z3rongod Posted September 14, 2009 Share Posted September 14, 2009 Hello PHP freaks! I've finished yesterday a script that checks an IP on multiple ports (ranging from 27015-27115) if there are servers online. When they are online the script inserts a new row in the table. The table has the following columns: id name (server name) 27015 (can be 1 or 0, depending on if it's online or not) 27016 .... 27115 rednr (number of servers online) time (UNIX time inserted by the script when it started running) Note: If wondering why i've added the status on each port and not just use `rednr` it's because maybe i'll want to make a more detailed report on each port later This script runs every 5 minutes. Remember the script runs only if at least 5 servers are online, therefor information is stored only if more than 5 servers are online. My problem: I now want to make a daily and detailed report of those servers. So i thought to echo the first timestamp as "START: " and make a for loop to check when there's a bigger difference than let's say 1200 seconds between timestamps to echo "STOP: " Another thing i want to add is an average of the nr of ports used in that interval (the `rednr` value on each row) Also i would want to make these as a daily report. A practical example of how it should look at the finish: 13/09 1:20 AM - 4:10 AM => ~ 35 servers 5:20 AM - 8:00 PM => ~ 32 servers 9:30 PM - 14/09 => ~30 servers 14/09 13/09 - 5:00 PM => ~29 servers 9:00 PM - 15/09 => ~60 servers 15/09 14/09 - 16/09 =>~55 servers 16/09 15/09 - 3:00PM => 55 servers I think you get the idea now. Here is the php script (which is a function tbh) for writing the data: http://www.copypastecode.com/10765/ Here is the script i made (which is not working obviously) to print out the report: http://www.copypastecode.com/10769/ Here is (part of) the array containing the timestamps if required: http://www.copypastecode.com/10773/ Any further info needed please ask, I'll respond promptly, as i'm refreshing this page in hopes for an answer Yours thankfully, Sergiu. Link to comment https://forums.phpfreaks.com/topic/174210-my-first-php-project-almost-done/ Share on other sites More sharing options...
Zane Posted September 14, 2009 Share Posted September 14, 2009 So what's your problem exactly..? That you want to make a detailed report. Link to comment https://forums.phpfreaks.com/topic/174210-my-first-php-project-almost-done/#findComment-918424 Share on other sites More sharing options...
z3rongod Posted September 14, 2009 Author Share Posted September 14, 2009 I don't know how to make a detailed report as the example above. Link to comment https://forums.phpfreaks.com/topic/174210-my-first-php-project-almost-done/#findComment-918431 Share on other sites More sharing options...
z3rongod Posted September 15, 2009 Author Share Posted September 15, 2009 Can someone please help me? I still can't figure it out... Link to comment https://forums.phpfreaks.com/topic/174210-my-first-php-project-almost-done/#findComment-918613 Share on other sites More sharing options...
YourNameHere Posted September 15, 2009 Share Posted September 15, 2009 You can use cron jobs to fire the script at a certain interval. then you can save all the information from how many servers to the timestamp into a reports table. (You may have to do a few tables) and then echo all the info out onto a page and the report is printable then. Link to comment https://forums.phpfreaks.com/topic/174210-my-first-php-project-almost-done/#findComment-918620 Share on other sites More sharing options...
z3rongod Posted September 15, 2009 Author Share Posted September 15, 2009 ... Have you read my post? I did the script and it's on a cron job already. Only thing i need now is to make the script to print out the detailed report. And I still can't figure it out how... Link to comment https://forums.phpfreaks.com/topic/174210-my-first-php-project-almost-done/#findComment-918747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.