diff options
author | Cristian Feldman <vizvayu@gmail.com> | 2012-05-17 22:33:31 -0300 |
---|---|---|
committer | Cristian Feldman <vizvayu@gmail.com> | 2012-05-18 00:53:21 -0300 |
commit | 4dedd18a80ac4f1a9187ddb042deb439710c5e6f (patch) | |
tree | 43750b3b08fe5dc93e40796e6c07a9b27757e730 /usr/local/www | |
parent | 735021f5dbca32e46b04515e0e852dae4d33546f (diff) | |
download | pfsense-4dedd18a80ac4f1a9187ddb042deb439710c5e6f.zip pfsense-4dedd18a80ac4f1a9187ddb042deb439710c5e6f.tar.gz |
System info widget on dashboard now updates CPU Frequency automatically
Diffstat (limited to 'usr/local/www')
-rw-r--r-- | usr/local/www/includes/functions.inc.php | 16 | ||||
-rw-r--r-- | usr/local/www/javascript/index/ajax.js | 6 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/system_information.widget.php | 12 |
3 files changed, 23 insertions, 11 deletions
diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 8ceea4d..3039c35 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -19,6 +19,7 @@ function get_stats() { $stats['interfacestatistics'] = get_interfacestats(); $stats['interfacestatus'] = get_interfacestatus(); $stats['gateways'] = get_gatewaystats(); + $stats['cpufreq'] = get_cpufreq(); $stats = join("|", $stats); return $stats; } @@ -215,6 +216,21 @@ function update_date_time() { return $datetime; } +function get_cpufreq() { + $cpufreqs = ""; + $out = ""; + exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs); + $cpufreqs = explode(" ", trim($cpufreqs[0])); + $maxfreq = explode("/", $cpufreqs[0]); + $maxfreq = $maxfreq[0]; + $curfreq = ""; + exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq); + $curfreq = trim($curfreq[0]); + if ($curfreq != $maxfreq) + $out = "Current: {$curfreq} MHz, Max: {$maxfreq} MHz"; + return $out; +} + function get_interfacestats() { global $config; diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index fffb5c0..eab0119 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -41,6 +41,7 @@ function stats(x) { updateInterfaceStats(values[6]); updateInterfaces(values[7]); updateGatewayStats(values[8]); + updateCpuFreq(values[9]); } function updateMemory(x) { @@ -100,6 +101,11 @@ function updateGatewayStats(x){ } } +function updateCpuFreq(x) { + if(jQuery('#cpufreq')) + jQuery("#cpufreq").html(x); +} + function updateInterfaceStats(x){ if (widgetActive("interface_statistics")){ statistics_split = x.split(","); diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 5658c54..776679a 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -135,18 +135,8 @@ $curcfg = $config['system']['firmware']; exec("/sbin/sysctl -n hw.model", $cpumodel); $cpumodel = implode(" ", $cpumodel); echo (htmlspecialchars($cpumodel)); - - $cpufreqs = ""; - exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs); - $cpufreqs = explode(" ", trim($cpufreqs[0])); - $maxfreq = explode("/", $cpufreqs[0]); - $maxfreq = $maxfreq[0]; - $curfreq = ""; - exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq); - $curfreq = trim($curfreq[0]); - if ($curfreq != $maxfreq) - echo "<br/>Current: {$curfreq} MHz, Max: {$maxfreq} MHz"; ?> + <div id="cpufreq"><?= get_cpufreq(); ?></div> </td> </tr> <?php if ($hwcrypto): ?> |