Uptime-checker-script
My ISP is telling me that my Internet connection is ok. They came out a couple times and "checked things out" and everything was "OK." So I decided to write a script that tries to connect every 15 minutes and record success if connected - and I'll have this handy next time I talked to their support. I haven't found a good solution so I wrote a crappy script myself.
This is my crappy script that I upload to the server on my shared hosting account:
$link = mysql_connect($your_mysql_server, $your_mysql_user, $your_mysql_password);
mysql_select_db($your_mysql_database);
$domain = gethostbyname($_SERVER['REMOTE_ADDR']);
$query="INSERT INTO uptime (timestamp,ip) VALUES (NOW(),'$domain')";
$result = mysql_query($query);
mysql_close($link);
This is my table structure (on the server at my shared hosting account):
CREATE TABLE IF NOT EXISTS `uptime` (
`pkid` int(11) NOT NULL auto_increment,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
`ip` varchar(15) NOT NULL,
PRIMARY KEY (`pkid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
This is in my crontab on my home computer (hits the script every 15 mins):
*/15 * * * * wget http://example.com/path-to-my-script
Leave a Comment