Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


simple PHP ping script (you only need 1 web server)
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

simple PHP ping script (you only need 1 web server)

Hey,

I saw a lot of great status scripts here which show the HDD, Ram Load etc. usage but you always need a webserver on the master and remote servers. That's why I searched for a php solution where I only need 1 master server which pings my VPS and shows me if they are on or offline (it refreshs the page every 5 seconds). I'm not good at HTML/CSS/PHP so the script looks like sh*t, but maybe someone would like to make a design for the script? Anyway the script works great.

1) Download
http://www.file-upload.net/download-7872650/status.zip.html

2) Preview
http://i.imagebanana.com/img/pyf2ssjr/20130723_134037.png

3) Configuration
Just look in the file and read my comments :)

As I said, it would be really nice if somebody could make a design for it :)

Thanked by 2Nickk Spirit
«13

Comments

  • taronyutaronyu Member
    edited July 2013

    Here is my edit of your script. (took me 10 minutes so you can't call it a edit but ohh well...)

    http://pastebin.com/5nWSCZjw

    (Note: For the background I used a seperate css file, easiest way to do it for me.)

  • @trexos The site is quite slow to load. I believe that this is due to the serialization of requests and the higher socket TTL value, waiting for unresponsive servers. You could set lower value than 5 seconds, in the fsockopen function, the last value. Other way is to make 1 minute polls of the servers and generate a result that would load instantly, however it might be up to one minute stale. You don't even need php for this. Anyhow, have in mind that polling shall result in this scenario causing up to one minute stale data, and active requests shall generate bigger load.

  • trexostrexos Member

    @Janevski
    You are right, the site loads a bit slow and that's because fo the 5 seconds in the fsockopen function, but I did some tests and (for me) 5 seconds are the best value.

  • @trexos said:
    Janevski
    You are right, the site loads a bit slow and that's because fo the 5 seconds in the fsockopen function, but I did some tests and (for me) 5 seconds are the best value.

    My site isn't loading slow at all, not with 30 seconds or 5 seconds. (Or it is because it is cached)

  • trexostrexos Member

    It just loads slower if one server is offline, because then it checks 5 (or 30 seconds) if it can reach the server :)

  • You don't even need a webserver, just use uptimerobot :)

  • @Makkesk8 said:
    You don't even need a webserver, just use uptimerobot :)

    That's just silly. Why do you need to use a third party service, when you can do it on your own server.

    This is something I'm interested in. I might give it a go later.

  • SpiritSpirit Member

    @Makkesk8 said:
    You don't even need a webserver, just use uptimerobot :)

    I use it but that's 5 minute check interval.

  • nunimnunim Member

    I looked into doing something like this, it was much easier to just write a simple shell script on a cronjob that does the pinging and logging the results to be displayed. That way you can do histories and monitor any downtime not just during the time you're checking the page.

  • clone1018clone1018 Member
    edited July 2013

    I wanted to join the bandwagon so here's my rewrite:

    Code: http://paste.kde.org/pc6344ab0/

    Demo: http://tools.io/misc/status.php

    Also this could be much better, for example it'll take forever for down hosts.

  • @clone1018 said:
    I wanted to join the bandwagon so here's my rewrite:

    Code: http://paste.kde.org/pc6344ab0/

    Demo: http://tools.io/misc/status.php

    Also this could be much better, for example it'll take forever for down hosts.

    It will turn red when they are offline?

  • Yes. Added an example.

  • __> @clone1018 said:

    Yes. Added an example.

    That is pretty nice actually.

  • trexostrexos Member

    It looks really nice. Simple and beautiful! Thanks :)

  • nixcomnixcom Member

    Nice job, simple, fast... You can put that on any shared hosting account... Great script.

  • nixcomnixcom Member

    Any way to monitor a SSH port instead? Reading a little bit on php but didn't found yet...

  • trexostrexos Member
    edited July 2013

    Sure, just change the port to 22 (or your SSH port)?

  • nixcomnixcom Member

    It doesn't work, always shows as down...

  • @nixcom said:
    It doesn't work, always shows as down...

    does the same with my sip port 5060... just down all the time, port 22,80 works ok

  • nixcomnixcom Member

    It seems to show down also 5353 or 5656 for solusvm... limited to 2 numbers port only?

  • nixcomnixcom Member

    My ssh port is 4 digits so it may be why...

  • SpiritSpirit Member
    edited July 2013

    @nixcom said:
    It doesn't work, always shows as down...

    I noticed the same. I have no problem with port 80 on VPSs where I run webserver or port 22 on VPSs where I didn't change ssh port but all rest (ie. non standard ssh port) show down for me.

  • Check your ip/ports with this tool and let me know the result: http://tools.io/network/ip/port

  • nixcomnixcom Member

    tried, doesn't detect the service but shows in green :)

  • nixcomnixcom Member

    possible to fix that script easily?

  • SpiritSpirit Member
    edited July 2013

    VPS with standard webserver port 80 - monitoring work.
    VPS with standard ssh port 22 - monitoring work.
    VPS with non standard ssh port 11223 - monitoring doesn't work, show as down.

    tools.io tool recognize all those ports open (in green) but doesn't recognize ssh service at port 11223

    So every my VPS where I don't have webserver to monitor port 80 as example and I changed ssh port to something different and I specified this different port for monitoring will be shown as down.

  • nixcomnixcom Member

    @Spirit said:
    VPS with standard webserver port 80 - monitoring work.
    VPS with standard ssh port 22 - monitoring work.
    VPS with non standard ssh port 11223 - monitoring doesn't work, show as down.

    tools.io tool recognize all those ports open (in green) but doesn't recognize ssh service at port 11223

    So every my VPS where I don't have webserver to monitor port 80 as example and I changed ssh port to something different and I specified this different port for monitoring will be shown as down.

    Seems to be the same here...

  • SpiritSpirit Member
    edited July 2013

    But that's the same with original @trexos script too.

    YOUR SITE online status
    SERVER 1 LOCATION 1 Offline!
    SERVER 2 LOCATION 2 Online!

    Both servers are up, but first one use non standard ssh port.

  • trexostrexos Member
    edited July 2013

    Mhm. I have ssh ports at 160X, 1810X and 1900X and the script works too oO

  • SpiritSpirit Member
    edited July 2013

    Strange :)

    This what I quoted above was direct output paste, only input difference is ssh port
    ("IP1", 11223, $errno, $errstr, 5))
    ("IP2", 22, $errno, $errstr, 5))

Sign In or Register to comment.