#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    85
    Rep Power
    2

    [PHP DEV.] Server Status Monitor


    Hello! Thanks for checking in on my post.

    I am wanting to make a service checker that checks to see if services are up periodically and then put the data into a database. I think it would be best to use some type of Cron Job. (Something like this is what I'm talking about: So here is something I am not sure about, https://teamexon [DOT] eu/stav-sluzieb.html).

    So how would I have the script that displays the data get a date, tell if it is on or off, and then Get the most recent data?

    Thanks,
    TJ
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    This sounds like a 2 part question. The first part is to write a shell or perl script (possible with PHP but I wouldn't do it) to do the checking and maintain the database. The 2nd part, in PHP, would read the data from the database and display it appropriately. Depending on how often you run the first script, I would not think checking the status in the PHP script would be necessary. The database will always be up to date if you run the first script frequently enough.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    85
    Rep Power
    2
    Originally Posted by gw1500se
    This sounds like a 2 part question. The first part is to write a shell or perl script (possible with PHP but I wouldn't do it) to do the checking and maintain the database. The 2nd part, in PHP, would read the data from the database and display it appropriately. Depending on how often you run the first script, I would not think checking the status in the PHP script would be necessary. The database will always be up to date if you run the first script frequently enough.
    Okay. Heres the deal, I am only some what good with PHP and dont know shell or perl.

    How would I tell it to receive the last three days to display on the site? And also in the main script, how could I also tell it to put a date in the database.

    Another question, how could when the status are okay, how could it put a "1" for okay in the database, and then when the script displays the data on the page "1" = an image?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    Originally Posted by tjswebdev
    Okay. Heres the deal, I am only some what good with PHP and dont know shell or perl.
    Sounds like a good opportunity to learn, especially if you are going to be using cron.
    Originally Posted by tjswebdev
    How would I tell it to receive the last three days to display on the site?
    Structure your query to do that. You need to design your database schema before you do any programming.
    Originally Posted by tjswebdev
    And also in the main script, how could I also tell it to put a date in the database.
    They same way you do any other field. All databases have date field definitions.
    Originally Posted by tjswebdev
    Another question, how could when the status are okay, how could it put a "1" for okay in the database, and then when the script displays the data on the page "1" = an image?
    All databases also have boolean field definitions. How you display that on your page is a matter of personal preference. You could use an image or simply the words 'up' and 'down'. Perhaps in green and red respectively.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    85
    Rep Power
    2
    Originally Posted by gw1500se
    Sounds like a good opportunity to learn, especially if you are going to be using cron.

    Structure your query to do that. You need to design your database schema before you do any programming.

    They same way you do any other field. All databases have date field definitions.

    All databases also have boolean field definitions. How you display that on your page is a matter of personal preference. You could use an image or simply the words 'up' and 'down'. Perhaps in green and red respectively.
    Okay, sorry for delay.

    How often should I have the service checking? 1, 5, 10, 20 times a day?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    That is entirely up to you. I have no idea what your users are expecting or what the purpose is with respect to history.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    85
    Rep Power
    2
    Originally Posted by gw1500se
    That is entirely up to you. I have no idea what your users are expecting or what the purpose is with respect to history.
    True. Heres a question. If I have it update once every 30 minutes, can it delete the previous check from earlier in the day?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,350
    Rep Power
    594
    Yes. You can pretty much delete/add/update anything you want, any time you want.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo