Date: Fri, 13 Jul 2001 14:57:29 -0400 From: Daniel Frazier <dfrazier@magpage.com> To: Joe Clarke <marcus@marcuscom.com> Cc: Graham White <graham@bravenet.com>, FreeBSD-questions <FreeBSD-questions@FreeBSD.ORG> Subject: Re: Newbie Bash-question Message-ID: <3B4F4499.1020100@magpage.com> References: <20010713144955.P25152-100000@shumai.marcuscom.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Joe Clarke wrote:
> [ expects an integer for both arg 1 and arg 2. .30 is not an integer.
>
> if [ $LOAD -qt 1 ]; then
>
> should work for you. IF you need more granularity, you can use Perl.
>
here's the perl code we use to do this...
#!/usr/bin/perl
$max_load = 3;
$hostname = `uname -n`;
chomp $hostname;
open (IN, "uptime|");
$line = <IN>; $line =~ /load average: (.*)/; $load_avg = $1;
($l1, $l2, $l3) = split (/\, /, $load_avg);
$load = int($l1);
if ($load >= $max_load) {
open (SENDMAIL, "|/usr/lib/sendmail -t");
print SENDMAIL <<EOF;
To: sysadmin\@magpage.com
Subject: Excessive Load Average !
WARNING!
The load on $hostname is currently at $l1, which is beyond its threshold
of $max_load.00. Please investigate this situation.
EOF
close (SENDMAIL);
}
close (IN);
exit 0;
--
----------------------------------------------------------------------
Daniel Frazier <dfrazier@magpage.com> Tel: 302-239-5900 Ext. 231
Systems Administrator Fax: 302-239-3909
MAGPAGE, We Power the Internet WWW: http://www.magpage.com/
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
- Benjamin Franklin, Historical Review of Pennsylvania, 1759.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B4F4499.1020100>
