Network Status
We run a status page for our servers found HereAs you can see uptime does not show on 2 of them one being sandy. The uptime url for sandy can been seen Here so we know it is working just not showing on page.
Below is the following code from our cron file that dumps information into the db and then on to the page. Something has changed on the 2 servers to not show uptime on this status page we do not know what. Any ideas anyone?
PHP Code:
#!/usr/bin/perl
use DBI;
use IO::Socket;
#print "Content-Type: text/html\n\n";
$db_user = "username"; #//enter your mySQL username here
$db_passwd = "password"; #//enter your mySQL password here
$vb_base = "dbname"; #//enter your vBulletin database name here
$dbh = DBI->connect("DBI:mysql:database=$vb_base",$db_user,$db_passwd);
$stm = $dbh->prepare("SELECT ip,uptimeurl,uptimeline FROM servers" );
$stm->execute();
while(@count=$stm->fetchrow_array){
if(@count[1] ne "" ){
$server = "@count[1]";
$server =~ s/http:\/\///g;
$server =~ s/\/.+//g;
$server =~ s/\/passthru.php//g;
$document = "@count[1]";
$remote = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>$server,
PeerPort=>"80",
Reuse=>1,
Timeout=>10,
Type => SOCK_STREAM);
if($remote){$remote -> send ("GET $document HTTP/1.0\n\n", 0);
@remote = <$remote>;
if(@remote[@count[2]] ne "" ){$stmx = $dbh->prepare("UPDATE servers SET [email=uptime='@remote[@count[2]]']uptime='@remote[@count[2]]'[/email] where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
} else {$stmx = $dbh->prepare("UPDATE servers SET uptime='No remote uptime monitoring available' where [email=ip='@count[0]']ip='@count[0]'[/email]" );
$stmx->execute();}};
$remotehttp = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>@count[0],
PeerPort=>"80",
Reuse=>1,
Timeout=>2,
Type => SOCK_STREAM);
if($remotehttp){$stmx = $dbh->prepare("UPDATE servers SET http='1' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}else
{$stmx = $dbh->prepare("UPDATE servers SET http='0' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
$remoteftp = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>@count[0],
PeerPort=>"21",
Reuse=>1,
Timeout=>2,
Type => SOCK_STREAM);
if($remoteftp){$stmx = $dbh->prepare("UPDATE servers SET ftp='1' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET ftp='0' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
$remotemysql = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>@count[0],
PeerPort=>"3306",
Reuse=>1,
Timeout=>2,
Type => SOCK_STREAM);
if($remotemysql){$stmx = $dbh->prepare("UPDATE servers SET mysql='1' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET mysql='0' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
$remotepop = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>@count[0],
PeerPort=>"110",
Reuse=>1,
Timeout=>2,
Type => SOCK_STREAM);
if($remotepop){$stmx = $dbh->prepare("UPDATE servers SET pop='1' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET pop='0' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
$remotesmtp = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>@count[0],
PeerPort=>"25",
Reuse=>1,
Timeout=>2,
Type => SOCK_STREAM);
if($remotesmtp){$stmx = $dbh->prepare("UPDATE servers SET smtp='1' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET smtp='0' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
$remotessh = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>@count[0],
PeerPort=>"22",
Reuse=>1,
Timeout=>2,
Type => SOCK_STREAM);
if($remotessh){$stmx = $dbh->prepare("UPDATE servers SET ssh='1' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET ssh='0' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
$remotedns = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>@count[0],
PeerPort=>"53",
Reuse=>1,
Timeout=>2,
Type => SOCK_STREAM);
if($remotedns){$stmx = $dbh->prepare("UPDATE servers SET dns='1' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET dns='0' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
$remotecp = IO::Socket::INET->new(
Proto=>"tcp",
PeerAddr=>@count[0],
PeerPort=>"2082",
Reuse=>1,
Timeout=>2,
Type => SOCK_STREAM);
if($remotecp){$stmx = $dbh->prepare("UPDATE servers SET cpanel='1' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET cpanel='0' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();}
$stmx = $dbh->prepare("UPDATE servers SET time='".time()."' where [email=ip='@count[0]']ip='@count[0]'[/email]" ); $stmx->execute();
}
$dbh->disconnect;