Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

System info widget on dashboard now updates CPU Frequency automatically

  • Loading branch information...
commit 4dedd18a80ac4f1a9187ddb042deb439710c5e6f 1 parent 735021f
@vizvayu authored
View
16 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;
View
6 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(",");
View
12 usr/local/www/widgets/widgets/system_information.widget.php
@@ -135,18 +135,8 @@
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): ?>
Please sign in to comment.
Something went wrong with that request. Please try again.