-
Notifications
You must be signed in to change notification settings - Fork 0
/
pm2web.html
155 lines (121 loc) · 5.47 KB
/
pm2web.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-JavaScript-Templates/3.11.0/js/tmpl.js"></script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/circliful/1.2.1/js/jquery.circliful.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/circliful/1.2.1/css/jquery.circliful.css"><link>
<style>
.card-image {
width:80px;
background-image: url("https://halftonepro.com/images/demo-poly1.jpg");
}
</style>
</head>
<body>
<script>
function secondsToString(seconds)
{
var numyears = Math.floor(seconds / 31536000);
var numdays = Math.floor((seconds % 31536000) / 86400);
var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600);
var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60);
var numseconds = (((seconds % 31536000) % 86400) % 3600) % 60;
return numyears + " years " + numdays + " days " + numhours + " hours " + numminutes + " minutes " + numseconds + " seconds";
}
/**
* Converts a long string of bytes into a readable format e.g KB, MB, GB, TB, YB
*
* @param {Int} num The number of bytes.
*/
function readableBytes(bytes) {
var i = Math.floor(Math.log(bytes) / Math.log(1024)),
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
return (bytes / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + sizes[i];
}
$.getJSON( "http://localhost:9615", function( data ) {
var items = [];
document.getElementById("result").innerHTML = tmpl("tmpl-demo", data);
});
</script>
<script type="text/x-tmpl" id="tmpl-demo">
<h2 class="header">{%=o.system_info.hostname%}</h2>
UpTime: {%=secondsToString(Math.floor(o.system_info.uptime))%}</h2>
<div class="card horizontal">
<div class="card-image">
</div>
<div class="card-stacked">
<div class="card-content">
<p>
<img src="http://icons.iconarchive.com/icons/tpdkdesign.net/refresh-cl/256/System-Memory-icon.png" width="50px" /> Total : {%=readableBytes(o.monit.total_mem)%}
Free : {%=readableBytes(o.monit.free_mem)%}
Memoire used :
<progress value="{%=o.monit.total_mem-o.monit.free_mem%}" max="{%=o.monit.total_mem%}"></progress>
</p>
Load Average : {% for (let value of Object.values(o.monit.loadavg)) { %}
{%= value %}
{% } %}
<h4 class="header">Process : </h4>
{% for (var i=0; i<o.processes.length; i++) { %}
<div class="card horizontal">
<div class="card-content">
<li onclick="$('#env{%=i%}').toggle()" style=" cursor:hand">{%=o.processes[i].name%}
{%=o.processes[i].monit.cpu%} : {%=readableBytes(o.processes[i].monit.memory)%} <progress value="{%=o.processes[i].monit.memory%}" max="{%=o.monit.total_mem%}"></progress>
</li>
<textarea id="env{%=i%}" rows="40" cols="50" style="height:150px;display:none">
{% for (let value of Object.keys(o.processes[i].pm2_env)) { %}
{%=value%}: {%=o.processes[i].pm2_env[value]%}{% } %}
</textarea>
</div>
</div>
{% } %}
<img src="https://www.computerhope.com/jargon/c/cpu.jpg" width="45px" />
<h4 class="header">CPU : </h4>
{% for (var i=0; i<o.monit.cpu.length; i++) { %}
<div class="card horizontal">
<div class="card-content">
<li onclick="$('#cpu{%=i%}').toggle()" style=" cursor:hand" >{%=o.monit.cpu[i].model%}</li>
<ul id="cpu{%=i%}" style="display:none" >
<li>Speed : {%=o.monit.cpu[i].speed%} Hz</li>
<li>Idle : {%=o.monit.cpu[i].times.idle%}
<li>Sys : {%=o.monit.cpu[i].times.sys%}
<li>User : {%=o.monit.cpu[i].times.user%}
</ul>
</div>
</div>
{% } %}
<img src="https://media.screwfix.com/is/image//ae235?src=ae235/12840_P&$prodImageMedium$" width="45px" />
<h4 class="header">Network : </h4>
{% for (let key of Object.keys(o.monit.interfaces)) { %}
<div class="card horizontal">
<div class="card-content">
<span ><b>{%=key%}</b></span>
<ul>
{% for (var i=0; i<o.monit.interfaces[key].length; i++) { %}
<hr>
<li> Adress {%= o.monit.interfaces[key][i].address%}
<li> NetMask {%= o.monit.interfaces[key][i].netmask%}
<li> Family {%= o.monit.interfaces[key][i].family%}
<li> Mac {%= o.monit.interfaces[key][i].mac%}
{% } %}
</ul>
</div>
</div>
{% } %}
</div>
<div class="card-action">
<a href="#">This is a link</a>
</div>
</div>
</div>
</script>
<div class="container">
<div class="row">
<div id="result"></div>
</div>
</div>
</body>
</html>