diff --git a/uptime.php b/uptime.php index 6b4c5f8..0ec88ef 100644 --- a/uptime.php +++ b/uptime.php @@ -1,68 +1,135 @@ 0 ? $days . ' day'.($days > 1 ? 's' : '') : $hours.':'.$mins.':'.$seconds; -} +// ======================================================================================================================================== +// Uptime (free resources) +// ======================================================================================================================================== +// +// By Cameron Munroe ~ Mun +// Website: https://www.qwdsa.com/converse/threads/serverstatus-rebuild.43/ +// Version 0.1a +// +// +// should be cross compatiable with ServerStatus2 by @mojeda +// rebuild off the original uptime.php file, which can be found here: +// https://raw.githubusercontent.com/Munroenet/ServerStatus/master/uptime.php +// ======================================================================================================================================== -$array = array(); -$fh = fopen('/proc/uptime', 'r'); -$uptime = fgets($fh); -fclose($fh); -$uptime = explode('.', $uptime, 2); -$array['uptime'] = sec2human($uptime[0]); +// ======================================================================================================================================== +// Settings! +// ======================================================================================================================================== -$fh = fopen('/proc/meminfo', 'r'); - $mem = 0; - while ($line = fgets($fh)) { - $pieces = array(); - if (preg_match('/^MemTotal:\s+(\d+)\skB$/', $line, $pieces)) { - $memtotal = $pieces[1]; - } - if (preg_match('/^MemFree:\s+(\d+)\skB$/', $line, $pieces)) { - $memfree = $pieces[1]; - } - if (preg_match('/^Cached:\s+(\d+)\skB$/', $line, $pieces)) { - $memcache = $pieces[1]; - break; - } - } -fclose($fh); +$dl = 10; // At this percent of usage we will show it as RED! +$wl = 25; // At this percent of usage we will show it as Yellow! + +$memloc = '/proc/meminfo'; // This is where we get our info for meminfo. +// Debian / Ubuntu it is /proc/meminfo and should be the default for Linux! + +$fileloc = '/'; // This is the drive we are monitoring! +// You can change this to what ever folder you like, but root i.e. '/' is +// most important on your system! + +$uptimeloc = '/proc/uptime'; // this is where we get our info for uptime! + +$loadtime = 0; // the settings are: +// 0 for 1 minute average +// 1 for 5 minute average +// 2 for 15 minute average + +// ======================================================================================================================================== +// Getting Data! +// ======================================================================================================================================== +// You shouldn't edit anything below here, unless you know +// what you are doing! + +$post = array(); // this is the info that will be posted to the page, +// be careful what you put under this handle! + +$internal = array(); // internal array! + +$internal['uptime'] = explode('.', file_get_contents($uptimeloc), 2); +$internal['memraw'] = file_get_contents($memloc); +$internal['hddtotal'] = disk_total_space($fileloc); +$internal['hddfree'] = disk_free_space($fileloc); +$internal['load'] = sys_getloadavg(); + +// ======================================================================================================================================== +// Process The Data! +// ======================================================================================================================================== -$memmath = $memcache + $memfree; -$memmath2 = $memmath / $memtotal * 100; -$memory = round($memmath2) . '%'; +// uptime +$post['uptime'] = sec2human($internal['uptime'][0]); // Processing uptime and putting in post field! +// uptime done! -if ($memory >= "51%") { $memlevel = "success"; } -elseif ($memory <= "50%") { $memlevel = "warning"; } -elseif ($memory <= "35%") { $memlevel = "danger"; } -$array['memory'] = '