Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl %config = ( # a) Server name server => 'Server', # b) Notification Email email => 'me@me.com', # c) Alert level (when system load > ?) alert => '5' ); system("cat /proc/loadavg"); while (<STDIN>) { push @loads, $_; } @loads = split(/ /); if ($loads[1] > $config{'notify'}) { # Alert !! :) print "@loads"; print "System [Alert] Current Load = $loads[1]\n\n"; ¬ify(); } else { print "System [OK] Current Load = $loads[1]\n\n"; } sub notify { $time = system("/bin/date"); open (MAIL, "|/usr/sbin/sendmail -t"); print MAIL "To: $config{'email'}"; print MAIL "From: Load Monitor"; print MAIL "Subject: ALERT High Load"; print MAIL "Server Alert (Server Name $config{'server' +})"; print MAIL "Time: $time"; print MAIL "$config{'server'} has exceeded the load al +ert of $config{'alert'}"; close(MAIL); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Load Monitor
by monkfish (Pilgrim) on Nov 02, 2001 at 21:03 UTC | |
|
Re: Load Monitor
by arhuman (Vicar) on Nov 02, 2001 at 20:59 UTC | |
|
Re: Load Monitor
by perrin (Chancellor) on Nov 02, 2001 at 20:54 UTC | |
|
Re: Load Monitor
by tfrayner (Curate) on Nov 02, 2001 at 20:57 UTC | |
|
Re: Load Monitor
by blackmateria (Chaplain) on Nov 02, 2001 at 21:02 UTC |