From: Darren H. <da...@br...> - 2010-06-22 18:05:05
|
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 |