express
Mon 17th Mar '03, 8:18am
We run a status page for our servers found Here (http://www.realwebhost.net/netstatus/)
As you can see uptime does not show on 2 of them one being sandy. The uptime url for sandy can been seen Here (http://www.realwebhost.net/passthru.php) 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?
#!/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 uptime='@remote[@count[2]]' where ip='@count[0]'"); $stmx->execute();}
} else {$stmx = $dbh->prepare("UPDATE servers SET uptime='No remote uptime monitoring available' where ip='@count[0]'");
$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 ip='@count[0]'"); $stmx->execute();}else
{$stmx = $dbh->prepare("UPDATE servers SET http='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET ftp='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET mysql='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET pop='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET smtp='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET ssh='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET dns='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET cpanel='0' where ip='@count[0]'"); $stmx->execute();}
$stmx = $dbh->prepare("UPDATE servers SET time='".time()."' where ip='@count[0]'"); $stmx->execute();
}
$dbh->disconnect;
As you can see uptime does not show on 2 of them one being sandy. The uptime url for sandy can been seen Here (http://www.realwebhost.net/passthru.php) 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?
#!/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 uptime='@remote[@count[2]]' where ip='@count[0]'"); $stmx->execute();}
} else {$stmx = $dbh->prepare("UPDATE servers SET uptime='No remote uptime monitoring available' where ip='@count[0]'");
$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 ip='@count[0]'"); $stmx->execute();}else
{$stmx = $dbh->prepare("UPDATE servers SET http='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET ftp='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET mysql='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET pop='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET smtp='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET ssh='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET dns='0' where ip='@count[0]'"); $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 ip='@count[0]'"); $stmx->execute();}
else {$stmx = $dbh->prepare("UPDATE servers SET cpanel='0' where ip='@count[0]'"); $stmx->execute();}
$stmx = $dbh->prepare("UPDATE servers SET time='".time()."' where ip='@count[0]'"); $stmx->execute();
}
$dbh->disconnect;