Xymon Mailing List Archive search

Why BBSVCNAME,BBHOSTSVC invalid in my alert script?

6 messages in this thread

list Casedj · Wed, 20 Jun 2007 20:03:06 +0800 ·
Hobbit 4.2.0 on RHEL4, BB client 1.08d on Windows XP cici.

hobbit-alerts.cfg:
 HOST=cici       SERVICE=procs,svcs
          SCRIPT /home/hobbit/server/etc/alert-svcs.sh  cici

Some environment variables,e.g,BBSVCNAME,BBHOSTSVC are used in alert script,
but they actually weren't shown as specific service or process that triggered the alert while the service or process reached down, just generic string procs.

alert-svcs.sh 
#!/bin/sh
echo "$BBHOSTSVC   reached error  state" |write hobbit
echo "$BBSVCNAME   reached error  state" |write hobbit
  

The result displayed as below:

Message from hobbit at my_linux on <no tty> at 22:21 ...
cici.procs   reached error  state
EOF

Message from hobbit at my_linux on <no tty> at 22:21 ...
procs   reached error  state
EOF


Thanks a lot.

Regards,
Case
list Henrik Størner · Wed, 20 Jun 2007 15:43:43 +0200 ·
quoted from Casedj
On Wed, Jun 20, 2007 at 08:03:06PM +0800, casedj wrote:
Hobbit 4.2.0 on RHEL4, BB client 1.08d on Windows XP cici.

hobbit-alerts.cfg:
 HOST=cici       SERVICE=procs,svcs
          SCRIPT /home/hobbit/server/etc/alert-svcs.sh  cici

Some environment variables,e.g,BBSVCNAME,BBHOSTSVC are used in alert script,
but they actually weren't shown as specific service or process that triggered 
the alert while the service or process reached down, just generic string procs.

alert-svcs.sh 
#!/bin/sh
echo "$BBHOSTSVC   reached error  state" |write hobbit
echo "$BBSVCNAME   reached error  state" |write hobbit
  

The result displayed as below:

Message from hobbit at my_linux on <no tty> at 22:21 ...
cici.procs   reached error  state
EOF
Actually, that's exactly as it should be. BBHOSTSVC contains the
hostname "cici" AND the servicename "procs", joined together with a 
dot. So an alert from hosts cici for the procs column has
BBHOSTSVC=cici.procs

BBSVCNAME is the service name, "procs" in this case:
quoted from Casedj
Message from hobbit at my_linux on <no tty> at 22:21 ...
procs   reached error  state
EOF
which is what you also get.

If you want just the hostname, use BBHOSTNAME. See the hobbit-alerts.cfg
man page for a listing of what the various variables contain.


Regards,
Henrik
list Daniel Bourque · Wed, 20 Jun 2007 11:47:33 -0500 ·
In your script, do a "set > /tmp/foo" . When hobbit runs the script,
look at /tmp/foo you'll see all the environment variables used by
hobbit. lots of stuff, you'll see the ones you're looking for.

-Dan
quoted from Henrik Størner
SCRIPT /home/hobbit/server/etc/alert-svcs.sh cici
Some environment variables,e.g,BBSVCNAME,BBHOSTSVC are used in alert
script,
but they actually weren't shown as specific service or process that
triggered the alert while the service or process reached down, just
generic string procs.
alert-svcs.sh
#!/bin/sh
echo "$BBHOSTSVC reached error state" |write hobbit
echo "$BBSVCNAME reached error state" |write hobbit
The result displayed as below:

Message from hobbit at my_linux <mailto:hobbit at my_linux> on <no tty> at
22:21 ...
cici.procs reached error state
EOF
Message from hobbit at my_linux <mailto:hobbit at my_linux> on <no tty> at
22:21 ...
procs reached error state
EOF

Thanks a lot.
Regards,
Case
list Case · Thu, 21 Jun 2007 15:05:28 +0800 ·
Hi Henrik and Daniel,

Thanks for support.

Mail message would include specific information about related process or
service' name  if we use MAIL in hobbit-alerts.cfg, e.g. "&red Cisco
Systems, Inc. VPN Service - Stopped".

How can we display similar messages in alert script while a process or
service triggers the alert?

Thanks a lot.

Regards,
Case
quoted from Henrik Størner

----- Original Message ----- 
From: "Henrik Stoerner" <user-ce4a2c883f75@xymon.invalid>
To: <user-ae9b8668bcde@xymon.invalid>
Sent: Wednesday, June 20, 2007 9:43 PM
Subject: Re: [hobbit] Why BBSVCNAME,BBHOSTSVC invalid in my alert script?

On Wed, Jun 20, 2007 at 08:03:06PM +0800, casedj wrote:
Hobbit 4.2.0 on RHEL4, BB client 1.08d on Windows XP cici.

hobbit-alerts.cfg:
 HOST=cici       SERVICE=procs,svcs
          SCRIPT /home/hobbit/server/etc/alert-svcs.sh  cici

Some environment variables,e.g,BBSVCNAME,BBHOSTSVC are used in alert
script,
but they actually weren't shown as specific service or process that
triggered
the alert while the service or process reached down, just generic string
procs.

alert-svcs.sh
#!/bin/sh
echo "$BBHOSTSVC   reached error  state" |write hobbit
echo "$BBSVCNAME   reached error  state" |write hobbit


The result displayed as below:

Message from hobbit at my_linux on <no tty> at 22:21 ...
cici.procs   reached error  state
EOF
Actually, that's exactly as it should be. BBHOSTSVC contains the
hostname "cici" AND the servicename "procs", joined together with a
dot. So an alert from hosts cici for the procs column has
BBHOSTSVC=cici.procs

BBSVCNAME is the service name, "procs" in this case:
Message from hobbit at my_linux on <no tty> at 22:21 ...
procs   reached error  state
EOF
which is what you also get.

If you want just the hostname, use BBHOSTNAME. See the hobbit-alerts.cfg
man page for a listing of what the various variables contain.


Regards,
Henrik

----- Original Message ----- 
From: "Henrik Stoerner" <user-ce4a2c883f75@xymon.invalid>
To: <user-ae9b8668bcde@xymon.invalid>
Sent: Wednesday, June 20, 2007 9:43 PM
Subject: Re: [hobbit] Why BBSVCNAME,BBHOSTSVC invalid in my alert script?

On Wed, Jun 20, 2007 at 08:03:06PM +0800, casedj wrote:
Hobbit 4.2.0 on RHEL4, BB client 1.08d on Windows XP cici.

hobbit-alerts.cfg:
 HOST=cici       SERVICE=procs,svcs
          SCRIPT /home/hobbit/server/etc/alert-svcs.sh  cici

Some environment variables,e.g,BBSVCNAME,BBHOSTSVC are used in alert 
script,
but they actually weren't shown as specific service or process that 
triggered
the alert while the service or process reached down, just generic string 
procs.

alert-svcs.sh
#!/bin/sh
echo "$BBHOSTSVC   reached error  state" |write hobbit
echo "$BBSVCNAME   reached error  state" |write hobbit


The result displayed as below:

Message from hobbit at my_linux on <no tty> at 22:21 ...
cici.procs   reached error  state
EOF
Actually, that's exactly as it should be. BBHOSTSVC contains the
hostname "cici" AND the servicename "procs", joined together with a
dot. So an alert from hosts cici for the procs column has
BBHOSTSVC=cici.procs

BBSVCNAME is the service name, "procs" in this case:
Message from hobbit at my_linux on <no tty> at 22:21 ...
procs   reached error  state
EOF
which is what you also get.

If you want just the hostname, use BBHOSTNAME. See the hobbit-alerts.cfg
man page for a listing of what the various variables contain.


Regards,
Henrik

list Henrik Størner · Thu, 21 Jun 2007 09:22:22 +0200 ·
quoted from Case
On Thu, Jun 21, 2007 at 03:05:28PM +0800, case wrote:
Mail message would include specific information about related process or
service' name  if we use MAIL in hobbit-alerts.cfg, e.g. "&red Cisco
Systems, Inc. VPN Service - Stopped".

How can we display similar messages in alert script while a process or
service triggers the alert?
The full status message text is passed in the BBALPHAMSG env. variable.
Process that to pick out lines with "&red", "&yellow" and so on. E.g.

   echo "$BBALPHAMSG" | egrep "^&red|&yellow"


Regards,
Henrik
list Daniel Bourque · Thu, 21 Jun 2007 09:50:57 -0500 ·
Note that lots of network check ( the ones defined in bb-services ) will not report statuses on a line starting with &color, they start with "Service..." . The following perl snippet is what I use to pick out statuses in my custom notification script.


        $subject="$ENV{BBHOSTSVC}: $ENV{BBCOLORLEVEL} ";

        foreach( split('\n',$ENV{BBALPHAMSG}) ) {
                if ( /^\&(yellow|red|purple)/ ){
                        $message .= $_;
                }
                if ( /^Service.* not OK/ ){
                        $message = $_;
                }
        }


Then use smtp mail to send out an email, you can concatenate $subject and $message togheter to if you whish to send out a message with no subject, nice for phones and pagers.

Enjoy


Daniel Bourque
Systems/Network Administrator
Weather Data Inc

Office (XXX) XXX-XXXX
Office (XXX) XXX-XXXX ext. XXXX
Mobile (XXX) XXX-XXXX
quoted from Henrik Størner


Henrik Stoerner wrote:
On Thu, Jun 21, 2007 at 03:05:28PM +0800, case wrote:
 
Mail message would include specific information about related process or
service' name  if we use MAIL in hobbit-alerts.cfg, e.g. "&red Cisco
Systems, Inc. VPN Service - Stopped".

How can we display similar messages in alert script while a process or
service triggers the alert?
   
The full status message text is passed in the BBALPHAMSG env. variable.
Process that to pick out lines with "&red", "&yellow" and so on. E.g.

  echo "$BBALPHAMSG" | egrep "^&red|&yellow"


Regards,
Henrik