From owner-freebsd-questions Tue Aug 7 23:53:10 2001 Delivered-To: freebsd-questions@freebsd.org Received: from smtp05.retemail.es (smtp05.iddeo.es [62.81.186.15]) by hub.freebsd.org (Postfix) with ESMTP id D3C4C37B637 for ; Tue, 7 Aug 2001 23:52:52 -0700 (PDT) (envelope-from fxn@retemail.es) Received: from retemail.es ([62.174.72.25]) by smtp05.retemail.es (InterMail vM.5.01.03.02 201-253-122-118-102-20010403) with ESMTP id <20010808065250.JMOD166.smtp05.retemail.es@retemail.es> for ; Wed, 8 Aug 2001 08:52:50 +0200 Message-ID: <3B70E1E1.C90E7132@retemail.es> Date: Wed, 08 Aug 2001 08:53:21 +0200 From: "F. Xavier Noria" X-Mailer: Mozilla 4.76 [en] (X11; U; FreeBSD 4.3-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG Subject: Re: Perl Script References: <001301c11fbc$69475600$4fcc4518@Gray1> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG : 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