Re: Checking Server Status with PHP
From: Andrew _at_ Rockface (_at_)
Date: 01/29/05
- Next message: Titus A Ducksass - AKA broken-record: "Re: Need some ideas"
- Previous message: Shane Malden: "Dynamic Pages"
- In reply to: J.O. Aho: "Re: Checking Server Status with PHP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 Jan 2005 17:02:04 +0000 (UTC)
J.O. Aho wrote:
> Andrew @ Rockface wrote:
>> Sypher wrote:
>>
>>> Is there a simple way to check some server's status with php ?
>>> I mean, checking if some servers are up or down ...
>>> Like teamspeak server, ftp, sftp, and others, all in the local
>>> server.
>>>
>>> Thanks in advance to any who answers ...
>>> Regards
>>
>>
>> $server = "apache";
>> $up = `ps ax | grep "$server" | grep -v "grep"`;
>> if ($up != "") {echo "$server is up:<pre>$up</pre>";}
>> else {echo "$server is down:<pre>$up</pre>";}
>>
>
> Drawback: The real service may be have teken down and a service run
> as another user may be up.
Good point.
> The init script had been a better way to comfirm if the real service
> is up, but that requiers that the php script would be run as root.
>
> $server = "apache";
> $user="apache";
> $up = `ps -u $user | grep "$server" | grep -v "grep"`;
> if($up != "") {
> echo "$server is up:<pre>$up</pre>";
> } else {
> /* No point in outputting "<pre>$up</pre>" as it
> will just generate "<pre></pre>" */
> echo "$server is down!";
The flaws of cut and paste ;)
> }
>
> You should make a check for services that shouldn't be up too.
>
>
> //Aho
- Next message: Titus A Ducksass - AKA broken-record: "Re: Need some ideas"
- Previous message: Shane Malden: "Dynamic Pages"
- In reply to: J.O. Aho: "Re: Checking Server Status with PHP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|