[hobbit] trouble with SCRIPT directive

Haertig, David F (Dave) haertig at avaya.com
Sat Jan 5 19:09:50 CET 2008


Sorry for the formatting of the script example in my p[revious post.  I
seem to be having cut-paste problems.  Cutting from a Putty window to a
Linux box and pasting into Outlook on a Windows box looks to be a little
glitchy.  I suppose if you understand PERL syntax in the first place,
you probably guessed that I had newlines after the semi-colons in the
original text.

I will try reformatting it again and see if it comes out better this
time:

#!/bin/perl
# RCS $Id: kill_script,v 1.3 2007/09/26 15:19:07 hobbit Exp $
#$debug++;      # Comment-out this line for normal operation
($host, $id, $pattern) = split(/,/, $ENV{RCPT}, 3);
exit unless ((defined $host) && (defined $id) && (defined $pattern));
$command = qq!ssh $id\@$host "pkill -f '$pattern'"!;
if ($debug) {
        $command =~ s/pkill/pgrep -l/;
        print `$command`;
}
else {
        `$command`;
}

-----Original Message-----
From: Haertig, David F (Dave) [mailto:haertig at avaya.com] 
Sent: Saturday, January 05, 2008 11:00 AM
To: hobbit at hswn.dk
Subject: RE: [hobbit] trouble with SCRIPT directive

You could make a dummy shell script named "trapgen_wrapper" that just
hardcodes the ip address parameter and then calls the real trapgen using
that.  Reference trapgen_wrapper in your hobbit alert config file,
passing it that same bogus_parameter for the recipient (which is
meaningless for your application, but required by Hobbit syntax).

If you don't want to hardcode the ip address in trapgen_wrapper, you
could make trapgen_wrapper parse out the info from the environment
variable "RCPT".

Here's a similar example I use to kill a process.  The SCRIPT directive
in hobbit-alerts.cfg passes this script three parameters, the hostname,
the userid, and a patternmatch for the kill.


SCRIPT kill_script hostname,userid,pattern_to_match


And here's the script that processes the above:

#!/bin/perl
# RCS $Id: kill_script,v 1.3 2007/09/26 15:19:07 hobbit Exp $
#$debug++;      # Comment-out this line for normal operation
($host, $id, $pattern) = split(/,/, $ENV{RCPT}, 3); exit unless
((defined $host) && (defined $id) && (defined $pattern)); $command =
qq!ssh $id\@$host "pkill -f '$pattern'"!; if ($debug) {
        $command =~ s/pkill/pgrep -l/;
        print `$command`;
}
else {
        `$command`;
}

-----Original Message-----
From: Galen Johnson [mailto:Galen.Johnson at sas.com]
Sent: Saturday, January 05, 2008 10:15 AM
To: hobbit at hswn.dk
Subject: RE: [hobbit] trouble with SCRIPT directive


Have you tried putting in a bogus recipient address and your options to
trapgen at the end?

=G=

-----Original Message-----
From: kevin [mailto:khanrahan at charter.net]
Sent: Sat 1/5/2008 11:38 AM
To: hobbit at hswn.dk
Subject: [hobbit] trouble with SCRIPT directive
 
Hi all,

 

This might seem long winded but I wanted to describe the problem in
detail and see if anyone could help please.

 

 I am trying to make use of the SCRIPT function in hobbit-alerts.cfg I
am trying to send snmp traps from hobbit to another receiver using a
utility called trapgen and I think the syntax of SCRIPT and trapgen are
getting in each others way. 

 

SCRIPT seems to have this syntax:

 

SCRIPT  <program>  <recipient>  <options>

 

And trapgen has this syntax:

 

trapgen  -d  destination   <options>

 

So, when I try to assemble it, it has this form:

 

SCRIPT  /home/hobbit/server/ext/trapgen -d 10.10.0.13 <options>

 

I get an error in the page.log that says trapgen needs at least a
destination specified as:

 

trapgen -d IPADDRESS   ..but it DOES have a destination!!!

 

It seems that the SCRIPT directive is intercepting the "-d IPADDRESS"
and interpreting it as it's own "recipient" directive.??

 

Is there a way around this? Is there a way to ignore the "recipient"
directive using SCRIPT?

 

Thanks for any ideas

 

KEvin

 


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



More information about the Xymon mailing list