function get_stats() { $stats['cpu'] = cpu_usage(); $stats['mem'] = mem_usage(); $stats['uptime'] = get_uptime(); $stats['states'] = get_pfstate(); $stats['temp'] = get_temp(); $stats['datetime'] = update_date_time(); $stats['interfacestatistics'] = get_interfacestats(); $stats['interfacestatus'] = get_interfacestatus(); $stats['gateways'] = get_gatewaystats(); $stats = join("|", $stats); return $stats; }
function get_stats() { $stats['cpu'] = cpu_usage(); $stats['mem'] = mem_usage(); $stats['uptime'] = get_uptime(); $stats['states'] = get_pfstate(); $stats['temp'] = get_temp(); $stats['datetime'] = update_date_time(); $stats['interfacestatistics'] = get_interfacestats(); $stats['interfacestatus'] = get_interfacestatus(); $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; }
modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ##|+PRIV ##|*IDENT=page-diagnostics-cpuutilization ##|*NAME=Diagnostics: CPU Utilization page ##|*DESCR=Allow access to the 'Diagnostics: CPU Utilization' page. ##|*MATCH=stats.php* ##|-PRIV require_once "guiconfig.inc"; require_once "includes/functions.inc.php"; $cpu = cpu_usage(); echo $cpu; exit;
?> <tr> <td class="vncellt">Son değişiklik</td> <td class="listr"><?php echo strftime("%T <br> %e %B %Y %A", intval($config['revision']['time'])); ?> </td> </tr> <?php } ?> <tr> <td class="vncellt">İşlemci kullanımı</td> <td class="listr"> <?php $cpuUsage = cpu_usage(); ?> <div class="progress-container"> <div id="cpubar" class="progress custom progress-danger progress-striped active"> <div id="cpuwidtha" class="bar" style="width: <?php echo $cpuUsage; ?> %;"></div> <span style="visibility: hidden;" id="cpu_usage"></span> </div> </div> </td> </tr> <tr> <td class="vncellt">RAM kullanımı</td> <td class="listr">
function loop_status($lcd) { global $g; global $config; $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; $lcdpanel_width = get_lcdpanel_width(); $lcdpanel_height = get_lcdpanel_height(); if (empty($g['product_name'])) { $g['product_name'] = "pfSense"; } $version = @file_get_contents("/etc/version"); $version = trim($version); $refresh_frequency = get_lcdpanel_refresh_frequency(); /* keep a counter to see how many times we can loop */ $i = 1; while ($i) { /* prepare the summary data */ if ($lcdpanel_height >= "4") { $summary_states = split("/", get_pfstate()); $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]); } else { $lcd_summary_data = ""; } $lcd_cmds = array(); $lcd_cmds[] = "widget_set welcome_scr title_wdgt \"Welcome to\""; $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$g['product_name']} {$version}\""; add_summary_values($lcd_cmds, "welcome_scr", $lcd_summary_data, $lcdpanel_width); /* process screens to display */ foreach ((array) $lcdproc_screens_config as $name => $screen) { if ($screen != "on") { continue; } switch ($name) { case "scr_time": $time = date("n/j/Y H:i"); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ System Time\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$time}\""; break; case "scr_uptime": $uptime = get_uptime_stats(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ System Uptime\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$uptime}\""; break; case "scr_hostname": exec("/bin/hostname", $output, $ret); $hostname = $output[0]; $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ System Name\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$hostname}\""; break; case "scr_system": $processor = cpu_usage(); $memory = mem_usage(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ System Stats\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"CPU {$processor}%, Mem {$memory}%\""; break; case "scr_disk": $disk = disk_usage(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ Disk Use\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"Disk {$disk}%\""; break; case "scr_load": $loadavg = get_loadavg_stats(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ Load Averages\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$loadavg}\""; break; case "scr_states": $states = get_pfstate(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ Traffic States\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"Curr/Max {$states}\""; break; case "scr_carp": $carp = get_carp_stats(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ CARP State\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$carp}\""; break; case "scr_ipsec": $ipsec = get_ipsec_stats(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ IPsec Tunnels\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$ipsec}\""; break; case "scr_slbd": $slbd = get_slbd_stats(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ Load Balancer\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$slbd}\""; break; case "scr_interfaces": $interfaces = get_interfaces_stats(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ Interfaces\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$interfaces}\""; break; case "scr_mbuf": $mbufstats = get_mbuf_stats(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ MBuf Usage\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$mbufstats}\""; break; case "scr_cpufrequency": $cpufreq = get_cpufrequency(); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"+ CPU Frequency\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 2 \"{$cpufreq}\""; break; } add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width); } send_lcd_commands($lcd, $lcd_cmds); sleep($refresh_frequency); $i++; } }
function loop_status($lcd) { global $g; global $config; global $lcdproc_connect_errors; $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; $lcdpanel_width = get_lcdpanel_width(); $lcdpanel_height = get_lcdpanel_height(); if (empty($g['product_name'])) { $g['product_name'] = "pfSense"; } $refresh_frequency = get_lcdpanel_refresh_frequency(); /* keep a counter to see how many times we can loop */ $i = 1; while ($i) { /* prepare the summary data */ if ($lcdpanel_height >= "4") { $summary_states = split("/", get_pfstate()); $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]); if ($lcdpanel_width > "16") { $lcd_summary_data = $lcd_summary_data . sprintf(" %3d%%", get_cpufrequency_perc()); } } else { $lcd_summary_data = ""; } $lcd_cmds = array(); /* initializes the widget counter */ $widget_counter = 0; /* controls the output leds */ if (outputled_enabled_CFontz633()) { $led_output_value = 0; /* LED 1: Interface status */ if (substr_count(get_interfaces_stats(), "Down") > 0) { $led_output_value = $led_output_value + pow(2, 0); } else { $led_output_value = $led_output_value + pow(2, 4); } /* LED 2: CARP status */ switch (outputled_carp()) { case -1: /* CARP disabled */ /* CARP disabled */ case 0: $led_output_value = $led_output_value + pow(2, 1); case 1: $led_output_value = $led_output_value + pow(2, 5); } /* LED 3: CPU Usage */ if (cpu_usage() > 50) { $led_output_value = $led_output_value + pow(2, 2); } else { $led_output_value = $led_output_value + pow(2, 6); } /* LED 4: Gateway status */ switch (outputled_gateway()) { case -1: /* Gateways not configured */ /* Gateways not configured */ case 0: $led_output_value = $led_output_value + 2 ^ 3; case 1: $led_output_value = $led_output_value + 2 ^ 7; } /* Sends the command to the panel */ $lcd_cmds[] = "output {$led_output_value}"; } /* process screens to display */ foreach ((array) $lcdproc_screens_config as $name => $screen) { if ($screen != "on") { continue; } switch ($name) { case "scr_version": $version = get_version(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$version}\""; break; case "scr_time": $time = date("n/j/Y H:i"); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$time}\""; break; case "scr_uptime": $uptime = get_uptime_stats(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$uptime}\""; break; case "scr_hostname": exec("/bin/hostname", $output, $ret); $hostname = $output[0]; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$hostname}\""; break; case "scr_system": $processor = cpu_usage(); $memory = mem_usage(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"CPU {$processor}%, Mem {$memory}%\""; break; case "scr_disk": $disk = disk_usage(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"Disk {$disk}%\""; break; case "scr_load": $loadavg = get_loadavg_stats(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$loadavg}\""; break; case "scr_states": $states = get_pfstate(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"Cur/Max {$states}\""; break; case "scr_carp": $carp = get_carp_stats(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$carp}\""; break; case "scr_ipsec": $ipsec = get_ipsec_stats(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$ipsec}\""; break; case "scr_slbd": $slbd = get_slbd_stats(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$slbd}\""; break; case "scr_interfaces": $interfaces = get_interfaces_stats(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$interfaces}\""; break; case "scr_mbuf": $mbufstats = get_mbuf_stats(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$mbufstats}\""; break; case "scr_cpufrequency": $cpufreq = get_cpufrequency(); $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 {$lcdpanel_width} 2 h 4 \"{$cpufreq}\""; break; case "scr_traffic": get_traffic_stats($in_data, $out_data); $lcd_cmds[] = "widget_set {$name} title_wdgt 1 1 \"{$in_data}\""; $lcd_cmds[] = "widget_set {$name} text_wdgt 1 2 \"{$out_data}\""; break; } if ($name != "scr_traffic_interface") { $widget_counter++; add_summary_values($lcd_cmds, $name, $lcd_summary_data); } } if (send_lcd_commands($lcd, $lcd_cmds)) { $lcdproc_connect_errors = 0; // Reset the error counter } else { //an error occurred return; } if ($refresh_frequency * $widget_counter > 5) { sleep(5); } else { sleep($refresh_frequency * $widget_counter); } $i++; } }
} else { if ($_GET['nav_intra'] == 'eval') { render_eval(); } else { if ($_GET['nav_intra'] == 'php_infos') { info_php(); } else { if ($_GET['nav_intra'] == 'infos_serveur') { ?> <div class="row" style="margin-top:15px;"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <div class="thumbnail-general" style="background:#dfe0e0; height:100px;"> <p style="font-size:16px;" class="bg-primary">Load average statut server Raspberry Pi type B</p> <div id="load_donnees"><?php cpu_usage(); ?> </div> </div> </div> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-5"> <div class="thumbnail" style="background:#dfe0e0; height:420px;"> <p style="font-size:16px;" class="bg-primary">Processor in server raspberry pi type b</p> <?php cpu_info(); ?> </div> </div> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-7"> <div class="thumbnail" style="background:#dfe0e0; height:200px;"> <p style="font-size:16px;" class="bg-primary">Memory in server raspberry pi type b</p>