#!/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 () { 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 alert of $config{'alert'}"; close(MAIL); }