Server Status Script

This is a basic PHP script that can be used to check the status of a server, or service running on it. It works by checking that a connection can be established, and there is a service running on the port number provided (i.e. checking port 80 will determine if a web server is running). It will not however verify that the server is running correctly.

The script is based on native PHP functions so there are no dependencies, simply download the class file and you're good to go. Should work with PHP 4 and up, but I've only ever tested on version 5.

Download

Source code for the class file can be found here: /static/ServerStatus.class.phps

Additionally the demo shown below can be obtained here: /static/ServerStatusDemo.phps

Save both files with a ".php" extension to use.

Demo

The demo below is checking the status of the server running this website (server01.leefindlow.com).

'Web Server','port' => 80, 'description' => 'Checking if a web server, such as Apache is running.'); $cfg['services'][1] = array('name' => 'SSH','port' => 22, 'description' => 'Checking if a Secure SHell service is running for remote access.'); $cfg['services'][2] = array('name' => 'MySQL','port' => 3306, 'description' => 'Checking if there is a MySQL database server running.'); $cfg['services'][3] = array('name' => 'SMTP','port' => 25, 'description' => 'Checking if there is an SMTP server running.'); $cfg['services'][4] = array('name' => 'FTP','port' => 21, 'description' => 'Checking if there is an FTP server running to allow file transfers.'); $cfg['services'][5] = array('name' => 'Telnet','port' => 23, 'description' => 'Checking if there is a Telnet server running to allow (unsecure) remote access.'); ?> '; echo ''; if($ss->checkServer($cfg['host'], $service['port'])){ echo ''; }else{ echo ''; } echo ''; echo ''; } ?>
Service
'.$service['name'].'OkFail'.$service['description'].'

↑ Top