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
Comments
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.
@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)
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
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.
I use it but that's 5 minute check interval.
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.
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:
That is pretty nice actually.
It looks really nice. Simple and beautiful! Thanks
Nice job, simple, fast... You can put that on any shared hosting account... Great script.
Any way to monitor a SSH port instead? Reading a little bit on php but didn't found yet...
Sure, just change the port to 22 (or your SSH port)?
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
It seems to show down also 5353 or 5656 for solusvm... limited to 2 numbers port only?
My ssh port is 4 digits so it may be why...
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
tried, doesn't detect the service but shows in green
possible to fix that script easily?
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...
But that's the same with original @trexos script too.
Both servers are up, but first one use non standard ssh port.
Mhm. I have ssh ports at 160X, 1810X and 1900X and the script works too oO
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))