Page 1 of 1

Ping a server and fetch a 'clean' result

Posted: Fri Jul 09, 2010 4:55 pm
by vaerge2
Hi,

Yes, somewhat new in PHP - so please bare with me.

What I am trying to do is to make a script which pings some IPs X times every Y minutes, and pick up the result and store it in a database. The part about getting the IPs to ping from a list (database), doing it every Y minutes (cron job) and getting it stored in a database - those parts I can handle. What I cannot figure out how to do is this:

Ping from PHP and pick up the result and then store it (timestamp, IP, and time in ms) in an array.

Can someone please help me on this?

Thanks a lot!!

//Anders

Re: Ping a server and fetch a 'clean' result

Posted: Fri Jul 09, 2010 7:13 pm
by requinix
Unless you want to try your hand at ICMP, learn about:
1. Executing shell commands using (for example) exec,
2. Redirecting shell output to a file, and
3. Reading files in PHP.

Re: Ping a server and fetch a 'clean' result

Posted: Fri Jul 09, 2010 8:39 pm
by vaerge2
Good and simple solution - fast to implement - I have it rolling already.

Thanks!!