Hey,
I have three different servers, and I want to have a status page to show that services such as POP3, SMTP, HTTP, etc etc would be shown as active or failed...
could anyone point me in the correct direction please?
Printable View
Hey,
I have three different servers, and I want to have a status page to show that services such as POP3, SMTP, HTTP, etc etc would be shown as active or failed...
could anyone point me in the correct direction please?
well, basically it's a better job for a perl script. Either way, you didn't specify platform you'll be running the script on. That has to be said, because Windoze handles that different than UNIX/Linux
Why? PHP is quite capable of doing it.Quote:
well, basically it's a better job for a perl script.
No, PHP glosses over the differences quite nicely.Quote:
Either way, you didn't specify platform you'll be running the script on. That has to be said, because Windoze handles that different than UNIX/Linux
Untested.Code:<?php
$servers = array(
'Server One' => 'server1.com',
'Server Two' => 'server2.com',
'Server Three' => 'server3.com'
);
$services = array(
'SMTP' => 25,
'HTTP' => 80,
'POP' => 110
);
foreach($servers as $svrName => $host) {
?>
<table class="serviceTable">
<tr>
<th colspan="2" class="serverName">
<?php echo($svrName); ?>
</th>
</tr>
<?php
foreach($services as $svcName => $port) {
$status = 'Available';
$f;
if(!($f = fsockopen($host, $port, $errno, $errstr, 3)))
// The number above is a timeout. A bigger
// number will result in better accuracy but
// longer page loading time.
$status = 'Unavailable';
else fclose($f);
// The connection worked; we don't need to
// do anything else with the socket, so we
// close it.
?>
<tr>
<td class="serviceName">
<?php echo($svcName); ?>
</td>
<td class="serviceStatus">
<?php echo($status); ?>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
oh sorry, its a linux Fedora Core VPS with webfusion..
excellent thank you, What other port numbers would be useful?
scrub that, found this
Ouch. If you're going to check all those, it might be wise to just display/parse the output of nmap.
hmm, i'm trying to check mysql, but 118 158 and 3006 dont work.. any ideas?
no i dont want them all lol... just FTP, HTTP, SMTP, POP3, Mysql and shoutcast
done lolQuote:
Originally Posted by munkynpunky
although shoutcast is active but not showing correctly...
ports 8000 and 8001..
any ideas?
nope, actually mysql and shoutcast isnt reporting correctly.. any idea?
You should note that the ports shown on that list are only defaults; they may not be the same on your server.
Also, shoutcast is (as far as I know; I'm no expert in this area) a datagram protocol. That is to say, it's connectionless. This method won't work with it. I'm not entirely sure how one would check a datagram service. Perhaps send a packet and see if it responds?
oh ok, stupid question, how would i know what port the mysql server is using?
Cheers
drew
Hummps, I guess I'm always step ahead of the question, of course I stand corrected, but I was thinking more about checking if daemons are running of course, not port scan.Quote:
Originally Posted by Twey
If you don't specify it when you connect, it's the default.Quote:
oh ok, stupid question, how would i know what port the mysql server is using?
Checking if the port is open is probably one of the easiest ways of checking if the daemon is running. Failing that (and if the script was running on the same machine, which we know is not the case, thus rendering this approach impossible), it may be necessary to look for the daemon's lock file. However, Perl is not required, and indeed I can think of very few cases where Perl would be required over PHP (although the job may at times be made easier by a module).Quote:
I was thinking more about checking if daemons are running of course, not port scan.