Jump to content

Recommended Posts

Posted

Hi,

 

I have been looking on the net for a short while for some software that will monitor a few key servers, and their services, then give a simple readout that I can display on a helpdesk web page. For example, I could monitor Exchange and POP and a display on helpdesk would simply read:

 

Email = OK

 

Nagios, Zenoss etc. all seem overkill, and I seem to be unable to visit the web pages without some sort of logon.

 

Any help appreciated,

 

Bengaul

Posted

Hi,

 

We have a simple php page which supports PING & Socket connections to key ports ... IE, we monitor DNS simply by checking its 'responding' on the correct port.

 

Not fool proof but works enough for us.

Posted
Hi,

 

We have a simple php page which supports PING & Socket connections to key ports ... IE, we monitor DNS simply by checking its 'responding' on the correct port.

 

Not fool proof but works enough for us.

 

That is the sort of thing I am after. It is simply so people can check the status of the network themselves. It need not be fool proof, but at least if our connection to the net is down, it would be simple for people to check if it is local to their machine or network wide, for example.

Posted

In the Bishop Barrington script (Which is just what I'm looking for!)

 

I don't understand the line:

"ping $host -c 1 -w 1"

 

I assume it runs that like a normal ping in command prompt, but the PING command in command prompt doesn't accept a -c command?

Posted

Correct, it is Linux ping command which is slightly different to Windows; which would be:

 

ping $host -n 1 -w 1

 

but the output and/or return value will be different so the PHP ping() function might need changing.

Posted
Yeah someone wrote something for me a while back which could be damn useful for me to integrate into an intranet (seeing as i don't know how to script/program) was written in php using sockets to check different services...i can even define none-standard ports for services etc.
Posted

I've been fiddling on a local Apache install, and tried errorlevel returning (1/0), tried shell_exec'ing and parsing output..nothing.

 

Typically, it's my missus day off..she loves PHP fiddling.

Posted
For Windows you will need to grab the output of the ping command and parse it. We don't run PHP on Windows here so I can't help I'm afraid.
Posted
For Windows you will need to grab the output of the ping command and parse it. We don't run PHP on Windows here so I can't help I'm afraid.

 

idot guide? so raher than have "ping $host -c 1 -w 1" you mean change to just "ping $host" ?

Posted

Not exactly. You only need to send one packet, and you can adjust how long you want the timeout. For example:

 

ping hostname -n 1 -w 500

 

Will ping 'hostname' once and wait a maximum of 500ms for a reply. You will need to get the output from this command and parse it to see if it was successful. Ping failures will contain "Request timed out." and successful pings will have something like "Reply from " in them.

  • Thanks 1
Posted (edited)

To get it working on IIS/Windows

 

Change these 2 lines. Its just because windows returns a different message when a ping fails.

 

	$rv = exec( "ping $host -n 1 -w 1" );
if( $rv != "Ping request could not find host ". $host . ". Please check the name and try again." )	{

 

This only works for named servers though and not the IP address as it comes back with a different reply.

 

I will see if I can modify it later.

Edited by zag
Posted

If you want to use this on IIS/Windows and use IP addresses rather than named hosts you can use these lines in the ping function.

 

$connect = "    Packets: Sent = 1, Received = 0, Lost = 1 (100% loss)," ;
$rv = exec("ping $host -n 1 -w 1");
   if( $connect == $rv )	

 

You could combine this with the previous guys post to cover named servers and IP addresses.

Posted

Here is the combined code to cover using an IP address or a named server.

 

function ping($host){
$hostconnect = "Ping request could not find host ". $host . ". Please check the name and try again." ;
$ipconnect = "    Packets: Sent = 1, Received = 0, Lost = 1 (100% loss)," ;
$rv = exec("ping $host -n 1 -w 1");
if( $ipconnect == $rv )	{
	return false;
} else {
	if( $hostconnect == $rv ) {
	return false;
} else {
	return true;
}
}
}

 

Just replace the whole of the ping function in the original code.

  • Thanks 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...