PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old May 28th, 2004, 08:45 PM
freelancer freelancer is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 freelancer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question help with site monitoring script

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

Reply With Quote
  #2  
Old June 2nd, 2004, 03:42 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
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.

Reply With Quote
  #3  
Old June 3rd, 2004, 07:10 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > help with site monitoring script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway