[Gllug] Simple Bash Script

- Tethys tethys at gmail.com
Tue Jun 3 12:00:00 UTC 2008


On Tue, Jun 3, 2008 at 12:43 PM, Martin A. Brooks
<martin at hinterlands.org> wrote:

> There sheer length of this thread reminds me of why I never write shell
> scripts, "simple" or otherwise.

Ahhhh.... this is better. You've once more started writing things with
which I can disagree :-)

> Here's a "simple" crude perl script that does what the OP wants.
>
> http://www.antibodymx.net/loadchecker.pl.txt

I'm not quite sure of the point you're making (I'll leave aside the
fact that's it doesn't quite do what the OP wanted). To me, that looks
no better than the equivalent shell script. Indeed, I'd say the shell
script is both shorter and cleaner:

	#!/bin/sh

	loadavg=$(sed 's/\.\(..\).*/\1/' /proc/loadavg)
	notify=600
	mail=/usr/bin/mail
	mailto="someone at example.com"
	host=$(hostname)
	rcluster=$(/usr/local/bin/in-cluster no)
	msg="$host removed from cluster. Load $loadavg is greater than $notify"

	if [ $loadavg -gt $notify ]
	then
		$rcluster
		echo "$msg" | "$mail" "$mailto"
	fi

Again, adjust variables to taste.

Tet

-- 
Perl is like vise grips. You can do anything with it but it is the
wrong tool for every job. -- Bruce Eckel
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list