Forum Moderators: phranque

Message Too Old, No Replies

DIY Server monitoring

How to roll your own server monitoring script

         

Trav

10:47 pm on Dec 10, 2009 (gmt 0)

10+ Year Member



Howdy gang,

I tried searching this, but so far haven't found anything that is reasonably straight-forward.

I have two servers. I'd like to set up one with a chron job, using wget to monitor the production box, and shoot out an email if/when it goes down.

I need to know:

1. exactly how to install wget
2. how to set up a chron job to access the php page request/parsing script
3. what the general code is for requesting a page and parsing it for certain text
4. how to send an email if the text in question doesn't appear

I can slog my way thru items 3 and 4, but I'm having a heck of time with the other two, particularly just getting wget installed. Anyone know of some good comprehensive tutorials?

Or, maybe I'm doing this the wrong way. Got an alternate idea?

Many thanks!

Trav

jdMorgan

2:39 pm on Dec 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your questions are a bit beyond the 'scale' of what can be easily answered in a forum venue. But a "poor man's version" of this -- and one that would give you time to research and write the scripts, would be to sign up for one of the many free server-monitoring services. These do essentially what you're asking about, and the only down-side is the marketing e-mails you'll receive, promoting "monitoring upgrades" and/or related services.

Jim

Trav

4:23 pm on Dec 11, 2009 (gmt 0)

10+ Year Member



Right on, Thanks Jim. I actually have set a couple of the 'off-the-shelf' services to see how well they work, and to give me some time for research as you suggest.

Would this even be the right forum to ask about installing wget, or is that more appropriate elsewhere?

jdMorgan

9:48 pm on Dec 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If this was my project, I'd go straight to the source [gnu.org] for info.

Jim

Trav

12:39 am on Mar 4, 2010 (gmt 0)

10+ Year Member



Just in case anyone else is wondering about this and finds this post, there is a relatively simple script that does this pretty nicely. It's written in PHP, and makes use of CURL and Cron jobs to accomplish the monitoring. I currently have the script fire an email to my Gmail account, which (via a filter) then forwards an SMS to my cel phone. Given the info above, one should be able to find the actual article fairly easily. I bet there's several very similar scripts for this out there on the wild web.

Since I got that part figured out, I thought I'd see if I can make it dump a bit of data into a DB, so I can run a report later on uptime. I guess I just like reinventing the wheel : )