mikelmao Posted July 14, 2009 Share Posted July 14, 2009 Hello, Im making a status checker to see if a webserver is online. im using: @fsockopen($l['ip'],80,$errorNumber,$errorMessage,1); but how can i check how much % it has been up since started checking? plz help thx! Link to comment https://forums.phpfreaks.com/topic/165986-amount-online/ Share on other sites More sharing options...
pquery Posted July 15, 2009 Share Posted July 15, 2009 you might want to read on the nagios plugin forums and see how some of them are doing it. Although they usually write their pulgins in PERL, you might be able to see the methods on what they're using to check and calculate Link to comment https://forums.phpfreaks.com/topic/165986-amount-online/#findComment-875490 Share on other sites More sharing options...
phporcaffeine Posted July 15, 2009 Share Posted July 15, 2009 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 More sharing options...
mikelmao Posted July 15, 2009 Author Share Posted July 15, 2009 but how do i make it check automaticly if the web is still online? Link to comment https://forums.phpfreaks.com/topic/165986-amount-online/#findComment-875788 Share on other sites More sharing options...
shergold Posted July 15, 2009 Share Posted July 15, 2009 using a cron job. Link to comment https://forums.phpfreaks.com/topic/165986-amount-online/#findComment-875792 Share on other sites More sharing options...
mikelmao Posted July 15, 2009 Author Share Posted July 15, 2009 never worked with cron jobs. Any examples? Link to comment https://forums.phpfreaks.com/topic/165986-amount-online/#findComment-876119 Share on other sites More sharing options...
seventheyejosh Posted July 15, 2009 Share Posted July 15, 2009 all it is is a php script that runs according to the server. Just log into your cpanel, and there is a tab called cron jobs where you set the file path, and the increment at which to run it. Link to comment https://forums.phpfreaks.com/topic/165986-amount-online/#findComment-876122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.