Jump to content

Recommended Posts

Hey guys

I want to monitor some tings on my server

Does anyone know how to check Server Load

I 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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.