JayBee has asked for the wisdom of the Perl Monks concerning the following question:
I was interested in making a program in perl (if possible) that checks the status of my server(s) and emails if a function fails. I know I may be able to do this if my computer was on and connected 24/7, but is it possible for perl to do this after I run it once and close my browser? I havn't had any experience with the wait(); function or probably many others I havn't heard about yet, but could it, or something else, be capable to do such a task on it's own.
I know about some of the other companies who can do this for me for a small fee, but why pay if we can do it ourself for fractions of the cost...
Thank you for your inputs, opinions, suggestions, and the slap of common sense to wake me up... JayBee 20040210 Edit by BazB: Changed title from 'Self-maintained script?'
Re: Monitoring system availability?
by Roger (Parson) on Feb 10, 2004 at 11:07 UTC
|
The Big Brother is watching... Better use a proven product. Unless you want to do it yourself while learning perl. Otherwise it's too much hassle to get things right.
| [reply] |
Re: Monitoring system availability?
by Tomte (Priest) on Feb 10, 2004 at 11:14 UTC
|
| [reply] |
|
I second the vote for Nagios, it's really a great piece of open source software. We love it up at school, and I've heard rumors of a few local communication companies using it as well.
:)
| [reply] |
Re: Monitoring system availability?
by allolex (Curate) on Feb 10, 2004 at 11:02 UTC
|
You'll need to run your script via a scheduler like cron (a UNIX daemon, but available for Windows, which has its own scheduler called "Task Scheduler", IIRC), or set up your program as a service (in Windows) or a daemon (*nix). If you choose to do the latter, have a look at the thread "Install a perl script as a Win NT/2000/XP service.". I would strongly recommend you set up your script using the scheduler.
| [reply] |
Re: Monitoring system availability?
by Abigail-II (Bishop) on Feb 10, 2004 at 11:47 UTC
|
Been there, done that. First of all, if your computer isn't
connected 24/7, what's the point of sending email? You first
have to determine why you are monitoring, and what you want
to do if something fails, before deciding what you are going
to use to monitor. Are you monitoring a mission critical
application? Do you (or someone else) have to perform a manual
intervention if a service is unreachable? Are you just monitoring to get an indication of your weekly uptimes?
I've monitored services in several previous gigs. That included using off-the-self products like mon, big brother,
and mrtg, and products written from scratch, which either
ran 24/7 or ran from cron. Sometimes the monitor ran on
the same box that performed the service - and sometimes the
monitor was a spin in a web, monitoring services of a range
of machines. Sometimes, all they did was producing graphs,
some products send out messages to pagers and phones, some
tools tried to fix problems instead of reporting them, and
sometimes they did all three. And I've written monitors to
monitor my monitors.
I've written scripts as simple as:
#!/bin/sh
if ping -c 1 'xxx.xxx.xxx.xxx'
then :
else /etc/init.d/network restart
echo "Restarted the network"
fi
and programs with thousands of lines monitoring dozens of
functions of tens of database servers, with cascading alerts.
Abigail | [reply] [d/l] |
Re: Monitoring system availability?
by flyingmoose (Priest) on Feb 10, 2004 at 15:18 UTC
|
About four years ago while at a certain acronymed telephone company, we implemented a system from scratch using a mixture of Sybase, Perl, and a Servlet front end. At the time, I thought it was really cool. Then I realized how many products were out there that did this better.
The awkwardness of collating all of this data, constructing packets, and writing a daemon to collect these packets led to some complexity that could be avoided by using more mature products.
However, it did have some good things going for it. It used one-way communication using UDP from the monitored servers back to the "reporting" server. No TCP, No database connections, from the production servers to the monitoring station. Perhaps it was limited in functionality, but it was stable and used very low resources.
If I had to reimplement a system from scratch again, I'd probably still use a UDP-like system, but would consider serializing data (YAML possibly) and putting the monitoring process on a crontab rather than running it as a daemon.
Anyhow, long story short, it was a pretty successful project, but we reinvented a lot of wheels and it wasn't the most extensible system when we got through with it. Picking up an off-the-shelf product would have probably been a better idea. At the time, though, I doubt many (free) solutions were ready for prime-time, especially on the obscure platforms we supported.
| [reply] |
Re: Monitoring system availability?
by dthacker (Deacon) on Feb 11, 2004 at 01:12 UTC
|
I've been using Big Brother for years. I like it a lot, and my department has even written some custom modules to send data and trigger alarms. The licensing has changed, and we're now pondering Nagios. If you're looking for a perl solution, you may want to check out Spong
| [reply] |
Re: Monitoring system availability?
by z3d (Scribe) on Feb 11, 2004 at 12:40 UTC
|
Different take on what you are asking (maybe even on topic ;) ) - perldoc -f fork may be a good start. If I am understanding you correctly, you are asking to be able to kick off a process remotely (via the web in your example) and have it continue to run after you close your browser, shutdown your local desktop (not where the program actually resides), etc. If this is a correct understanding, I'd suggest looking into fork() for seperating the monitor code from the call to kick it off. You may want to consider some of the IO::Net modules (or related variants, of course) for being able to connect to the monitor output, as well as performing some of the network related tasks. Is this what you intended? Or am I being both off topic and naive here? (Yes, I've used both Big Brother and Nagios, nice, blah, etc., andmuch quicker than writing your own - but there's always a value in doing it yourself if you have the time).
"I have never written bad code. There are merely unanticipated features."
| [reply] |
|
|