I’m creating an game server list, and I want to measure uptime for certain server (to be specific, uptime should be displayed in percents).
I have configured a cronjob for my script, which is checking every 5 minutes if server is up or down, so I can easly get the server status.
I need an idea on how can I measure each server uptime basing on the above data. I’d have to save down and up time for each server every one minute the script is executing?
If you don’t care about many details and you just want the up and down time. Then you could save 2 numbers in a file, one being the current percentage and the other being the current number of measures the script took.
For example: ’96 800′.
Then, whenever the script is executed, use this formula, assuming that the percentage (96) is X, the number of saves is Y (800) and the current measure is Z (0 or 1)
That’s of course just pseudo code and won’t work straight away, it’s just to give you an idea of one way to do it. You must also include a way of reading a file and saving it wherever you want of your page that contains those 2 numbers.
As Jamie stated, this is assuming that crontime is still working despite of the server is down.
PS, you could also add a system from other server to check this server uptime, but it would need to be statistically calculated (and error tends to 0 when many other servers are added, but that’d be too difficult) as you’d need to take into account the other server’s uptime also…