onlyican Posted September 17, 2006 Share Posted September 17, 2006 Hey guysI want to monitor some tings on my serverDoes anyone know how to check Server LoadI am running php4.4.1(and should be running 5.1.4 tomorrow)I know how to check the Uptime[code]<?php $data = shell_exec('uptime'); $uptime = explode(' up ', $data); $uptime = explode(',', $uptime[1]); $uptime = $uptime[0].', '.$uptime[1]; echo (''.$uptime.''); ?>[/code]But I want to check Server Load (Yes, the whole server)and is it possible to monitor Bandwidth on a certain page as well(maybe add a lil script which gets the server load, and stores to a DB or something) Link to comment https://forums.phpfreaks.com/topic/21099-check-server-load/ Share on other sites More sharing options...
Daniel0 Posted September 18, 2006 Share Posted September 18, 2006 This will get the server load.[code]<?php$loadavg_file = @file_get_contents('/proc/loadavg');$loadavg_file = explode(' ',$loadavg_file);$loadavg = trim($loadavg_file[0]);if(empty($loadavg)){ $uptime_exec= explode(' ',@exec('uptime')); if(!empty($uptime_exec)) { $loadavg= $uptime_exec[count($uptime_exec)-1]; } else { $loadavg= '--'; }}echo "Server load: {$loadavg}";?>[/code] Link to comment https://forums.phpfreaks.com/topic/21099-check-server-load/#findComment-93821 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.