Date: Wed, 08 Aug 2001 08:53:21 +0200 From: "F. Xavier Noria" <fxn@retemail.es> To: freebsd-questions@FreeBSD.ORG Subject: Re: Perl Script Message-ID: <3B70E1E1.C90E7132@retemail.es> References: <001301c11fbc$69475600$4fcc4518@Gray1>
next in thread | previous in thread | raw e-mail | index | archive | help
: Does anyone have an example of a Perl script that constantly loops
: and checks the loadaverage of a machine, if the loadaverage is
: over a certain amount then it will stop and restart a program or
: program(s)
This would be a way:
$max_load = 4.0; # for instance
$period = 60; # seconds
sub restart_programs {
# restart programs
}
while () {
$uptime = `/usr/bin/uptime`;
($avg1, $avg5, $avg15) = $uptime =~ /averages: ([\d.]+), ([\d.]+), ([\d.]+)/;
restart_programs if $avg5 > $max_load; # for example
sleep $period;
}
-- fxn
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?3B70E1E1.C90E7132>
