Add option to add custom title in header (esm:custom_title)

Last login : add option to enable or not
Disk : add filesystem
Disk : values are centered
This commit is contained in:
ShevAbam 2015-07-13 09:43:34 +02:00
parent 9970343fe5
commit b330d193bb
7 changed files with 48 additions and 29 deletions

View File

@ -3,7 +3,8 @@
"version": "2.5",
"website": "http://www.ezservermonitor.com",
"check_updates": true,
"auto_refresh": 0
"auto_refresh": 0,
"custom_title": ""
},
"cpu": {
"enable_temperature": true
@ -19,6 +20,7 @@
]
},
"last_login": {
"enable": true,
"max": 5
},
"services": {

View File

@ -48,7 +48,12 @@ $update = $Config->checkUpdate();
</div>
<div id="hostname">
<?php echo Misc::getHostname(); ?> - <?php echo Misc::getLanIP(); ?>
<?php
if ($Config->get('esm:custom_title') != '')
echo $Config->get('esm:custom_title');
else
echo Misc::getHostname().' - '.Misc::getLanIP();
?>
</div>
<?php if (!is_null($update)): ?>
@ -221,8 +226,9 @@ $update = $Config->checkUpdate();
<table>
<thead>
<tr>
<th class="w10p">Filesystem</th>
<th class="w20p">Mount</th>
<th class="w35p">Use</th>
<th>Use</th>
<th class="w15p">Free</th>
<th class="w15p">Used</th>
<th class="w15p">Total</th>
@ -316,9 +322,13 @@ $update = $Config->checkUpdate();
</div>
<div class="box-content">
<table>
<tbody></tbody>
</table>
<?php if ($Config->get('last_login:enable') == true): ?>
<table>
<tbody></tbody>
</table>
<?php else: ?>
<p>Disabled</p>
<?php endif; ?>
</div>
</div>

View File

@ -152,11 +152,12 @@ esm.getDisk = function() {
var html = '';
html += '<tr>';
html += '<td>'+data[line].filesystem+'</td>';
html += '<td>'+data[line].mount+'</td>';
html += '<td><div class="progressbar-wrap"><div class="progressbar '+bar_class+'" style="width: '+data[line].percent_used+'%;">'+data[line].percent_used+'%</div></div></td>';
html += '<td class="t-right">'+data[line].free+'</td>';
html += '<td class="t-right">'+data[line].used+'</td>';
html += '<td class="t-right">'+data[line].total+'</td>';
html += '<td class="t-center">'+data[line].free+'</td>';
html += '<td class="t-center">'+data[line].used+'</td>';
html += '<td class="t-center">'+data[line].total+'</td>';
html += '</tr>';
$box.append(html);

View File

@ -4,7 +4,7 @@ $Config = new Config();
$datas = array();
if (!(exec('/bin/df -T | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $1}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6}\'', $df)))
if (!(exec('/bin/df -T | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df)))
{
$datas[] = array(
'total' => 'N.A',
@ -12,6 +12,7 @@ if (!(exec('/bin/df -T | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{pri
'free' => 'N.A',
'percent_used' => 0,
'mount' => 'N.A',
'filesystem' => 'N.A',
);
}
else
@ -20,7 +21,7 @@ else
foreach ($df as $mounted)
{
list($type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
if (strpos($type, 'tmpfs') !== false && $Config->get('disk:show_tmpfs') === false)
continue;
@ -35,6 +36,7 @@ else
'free' => Misc::getSize($free * 1024),
'percent_used' => trim($percent, '%'),
'mount' => $mount,
'filesystem' => $filesystem,
);
}
}

View File

@ -5,26 +5,29 @@ $Config = new Config();
$datas = array();
if (!(exec('/usr/bin/lastlog --time 365 | /usr/bin/awk -F\' \' \'{ print $1";"$5, $4, $8, $6}\'', $users)))
if ($Config->get('last_login:enable'))
{
$datas[] = array(
'user' => 'N.A',
'date' => 'N.A',
);
}
else
{
$max = $Config->get('last_login:max');
for ($i = 1; $i < count($users) && $i <= $max; $i++)
if (!(exec('/usr/bin/lastlog --time 365 | /usr/bin/awk -F\' \' \'{ print $1";"$5, $4, $8, $6}\'', $users)))
{
list($user, $date) = explode(';', $users[$i]);
$datas[] = array(
'user' => $user,
'date' => $date,
'user' => 'N.A',
'date' => 'N.A',
);
}
else
{
$max = $Config->get('last_login:max');
for ($i = 1; $i < count($users) && $i <= $max; $i++)
{
list($user, $date) = explode(';', $users[$i]);
$datas[] = array(
'user' => $user,
'date' => $date,
);
}
}
}
echo json_encode($datas);

View File

@ -35,9 +35,9 @@ img { border: 0; }
.debug { border: 1px solid red; }
.text_left, .t-left { text-align: left; }
.text_left, .t-left { text-align: left !important; }
.text_right, .t-right { text-align: right !important; }
.text_center, .t-center { text-align: center; }
.text_center, .t-center { text-align: center !important; }
.pfixed { position: fixed !important; }
.f-left { float: left; }
@ -66,6 +66,7 @@ img { border: 0; }
color: #666;
}*/
.w10p { width: 10%; }
.w15p { width: 15%; }
.w20p { width: 20%; }
.w33p { width: 33%; }

File diff suppressed because one or more lines are too long