Jump to content

Amount % online


mikelmao

Recommended Posts

Assuming you have some sort of historical uptime data stored somewhere ...

 

The basic process is just some simple math.

 

Lets say your script shows up-time percentages for the 30 day periods at a time. First calculate the seconds in the month the you are viewing (assume a 30 day month which is 2,592,000 seconds). This will be the benchmark.

 

Now the historical data is where it can be tricky, depending on the sort of data that it is.  Often times what you want to do is have the function that checks the server take the timesptamp from the last good check and subtract it from the timestamp of the present good check. This will give you the distance in seconds between the last and current good check.  Then you will want to continually add that distance to the next 'distance calculation' that is made at the next check interval.

 

So basically, your historical data should be a running tally of seconds that the server has been up.  Now how accurate that number is depends on how often you checking function is running.  The greater the interval the less accurate the number may be.  For example, I may have a good check at 5:00pm and the next check is at 5:10pm ... well the server could have been down for 3 minutes in between checks but as long as both checks are good then it will appear that the server never went down in that 10 minute span.

 

So anyway, the math!  What percent of 'benchmark seconds' is 'historical data seconds'.  Simple enough eh?

Link to comment
https://forums.phpfreaks.com/topic/165986-amount-online/#findComment-875502
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.