#!/usr/bin/perl # Simple service picker, by Frank Johnson # Released under GPLv2 # # When called by GET, displays a form # When called by POST, OR's all your choices and sends an HTTP redirect to status.cgi use strict; use CGI qw/:standard/; my $stypes = 0; my $sprops = 0; my $sttxt = ''; my $q = new CGI; my %p = $q->Vars; if ($ENV{'REQUEST_METHOD'} ne 'POST') { print $q->header; &blank_form(); exit; } my @st = $q->param('stypes'); # OR together the chosen service types $stypes |= eval(join('|',@st)); if ($stypes) { $sttxt = "&servicestatustypes=$stypes"; } # OR together the chosen service properties foreach my $x (keys(%p)) { if ($x =~ /^sp/) { $sprops |= $p{$x}; } } # get the virtual host name for building the redirect URL my $vh = $q->virtual_host(); # for debugging. probably not very useful #print header, start_html('Something'), "ST: $stypes",p, "SP: $sprops",end_html; ## You may need to edit this URL to suit your environment print redirect("http://$vh/nagios/cgi-bin/status.cgi?host=all$sttxt&serviceprops=$sprops"); sub blank_form { print STDOUT < Service-Picker
Service Status Types:

Service Properties:
PropertyYesNoN/A
Downtime scheduled
Service Acknowledged
Active Checks Disabled
Event Handler Disabled
Flap Detection Disabled
Service Flapping
Notifications Disabled
Passive Checks Disabled
Last Result Pasv/Actv

EOF }