Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.