Page 1 of 2

Springinfo spring server status monitoring

Posted: 09 Mar 2009, 03:42
by Forboding Angel
This is kinda unrelated to anything, but it should prove somewhat handy.

I've just added server status checking to springinfo so that when you go there, it will tell you if the master server and backup servers are up.

Nifty neato stuff.

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 04:17
by MidKnight
yay! :-)

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 10:18
by Caradhras
nice

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 17:24
by aegis
what method do you use for checking if it's online?

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 19:37
by Forboding Angel
Only checking port 8200

Here is the script if anyone else wants to use it. I didn't write it myself even thought I started to at first, but realized it was going to take a lot longer than just finding someone who had already done it.

Code: Select all

<div class="serverstatus"></div>
<?php
/////////////////////////////////////////////////////
// Server Monitor v1.0 - sebflipper Copyright 2004 //
//         http://www.sebflipper.com               //
//                                                 //
//      This is a simple script to monitor a       //
//      list of ports from a list of domains       //
                                                   //
//     Don't forget to download green.gif and      //
//        red.gif for the status icons             //
/////////////////////////////////////////////////////

// Config Area
// Enter a list of domain names you want to monitor
$domains = array("taspringmaster.clan-sy.com", "springbackup1.servegame.com", "springbackup2.servegame.org");
// Enter a list of ports you wish to monitor (80 = HTTP, 21 = FTP, 25 = SMTP, 3306 = MySQL)
$ports = array("8200");

// How often the page should refresh
$page_refresh = "3600"; // in seconds

?>
<?php
// PHP Script
// Turn off all error reporting
// Removes errors like fsockopen failed if the script couldn't connect to the port
error_reporting(0);

// Main moniting function
function server_monitor($domain,$port) {
    $fp = fsockopen ($domain, $port, $errno, $errstr, 10);
    if (!$fp) {
        return "<img src=images/red.gif alt='Status: Down, Domain: $domain, Port: $port'>\n";
    } else {
        return "<img src=images/green.gif alt='Status: Up, Domain: $domain, Port: $port'>\n";
    }
    fclose($fp);
}

// Foreach array
foreach ($domains as $domain_value) {
    echo "<div class='singleinfo'><center>&nbsp;<b>$domain_value: </b> ";
    foreach ($ports as $port_value) {
   }
    foreach ($ports as $port_value) {
        echo "&nbsp;&nbsp;". server_monitor($domain_value,$port_value) . "\n</center>";
   }
   echo "</div>";
}

?>
There is the script if anyone else would like to use it. It's pretty nifty.

Here are the icons:
Image
Image

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 21:14
by Masure
Good idea forb !

I'd suggest you to cache the monitoring result so each page rendered doesn't fsock lobby servers. What do you think about this ?

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 21:37
by Peet
Yeah that's probably a good idea. Does dreamhost let you set up cronjobs for every 5-10 mins?

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 22:04
by Masure
No need to cron, a mysql table :

Code: Select all

PK serverurl varchar
checked_at timestamp
up boolean
server_monitor function tweaking to fsock only if the timestamp exceed x minutes otherwise you read the "up" value, and you're done.

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 22:58
by lurker
Peet wrote:Yeah that's probably a good idea. Does dreamhost let you set up cronjobs for every 5-10 mins?
You forget that I run my lobby bot off of the dreamhost server?

Re: Springinfo spring server status monitoring

Posted: 09 Mar 2009, 23:05
by Forboding Angel
Well basically this is how it works. WP caches the main page every 15 minutes. So every 15 minutes the servers get a ping, however, if 1 person hits the refresh button on their browser, WP re-Caches the page.

A lil confusing but that's kinda a halfway decent way of explaining it.

As far as linking it to a db... Why? Doesn't make any sense to me. WOuldn't it be better to have the actual servers track their uptime and whatnot?

Also keep in mind, I don't have access to the lobby servers, so everything I do has to be done via pings and things like that. I suppose I could set it up to track it, but I don't really feel like coding it :-/

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 02:45
by MidKnight
Masure wrote:Good idea forb !
Peet wrote:Yeah that's probably a good idea.
err, it kinda was my idea :-)

but ideas are cheap as dirt, implementation is what counts!

so...
Masure wrote:Nice work forb !
Peet wrote:Yeah that's good implementation.
fixed :wink:

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 03:04
by Forboding Angel
Masure wrote:Good idea forb !

I'd suggest you to cache the monitoring result so each page rendered doesn't fsock lobby servers. What do you think about this ?
It is cached, the cache updates every 15 minutes, and technically it only gets pinged once because of the way the caching works. Ping is only sent once every 15 minutes when the frontpage of the site is accessed.

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 05:46
by aragon
some uptime charts would be nice

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 05:51
by Peet
Someone (bibim?) has a huge stat system that has that already

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 05:53
by Forboding Angel
Oh thank god lol. I didn't want to have to be responsible for it hehe.

Do you happen to have a link peet? If so, I'll link to it from springinfo under the status thingy

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 05:58
by Peet
Hmm...after searching a bit it looks like he took it down (or at least the link to it). PM him I guess.

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 06:28
by lurker

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 12:04
by NOiZE
perhaps it could show the number of players online/number of games being played. So ppl can see its an active community.

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 14:39
by AF
lurker wrote:
Peet wrote:Yeah that's probably a good idea. Does dreamhost let you set up cronjobs for every 5-10 mins?
You forget that I run my lobby bot off of the dreamhost server?
How and what language?

Re: Springinfo spring server status monitoring

Posted: 10 Mar 2009, 16:25
by lurker
Python. I just run it under screen; as long as you don't use a lot of ram or open up a socket for receiving you're fine. Actually, scratch that, I believe you can open a socket for receiving as long as nothing connects to it, but I'm not sure.