Ping a server and fetch a 'clean' result

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vaerge2
Forum Newbie
Posts: 3
Joined: Fri Jul 09, 2010 4:53 pm

Ping a server and fetch a 'clean' result

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
vaerge2
Forum Newbie
Posts: 3
Joined: Fri Jul 09, 2010 4:53 pm

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

Post by vaerge2 »

Good and simple solution - fast to implement - I have it rolling already.

Thanks!!
Post Reply