Im working on a project that is a IP monitor system.
I have created a database and the script works for the most part. Now i wanted to added a few functions to help us out.
Basicly this script runs and pings all these ip's and tells me weither or not its up. That works fine but takes almost 7 minutes to load cause there are 1320 Ip's it needs to ping. What i would like for it to do is only display the sites that failed the ping.
Here is the main script along with my ping script.
Ping FunctionCode:<html> <head> <title>IP Monitor</title> </head> <body> <meta http-equiv="refresh" content="600"> <?php echo "<center>IP Monitor</center>"; include ('functions.php'); require_once('inc/conn.php'); echo "<center><form action='{$_SERVER['PHP_SELF']}' method='POST'>\n". " <table width='450' border='0' cellspacing='3' cellpadding='3' id='ipmon'>\n". " <tr align=center valign=top>\n". " <td align=center valign=top><b>Property</b></td>\n". " <td align=center valign=top><b>IP</b></td>\n". " <td align=center valign=top><b>Status</b></td>\n". " </tr>\n"; $result = mysql_query("Select prop, ip from ipinfo"); while ($row = mysql_fetch_array($result)) { echo "<tr align=center valign=top>\n". "<td align=center valign=top>". $row['prop']. "</td>\n". "<td align=center valign=top>". $row['ip']. "</td>\n". "<td align=center valign=top>"; ping($row["ip"]); echo "</td>\n". "</tr>\n"; } echo "</table>\n". "</form>". "</center>"; ?> </body> </html>
Any help that could point me into the right direction is a big help and much appricated. Thanks!!!Code:<?php function ping($ProxyServer){ // false proxy used to generate connection error $ProxyPort = 80; $timeout= 5; // must use next two statements set_time_limit(0); //Time for script to run .. not sure how it works with 0 but you need it ignore_user_abort(true); //this will force the script running at the end // Create Proxy $handle = fsockopen($ProxyServer,$ProxyPort,$errno,$errstr,$timeout); if (!$handle){ echo "<img src='images/red.jpg'><br>"; } else { // copied method for PING like time operation $status = socket_get_status($handle); stream_set_timeout($handle); //send somthing $write = fwrite($handle,"echo this\n"); if(!$write){ return 0; } stream_set_blocking($handle,0); //Try to read. the server will most likely respond with a "ICMP Destination Unreachable" and end the read. But that is a responce! fread($handle,1024); fclose($handle); echo "<img src='images/green.jpg'><br>"; } } ?>


Reply With Quote
Bookmarks