View Single Post
  #7  
Old 19th August 2006, 00:42
MicCo MicCo is offline
Junior Member
 
Join Date: Aug 2006
Location: Denmark
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Post

Quote:
Originally Posted by falko
What's in /root/ispconfig/scripts/shell/check_services.php?
This is the contents of the file:

Quote:
class check_services {

function warning()
{

$warning = "";

if(!$this->_check_tcp("213.173.250.118",80)) {
$warning .= "WARNING: service web not running (server: epsilon.eurohost.dk, port: 80)!\n\n";

}
if(!$this->_check_ftp("213.173.250.118",21)) {
$warning .= "WARNING: service ftp not running (server: epsilon.eurohost.dk, port: 21)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118",25)) {
$warning .= "WARNING: service mail not running (server: epsilon.eurohost.dk, port: 25)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118",110)) {
$warning .= "WARNING: service pop3 not running (server: epsilon.eurohost.dk, port: 110)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/SSL",443)) {
$warning .= "WARNING: service not running (server: epsilon.eurohost.dk, port: 443)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/ISPConfig",81)) {
$warning .= "WARNING: service not running (server: epsilon.eurohost.dk, port: 81)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/SSH",22)) {
$warning .= "WARNING: service not running (server: epsilon.eurohost.dk, port: 22)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/TCP",53)) {
$warning .= "WARNING: service dns not running (server: epsilon.eurohost.dk, port: 53)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/UDP",53)) {
$warning .= "WARNING: service dns not running (server: epsilon.eurohost.dk, port: 53)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/Webmin",10000)) {
$warning .= "WARNING: service not running (server: epsilon.eurohost.dk, port: 10000)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/IMAP2",143)) {
$warning .= "WARNING: service mail not running (server: epsilon.eurohost.dk, port: 143)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/IMAPS",993)) {
$warning .= "WARNING: service mail not running (server: epsilon.eurohost.dk, port: 993)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/POP3S",995)) {
$warning .= "WARNING: service pop3 not running (server: epsilon.eurohost.dk, port: 995)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/MySQL",3306)) {
$warning .= "WARNING: service not running (server: epsilon.eurohost.dk, port: 3306)!\n\n";

}
if(!$this->_check_tcp("213.173.250.118/unknown",953)) {
$warning .= "WARNING: service web not running (server: epsilon.eurohost.dk, port: 953)!\n\n";

}



if($warning != ""){
$warning .= "Message generated at ".date("F j, Y, G:i", time()).".\n";
return $warning;
} else {
return false;
}

}

function _check_tcp ($host,$port) {

$fp = fsockopen ($host, $port, &$errno, &$errstr, 2);

if ($fp) {
fclose($fp);
return true;
} else {
return false;
}
}

function _check_udp ($host,$port) {

$fp = fsockopen ('udp://'.$host, $port, &$errno, &$errstr, 2);

if ($fp) {
fclose($fp);
return true;
} else {
return false;
}
}

function _check_ftp ($host,$port){

$conn_id = @ftp_connect($host, $port);

if($conn_id){
@ftp_close($conn_id);
return true;
} else {
return false;
}
}
}

$cs = new check_services;

if(is_file("/home/admispconfig/ispconfig/adminmail.txt")){
$fp = fopen ("/home/admispconfig/ispconfig/adminmail.txt", "r");
$email = trim(fread($fp, filesize ("/home/admispconfig/ispconfig/adminmail.txt")));
fclose($fp);
$email = str_replace("\r\n", "", $email);
$email = str_replace("\r", "", $email);
$email = str_replace("\n", "", $email);
}
$msg = $cs->warning();
if(!empty($email) && strstr($email, "@") && strlen($email) > 3 && $msg) mail($email, "WARNING: services not running", $msg);

Looking forward to Your comment.
__________________
Best regards,

MicCo
________________________________
Reply With Quote