[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [hobbit] Hobbit client executing a script to be proactive if a problem occurs?
- To: hobbit (at) hswn.dk
- Subject: Re: [hobbit] Hobbit client executing a script to be proactive if a problem occurs?
- From: Henrik Stoerner <henrik (at) hswn.dk>
- Date: Mon, 14 Apr 2008 07:43:01 +0200
- References: <47FF6DF2.4030306 (at) supranet.net>
- User-agent: Mutt/1.5.15+20070412 (2007-04-11)
On Fri, Apr 11, 2008 at 08:56:02AM -0500, Chris Wopat wrote:
> What I'd like to do is execute a script *on the client* when an alert has
> happened. Say, if CPU goes red on something, I'd like a script to run on
> the cilent. I could force the issue with #1 above, but this seems like it
> would invovle the server having the script, likely having SSH keys setup to
> get into the client, then run the script.
>
> Is there a cleaner way built in that will just say "if service FOO is red
> then on client run script ext/BAR.sh"?
There is. You use the Hobbit "query" command to probe the status, and
then act accordingly. To use your example with the "cpu" status going
red:
#!/bin/sh
CPUCOLOR=`$BB $BBDISP "query $MACHINE.cpu" | awk '{print $1}'`
if test "$CPUCOLOR" = "red"
then
# Kill some cpu hogging processes
.... whatever it takes ....
fi
exit 0
The "query" command returns the first line of the current status, and
the first word is the current color. You probably will want to put in
some sort of sanity check so you don't trigger this too often. Or
perhaps just log the fact that it triggered.
Regards,
Henrik