Jump to content

My first PHP project almost done!


z3rongod

Recommended Posts

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

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.

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.