function get_perc() { $info = array(); $info['net_info'] = get_network(); $info['cpu_info'] = get_cpu(); $info['disk_info'] = get_disk(); $info['mem_info'] = get_mem(); return $info; }
<footer class="container margin-top-30"> <div class="row"> <div class="col-lg-12"> <p class="templatemo-copyright-container text-uppercase small templatemo-brown"> <span class="templatemo-copyright-text">Copyright © 2015 <a href="#" class="templatemo-gold">Amazon Web Services</a></span> <!-- <span class="templatemo-copyright-design">Design: <a href="http://www.templatemo.com" class="templatemo-gold">templatemo</a></span> --> </p> </div> </div> </footer> <script src="js/jquery-1.11.1.min.js"></script> <script src="js/templatemo_script.js"></script> <script> // line chart data <?php $cpuTon = get_cpu(); $cpuOne = $cpuTon[0]; $cpuTwo = $cpuTon[1]; $cpuThr = $cpuTon[2]; ?> var cpuData = { labels : ["One Min","Five Min","Fifteen Min"], datasets : [ { fillColor : "rgba(172,194,132,0.4)", strokeColor : "#ACC26D", pointColor : "#fff", pointStrokeColor : "#9DB86D", data : [<?php print $cpuOne; ?>
$cpu_nice_old = get_userdata("cpu_nice"); $cpu_sys_old = get_userdata("cpu_sys"); $cpu_idle_old = get_userdata("cpu_idle"); $cpu_io_old = get_userdata("cpu_io"); $cpu_user = $tmp[2]; $cpu_nice = $tmp[3]; $cpu_sys = $tmp[4]; $cpu_idle = $tmp[5]; $cpu_io = $tmp[6]; $diff_used = $cpu_user - $cpu_user_old + ($cpu_nice - $cpu_nice_old) + ($cpu_sys - $cpu_sys_old) + ($cpu_io - $cpu_io_old); $diff_total = $cpu_user - $cpu_user_old + ($cpu_nice - $cpu_nice_old) + ($cpu_sys - $cpu_sys_old) + ($cpu_io - $cpu_io_old) + ($cpu_idle - $cpu_idle_old); $cpu = $diff_used / $diff_total * 100; set_userdata(array("cpu_user" => $cpu_user, "cpu_nice" => $cpu_nice, "cpu_sys" => $cpu_sys, "cpu_idle" => $cpu_idle, "cpu_io" => $cpu_io)); return $cpu; } $f_data[] = array('cpu_use', round(get_cpu(), 2) . " %"); function get_mem() { $file = file("/proc/meminfo"); $data = humanSize(substr($file[0], strpos($file[0], " "), strrpos($file[0], " ") - strpos($file[0], " ")) * 1024); $str = $data[0] . " " . $data[2]; $data = humanSize(substr($file[1], strpos($file[1], " "), strrpos($file[1], " ") - strpos($file[1], " ")) * 1024, $data[1]); $str = $data[0] . "/" . $str; return $str; /* $memory["total"]=round(substr($file[0],strpos($file[0]," "),strrpos($file[0]," ")-strpos($file[0]," "))/(1024*1024),2); $memory["free"]=round(substr($file[1],strpos($file[1]," "),strrpos($file[1]," ")-strpos($file[1]," "))/(1024*1024),2); return $memory["free"].'/'.$memory["total"]; */ } $f_data[] = array('mem_use', get_mem());