forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Fri Nov 17, 2017 9:00 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Server issue detection
PostPosted: Tue May 29, 2012 1:51 am 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
This code snippet can help make your server able to report when it's having issues in a way which can be detected by an external script:

Code:
        public static function customFooter()
        {
                global $Misc;

                if( isset($_GET) && isset($_GET['pingability']) ) {
                        // Generate a status code for pingability.com
                        $status = "pSxqXCuhhq (normal)";
                        if( defined('ERROR') )
                                $status = "42cqO55jiA (error)";
                        if( !isset($Misc) )
                                $status = "I489TWdvz2 (misc environment)";
                        else
                        {
                                if ( $Misc->Maintenance )
                                        $status = "7BYDynhGpx (maintenance)";
                                if ( $Misc->Panic )
                                        $status = "a/j7BwXSKk (panic)";
                                if ( ( time() - $Misc->LastProcessTime ) > Config::$downtimeTriggerMinutes*60 )
                                        $status = "J9RhUjPGOS (downtime)";
                        }

                        if( (disk_free_space('/var')/disk_total_space('/var') < 0.1)
                        || (disk_free_space('/tmp')/disk_total_space('/tmp') < 0.1)
                        || (disk_free_space('/usr')/disk_total_space('/usr') < 0.1)
                        || (disk_free_space('/home')/disk_total_space('/home') < 0.1)
                        || (disk_free_space('/')/disk_total_space('/') < 0.1) )
                                $status = "uhN5ClX8/a (diskspace)";

                        $buf .= '<p style="font-size:6pt">Status code: '.$status.'</p>';
                }

                return $buf;
        }


Just add that to your config.php::customFooter(), and you'll be able to set up a service like pingability.com, or your own script, to check http://yourserver.com/?pingability=on for the right status code "pSxqXCuhhq"

You may have to tweak the free-space detection, if you're on Windows or have an unusual partition layout


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group