Watty wrote:
>> We know because the IP check run every 5 minutes by >> cron, and if it has no run within 5:01 minutes then >> the computer is off, or the script isn't working. >> But we should assume that the computer is off is there >> is not a record for that 5 minute slot. Alternatively >> we could write another line into the log when the >> computer shuts down. >
Basically how this is going to work:
1. Read first two lines, $line[1], $line[2], using fgets() 2. Use strtotime() to convert timestamps and subtract to determine the elapsed time between them 3. Add difference to either $U_time or $S_time based upon status (S or U) in $line[1] 4. Set $line[1] = $line[2] 5. Read next line of file into $line[2] 6. GOTO #2
Then you'll have total $U_time and total $S_time and you can calculate your percentages from there.
So, according to what you said, when you calculate the difference in Step 2 above, you could put a maximum of five minutes, right? If the difference between two lines is over 5 minutes, you can assume it was on for the first 5 and off for the rest.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php