[hobbit] Hobbit client executing a script to be proactive if a problem occurs?

Haertig, David F (Dave) haertig at avaya.com
Fri Apr 11 18:30:11 CEST 2008


Here is how I execute a remote "pkill" on a client.  Replace
"client_server" with your client hostname, and replace "client_userid"
with the userid (on the client) that you want to run the script (pkill)
under.  Also, set up ssh pubkey authentication between the Hobbit server
and client so that ssh does not prompt you for a password.


hobbit_alerts.cfg:

##############################
$KILL_SCRIPT=/hobbit/server/ext/kill_script
HOST=client_server SERVICE=procs COLOR=red
        SCRIPT $KILL_SCRIPT client_server,client_userid,grep_pattern
##############################



/hobbit/server/ext/kill_script:

##############################
#!/bin/perl
#$debug++;      # Comment-out this line for normal operation
($host, $userid, $pattern) = split(/,/, $ENV{RCPT}, 3);
exit unless ((defined $host) && (defined $userid) && (defined
$pattern));
$command = qq!ssh $userid\@$host "pkill -f '$pattern'"!;
if ($debug) {
        $command =~ s/pkill/pgrep -l/;
        print `$command`;
}
else {
        `$command`;
}
##############################



And here is how I execute an arbitrary script on the client (in this
example, "weblogics_kill_script").  It is a minor modification of the
above:


hobbit_alerts.cfg:

##############################
$REMOTE_SCRIPT=/hobbit/server/ext/remote_script
HOST=ssdpws001 SERVICE=weblogics COLOR=red
        SCRIPT $REMOTE_SCRIPT
client_server,client_userid,/export/home/hobbit/scripts/weblogics_kill_s
cript
##############################


Note: weblogics_kill_script exists on the client - I use it to force a
few thread dumps, archive logfiles, and then kill/restart weblogics

/hobbit/server/ext/remote_script:

##############################
#!/bin/perl
#$debug++;      # Comment-out this line for normal operation
($host, $userid, $script) = split(/,/, $ENV{RCPT}, 3);
exit unless ((defined $host) && (defined $userid) && (defined $script));
$command = qq!ssh $userid\@$host "$script"!;
if ($debug) {
        print `$command`;
}
else {
        `$command`;
}
##############################


-----Original Message-----
From: Chris Wopat [mailto:chrisw at supranet.net] 
Sent: Friday, April 11, 2008 7:56 AM
To: hobbit at hswn.dk
Subject: [hobbit] Hobbit client executing a script to be proactive if a
problem occurs?

Hello,

I've been running hobbit for a few years, after converting from Big
Brother. I actively use it to monitor hundreds of hosts, send alerts,
etc. However, one thing I have yet to do is use any custom scripts for
anything. Looking at docs, I see two ways that scripts are called:

1) an alert can call a script instead of email directly. This script is
passed variables, and just about anything can be done *on the hobbit
server* from here.

2) A script can be launched on the client, from ext/, when the hobbit
clien starts. This script is generally used to add another column to
hobbit.

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"?

Thanks
--Chris

To unsubscribe from the hobbit list, send an e-mail to
hobbit-unsubscribe at hswn.dk





More information about the Xymon mailing list