[PHP]Server Status

This is guide mostly for website tools and code, for example CMS or registration scripts.
There can also be tools.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Re: [PHP]Server Status

Postby lmame on Fri Oct 05, 2007 9:31 am

Ok :D it's not really complicated indeed ;)
Though some prefer to use a Cron system to ping their servers every now and then (like every minute) and so the php file only fetchs the result. It avoids a lot of socket "requests" on the server and the answer of the php query is immediate so it does not slow down your website display.
Downside is that you have the servers state from one minute ago, a pro is that with this you can have your website on a server and your osRose servers on another (the other way too in fact :lol:).
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [PHP]Server Status

Postby Souleater on Fri Oct 05, 2007 2:51 pm

You can't go lower than 1 second.


The timeout val in fsockopen is a float, so you can go lower than 1 second ;)

Good script, It works cause it knows that it actually works :roll: :roll: ( 127.0.0.1:80 xD )
Image
Souleater
Antares
Antares
 
Posts: 355
Joined: Thu Aug 09, 2007 10:59 pm

Re: [PHP]Server Status

Postby Flik on Fri Oct 05, 2007 2:57 pm

if you need a personal image for online/offline status post in this topic. ;)
User avatar
Flik
Smoulie
Smoulie
 
Posts: 49
Joined: Mon Sep 10, 2007 5:05 pm

Re: [PHP]Server Status

Postby Flik on Fri Oct 05, 2007 3:51 pm

port bug fixed and 3 new style added.
User avatar
Flik
Smoulie
Smoulie
 
Posts: 49
Joined: Mon Sep 10, 2007 5:05 pm

Re: [PHP]Server Status

Postby Rifke on Fri Oct 05, 2007 5:44 pm

Not that it would be bad? It is cool when you have up to date server information, but some data like your server, doesn't require a check every page view. One every 5 minutes is good enough. And mostly when the server 'hangs' the checking of the server doesn't work. Because the script 'sees' the sever running, and it assumes it is working so it shows ONLINE, but in fact it is down only the Task End windows blocks the restarter from restarting again.

lmame wrote:Ok :D it's not really complicated indeed ;)
Though some prefer to use a Cron system to ping their servers every now and then (like every minute) and so the php file only fetchs the result. It avoids a lot of socket "requests" on the server and the answer of the php query is immediate so it does not slow down your website display.
Downside is that you have the servers state from one minute ago, a pro is that with this you can have your website on a server and your osRose servers on another (the other way too in fact :lol:).
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: [PHP]Server Status

Postby lmame on Fri Oct 05, 2007 6:01 pm

Rifke wrote:Not that it would be bad? It is cool when you have up to date server information, but some data like your server, doesn't require a check every page view. One every 5 minutes is good enough. And mostly when the server 'hangs' the checking of the server doesn't work. Because the script 'sees' the sever running, and it assumes it is working so it shows ONLINE, but in fact it is down only the Task End windows blocks the restarter from restarting again.

lmame wrote:Ok :D it's not really complicated indeed ;)
Though some prefer to use a Cron system to ping their servers every now and then (like every minute) and so the php file only fetchs the result. It avoids a lot of socket "requests" on the server and the answer of the php query is immediate so it does not slow down your website display.
Downside is that you have the servers state from one minute ago, a pro is that with this you can have your website on a server and your osRose servers on another (the other way too in fact :lol:).


Yes and no I guess both methods has pors and cons.
For my server I made a program under Windows that does several checks and generate several PHP files and accesed with Curl from other scripts files :)
It sends also automatically by email stats and alarms.
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [PHP]Server Status

Postby Souleater on Sat Oct 06, 2007 12:30 am

lmame wrote:For my server I made a program under Windows that does several checks and generate several PHP files and accesed with Curl from other scripts files :)
It sends also automatically by email stats and alarms.


Dude that's some hardcore coding for a simple status checker xD

I knocked up a little script for those who're interested in knowing how it works using GD :roll:

  1. <?php
  2. $host = false;
  3. $timeout = 1;
  4.  
  5. if ( isset($_GET["link"]) && isset($_GET["port"]))
  6. {
  7.     extract($_GET);
  8.     $arr = explode('.', $link);
  9.     if ( count($arr) != 4 && !is_numeric($arr[0]) )
  10.         $host = true;
  11.    
  12.     if ( $host )
  13.         $ip = gethostbyname($link);
  14.     else
  15.         $ip = $_GET["link"];
  16.        
  17.     header('Content-Type: image/png');
  18.     $im = imagecreate(50, 15);
  19.     imagecolorallocate($im, 255, 255, 255);
  20.     $green = imagecolorallocate($im, 100, 200, 100);
  21.     $red = imagecolorallocate($im, 255, 0, 0);
  22.    
  23.     if ( ( $sock = @fsockopen($ip, $port, $errno, $errstr, $timeout) ) !== FALSE )
  24.         imagestring($im, 3, 0, 0, "Online", $green);
  25.     else
  26.         imagestring($im, 3, 0, 0, "Offline", $red);
  27.        
  28.     imagepng($im);
  29.     imagedestroy($im);
  30. }
  31. else
  32. {
  33.     die("piss off");
  34. }
  35. ?>


Kept it simple though 'cause I gotta run now, tomorrow's gonna be a tough day :roll:
Image
Souleater
Antares
Antares
 
Posts: 355
Joined: Thu Aug 09, 2007 10:59 pm

Re: [PHP]Server Status

Postby Rifke on Sat Oct 06, 2007 1:11 am

Don't forget to mention that the users who are going to use that script need the gdb library installed.
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: [PHP]Server Status

Postby lmame on Sat Oct 06, 2007 2:50 am

In fact it's my job, I made a lot of those bots or client / servers so it was pretty fast to do this one and I had my reasons, mostly I didn't want to check on servers, this thing does it for me, it handles stuff like exceptions errors, ms c++ dll warning (exceptions and so on), make some hacks checks / repairs and so on :)

the only thing I didn't do on this one is text messaging :lol: I could as I already wrote some but I thought it would be a bit too much :)
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [PHP]Server Status

Postby Erwt on Mon Oct 15, 2007 1:01 am

I got attracted by the name of the topic.

Maybe you could make a SIMPLE one so we can implement in our own website and we know how to make it then, that would be nice.

And about the 1 sec request.. If it is a home-hosted server and he has to wait more then 1 second because (bad pc, bad host internet, too many users) etc etc.. then you get wrong answer? :)
Erwt
Little soul
Little soul
 
Posts: 3
Joined: Sun Oct 14, 2007 9:31 pm

PreviousNext

Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 5 guests