Commit e6bc4237 authored by Ad Schellevis's avatar Ad Schellevis

add actual memory/disc/swap usage in dashboard, feature request...

add actual memory/disc/swap usage in dashboard, feature request https://github.com/opnsense/core/issues/66
parent 0c326261
...@@ -192,13 +192,13 @@ function get_temp() { ...@@ -192,13 +192,13 @@ function get_temp() {
function get_mounted_filesystems() { function get_mounted_filesystems() {
$mout = ""; $mout = "";
$filesystems = array(); $filesystems = array();
exec("/bin/df -Tht ufs,zfs,cd9660 | /usr/bin/awk '{print $1, $2, $3, $6, $7;}'", $mout); exec("/bin/df -Tht ufs,zfs,cd9660 | /usr/bin/awk '{print $1, $2, $3, $4, $6, $7;}'", $mout);
/* Get rid of the header */ /* Get rid of the header */
array_shift($mout); array_shift($mout);
foreach ($mout as $fs) { foreach ($mout as $fs) {
$f = array(); $f = array();
list($f['device'], $f['type'], $f['total_size'], $f['percent_used'], $f['mountpoint']) = explode(' ', $fs); list($f['device'], $f['type'], $f['total_size'], $f['used_size'], $f['percent_used'], $f['mountpoint']) = explode(' ', $fs);
/* We dont' want the trailing % sign. */ /* We dont' want the trailing % sign. */
$f['percent_used'] = trim($f['percent_used'], '%'); $f['percent_used'] = trim($f['percent_used'], '%');
...@@ -242,6 +242,7 @@ function mem_usage() { ...@@ -242,6 +242,7 @@ function mem_usage() {
return $memUsage; return $memUsage;
} }
function update_date_time() { function update_date_time() {
$datetime = date("D M j G:i:s T Y"); $datetime = date("D M j G:i:s T Y");
return $datetime; return $datetime;
......
...@@ -274,7 +274,7 @@ $filesystems = get_mounted_filesystems(); ...@@ -274,7 +274,7 @@ $filesystems = get_mounted_filesystems();
<span class="sr-only"></span> <span class="sr-only"></span>
</div> </div>
</div> </div>
<span id="memusagemeter"><?= $memUsage.'%'; ?></span> of <?= sprintf("%.0f", get_single_sysctl('hw.physmem') / (1024*1024)) ?> MB <span id="memusagemeter"><?= $memUsage.'%'; ?></span> used <?= sprintf("%.0f/%.0f", $memUsage/100.0 * get_single_sysctl('hw.physmem') / (1024*1024) ,get_single_sysctl('hw.physmem') / (1024*1024)) ?> MB
</td> </td>
</tr> </tr>
<?php if($showswap == true): ?> <?php if($showswap == true): ?>
...@@ -287,7 +287,7 @@ $filesystems = get_mounted_filesystems(); ...@@ -287,7 +287,7 @@ $filesystems = get_mounted_filesystems();
<span class="sr-only"></span> <span class="sr-only"></span>
</div> </div>
</div> </div>
<span id="swapusagemeter"><?= $swapusage.'%'; ?></span> of <?= sprintf("%.0f", `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $2;}'`) ?> MB <span id="swapusagemeter"><?= $swapusage.'%'; ?></span> used <?= sprintf("%.0f/%.0f",`/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $3;}'`, `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $2;}'`) ?> MB
</td> </td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
...@@ -302,7 +302,7 @@ $filesystems = get_mounted_filesystems(); ...@@ -302,7 +302,7 @@ $filesystems = get_mounted_filesystems();
</div> </div>
</div> </div>
<?PHP if (substr(basename($fs['device']), 0, 2) == "md") $fs['type'] .= " in RAM"; ?> <?PHP if (substr(basename($fs['device']), 0, 2) == "md") $fs['type'] .= " in RAM"; ?>
<?PHP echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> of <?PHP echo $fs['total_size'];?> <?PHP echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> used <?PHP echo $fs['used_size'] ."/". $fs['total_size'];?>
<br /> <br />
<?PHP endforeach; ?> <?PHP endforeach; ?>
</td> </td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment