nagios/opsview with qpage
Darren Hill
darren at brucetelecom.com
Tue Jun 22 20:05:02 CEST 2010
Hi,
I have this contact script for my nagios/opsview to work.
I have qpage paging manually if I just tell it to run qpage, but I don't
want 2 contacts, one for hosts, one for services.
I need a way for it to figure out if it's a host or service page and
then run the command from there.
Any ideas what I've got wrong?
Running qpage manually works fine such as "qpage -dip darren this is a
test".
If I set it up to just use qpage and send it all, it pages but is all
garbled as it includes variables for a service in a host page that does
not work.
Any help would be greatly appreciated.
This is the standard opsview submit_sms script which I am attempting to
modify to use qpage instead of sending an email.
#!/usr/bin/perl -w
#
#
# SYNTAX:
my $usage = qq{
sms_darren
Usage: sms_darren
};
sub usage { if ($_ = shift) { print "Error: $_\n" } print $usage; exit 1; }
use strict;
use Switch;
use lib "/usr/local/nagios/perl/lib";
sub ldie { $_ = shift; print $_.$/; exit 1 }
my ($text, $message);
if ( $ENV{NAGIOS_SERVICEDESC} ) {
## TODO Need to check for ack message as well
## ACKNOWLEDGE_SVC_PROBLEM
$text = "$ENV{NAGIOS_SERVICEDESC} on $ENV{NAGIOS_HOSTNAME} is
$ENV{NAGIOS_SERVICESTATE}: $ENV{NAGIOS_SERVICEOUTPUT} (
$ENV{NAGIOS_SHORTDATETIME})";
#
$text = "$ENV{NAGIOS_HOSTNAME} $ENV{NAGIOS_SERVICEDESC}
$ENV{NAGIOS_SERVICESTATE}: $ENV{NAGIOS_SERVICEOUTPUT} ($ENV{N
AGIOS_SHORTDATETIME})";
} else {
$text = "$ENV{NAGIOS_HOSTNAME} is $ENV{NAGIOS_HOSTSTATE}:
$ENV{NAGIOS_HOSTOUTPUT} ($ENV{NAGIOS_SHORTDATETIME})";
}
# Cleanup text
$text =~ s/\n/ /g;
my $maxchars = 135;
$text = substr($text, 0, $maxchars);
qpage -s nagios -p $CONTACTNAME$ echo -e $text
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list