mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Some more tweaks to state and mbuf update/output on dashboard widget.
This commit is contained in:
parent
97f544d7e5
commit
2cb760dae2
@ -22,6 +22,7 @@ function get_stats() {
|
||||
$stats['cpufreq'] = get_cpufreq();
|
||||
$stats['load_average'] = get_load_average();
|
||||
$stats['mbuf'] = get_mbuf();
|
||||
$stats['mbufpercent'] = get_mbuf(true);
|
||||
$stats['statepercent'] = get_pfstate(true);
|
||||
$stats = join("|", $stats);
|
||||
return $stats;
|
||||
@ -151,7 +152,7 @@ function get_pfstate($percent=false) {
|
||||
$curentries = $matches[1];
|
||||
}
|
||||
if ($percent)
|
||||
return ($curentries / $maxstates) * 100;
|
||||
return round(($curentries / $maxstates) * 100, 0);
|
||||
else
|
||||
return $curentries . "/" . $maxstates;
|
||||
}
|
||||
@ -167,11 +168,13 @@ function get_hwtype() {
|
||||
return;
|
||||
}
|
||||
|
||||
function get_mbuf() {
|
||||
function get_mbuf($percent=false) {
|
||||
$mbufs_output=trim(`/usr/bin/netstat -mb | /usr/bin/grep "mbuf clusters in use" | /usr/bin/awk '{ print $1 }'`);
|
||||
list( $mbufs_current, $mbufs_cache, $mbufs_total, $mbufs_max ) = explode( "/", $mbufs_output);
|
||||
$mbufusage = round(($mbufs_total / $mbufs_max) * 100);
|
||||
return $mbufusage;
|
||||
if ($percent)
|
||||
return round(($mbufs_total / $mbufs_max) * 100, 0);
|
||||
else
|
||||
return "{$mbufs_total}/{$mbufs_max}";
|
||||
}
|
||||
|
||||
function get_temp() {
|
||||
|
||||
@ -44,7 +44,8 @@ function stats(x) {
|
||||
updateCpuFreq(values[9]);
|
||||
updateLoadAverage(values[10]);
|
||||
updateMbuf(values[11]);
|
||||
updateStateMeter(values[12]);
|
||||
updateMbufMeter(values[12]);
|
||||
updateStateMeter(values[13]);
|
||||
}
|
||||
|
||||
function updateMemory(x) {
|
||||
@ -57,6 +58,11 @@ function updateMemory(x) {
|
||||
}
|
||||
|
||||
function updateMbuf(x) {
|
||||
if(jQuery('#mbuf'))
|
||||
jQuery("#mbuf").html(x);
|
||||
}
|
||||
|
||||
function updateMbufMeter(x) {
|
||||
if(jQuery('#mbufusagemeter'))
|
||||
jQuery("#mbufusagemeter").html(x + '%');
|
||||
if(jQuery('#mbufwidtha'))
|
||||
|
||||
@ -199,12 +199,11 @@ $curcfg = $config['system']['firmware'];
|
||||
<td width="25%" class="vncellt"><?=gettext("MBUF Usage");?></td>
|
||||
<td width="75%" class="listr">
|
||||
<?php
|
||||
$mbufs_output=trim(`netstat -mb | grep "mbuf clusters in use" | awk '{ print $1 }'`);
|
||||
list( $mbufs_current, $mbufs_cache, $mbufs_total, $mbufs_max ) = explode( "/", $mbufs_output);
|
||||
$mbufusage = sprintf("%.2f", ($mbufs_total / $mbufs_max) * 100);
|
||||
$mbufstext = get_mbuf();
|
||||
$mbufusage = get_mbuf(true);
|
||||
?>
|
||||
<img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="mbufwidtha" id="mbufwidtha" width="<?= round($mbufusage); ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="mbufwidthb" id="mbufwidthb" width="<?= (100 - $mbufusage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
|
||||
<br/><span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<?= $mbufs_total ?>/<?= $mbufs_max ?>)
|
||||
<br/><span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<span id="mbuf"><?= $mbufstext ?></span>)
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (get_temp() != ""): ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user