Jump to content
MakeWebGames

Monitor your server from PHP


a_bertrand

Recommended Posts

A little script to get the HDD activity and memory / cpu usage. I used popen but you may use other functions as well.

 

<?PHP
echo "<PRE>\n";
echo "[b]IO STATS[/b]\n";
$handle=popen("/usr/bin/iostat -k sda 1 2","r");
fread($handle,16000);
$lines=explode("\n",fread($handle,16000));
array_shift($lines);
array_shift($lines);
array_shift($lines);
echo implode("\n",$lines);
pclose($handle);

echo "[b]Top[/b]\n";
$handle=popen("/usr/bin/top -b -n 1","r");
echo fread($handle,16000);
pclose($handle);
echo "</PRE>\n";
?>
Link to comment
Share on other sites

Re: Monitor your server from PHP

Honestly you would run your PHP scripts on a windows server? Would be a non-sense... I would run on a windows server only for ASPX applications (with IIS) but certainly not for a PHP installation. I do use PHP on windows but only for the development ;)

Why? Well simply check the memory usage of your server with just the OS loaded, and tell me which of a Linux box or a Windows box use less memory, add to that cron and ssh and you know why I use Linux as servers.

Link to comment
Share on other sites

Re: Monitor your server from PHP

 

Honestly you would run your PHP scripts on a windows server? Would be a non-sense... I would run on a windows server only for ASPX applications (with IIS) but certainly not for a PHP installation. I do use PHP on windows but only for the development ;)

Why? Well simply check the memory usage of your server with just the OS loaded, and tell me which of a Linux box or a Windows box use less memory, add to that cron and ssh and you know why I use Linux as servers.

I'll give you a few reasons:

1.) GUI

2.) Compatibility with some nifty backend things you dont / cant get with unix / linux

3.) Memory is cheap 2gb DDR2 sticks are like $20

Link to comment
Share on other sites

Re: Monitor your server from PHP

- Remote GUI is not good due to his slowness, unless you are in the same network.

- Compatibility with some back-ends, then yes, but I rarely saw a back-end which doesn't offer yet web services.

- Server memory is never cheap, specially if you need to rent your dedicated server.

Link to comment
Share on other sites

Re: Monitor your server from PHP

 

Honestly you would run your PHP scripts on a windows server? Would be a non-sense... I would run on a windows server only for ASPX applications (with IIS) but certainly not for a PHP installation. I do use PHP on windows but only for the development ;)

Why? Well simply check the memory usage of your server with just the OS loaded, and tell me which of a Linux box or a Windows box use less memory, add to that cron and ssh and you know why I use Linux as servers.

I'll give you a few reasons:

1.) GUI

2.) Compatibility with some nifty backend things you dont / cant get with unix / linux

3.) Memory is cheap 2gb DDR2 sticks are like $20

GUI, let's see... windows windows windows... (for Windows) Xwindows, gnome, kde, and that tiny awesome fluxbox, among a few dozen more (for *nix).

Backend things you can't do with *nix flavours? name a couple...

Memory cheap... well as a_bertrand stated... Server memory is not cheap.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...