|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I've found a site monitoring script (shown below) which is used to monitor if HTTP, FTP, SMTP, POP3, MySQL, IMAP, DNS, Secondry DNS, and DHCP are running and up.
Although I always get the following warning messages when trying to run the script: Warning: fsockopen(): unable to connect to www.domain.com:3306 in C:\Program Files\Apache Group\Apache2\htdocs\status.php on line 24 MySQL: PORT 3306 = Warning: fsockopen(): unable to connect to www.domain.com:3306 in C:\Program Files\Apache Group\Apache2\htdocs\status.php on line 24 IMAP: PORT 143 = Warning: fsockopen(): unable to connect to ns1.dnsjunction.com:3306 in C:\Program Files\Apache Group\Apache2\htdocs\status.php on line 24 DNS:[ns1.dnsjunction.com] PORT 53 = Warning: fsockopen(): unable to connect to ns1.dnsjunction.com:3306 in C:\Program Files\Apache Group\Apache2\htdocs\status.php on line 24 Secondary DNS:[ns1.dnsjunction.com] PORT 53 = Warning: fsockopen(): unable to connect to ns1.dnsjunction.com:3306 in C:\Program Files\Apache Group\Apache2\htdocs\status.php on line 24 DHCP: PORT 68 = ============================== Script used: <?php $domain = "www.domain.com"; $dns_server="ns1.dnsjunction.com"; $sec_dns="ns1.dnsjunction.com"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Server Status</title> </head> <body> <p><b><font size="5" face="Times New Roman, Times, serif">Server Status </font></b></p> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> Online:<img src="on.jpg"><br> Offline:<img src="off.jpg"><br><HR NOSHADE> <? function lookup_ports($hport,$hdomain) { $fp = fsockopen($hdomain, $hport,$errno,$errstr, 4); if (!$fp){ $data = "<img src='off.jpg'>"; } else { $data = "<img src='on.jpg'>"; fclose($fp); } return $data; } function get_server_software($domain) { $fp = fsockopen($domain, 80, $errno, $errstr, 1); if (!$fp) { return(""); } else { fputs($fp, "HEAD / HTTP/1.1\r\nHost: " . $domain . "\r\n\r\n"); while (!feof($fp)) { if (preg_match("/\bServer:/", $server = fgets($fp, 256))) { fclose($fp); return(substr($server, 8, -2)); } } fclose($fp); } } echo "<b>Checking services on: ".$domain; echo "<br><br>Server type :"; echo get_server_software($domain); echo "</b><br><br>"; echo "<br><li><b>HTTP:</b> <i>PORT 80 = <b>".lookup_ports("80",$domain)."</b></i></li>"; echo "<li><b>FTP:</b> <i>PORT 21 = <b>".lookup_ports("21",$domain)."</b></i></li>"; echo "<li><b>SMTP:</b> <i>PORT 25 = <b>".lookup_ports("25",$domain)."</b></i></li>"; echo "<li><b>POP:</b> <i>PORT 110 = <b>".lookup_ports("110",$domain)."</b></i></li>"; echo "<li><b>MySQL:</b> <i>PORT 3306 = <b>".lookup_ports("3306",$domain)."</b></i></li>"; echo "<li><b>IMAP:</b> <i>PORT 143 = <b>".lookup_ports("3306",$domain)."</b></i></li>"; echo "<li><b>DNS:[$dns_server]</b> <i>PORT 53 = <b>".lookup_ports("3306",$dns_server)."</b></i></li>"; echo "<li><b>Secondary DNS:[$sec_dns]</b> <i>PORT 53 = <b>".lookup_ports("3306",$sec_dns)."</b></i></li>"; echo "<li><b>DHCP:</b> <i>PORT 68 = <b>".lookup_ports("3306",$dns_server)."</b></i></li>"; ?> </font> </body> </html> Can someone tell me please where exactly is the error in the script, or why I am getting such warning. Thanks in advance |
|
#2
|
|||
|
|||
|
Well, at first glance the code looks like it it trying to issue an HTTP request to protocols that are obviously do not understand HTTP commands.
You are better off using this script to monitor web sites / pages. That was just from a quick glance... I did not have time to read it carefully so you might check into it.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
||||
|
||||
|
Maybe prepending "@" to your fsockopen calls will suppress the error message while still giving you a return you can use to print your custom status messages.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > help with site monitoring script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|