#!/usr/bin/perl -w # # nagios_status.cgi # Copyright (C) 2010-2013 Stefan Heumader # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # use strict; use warnings; use NagiosStatus; my $foo = NagiosStatus->new("/usr/local/nagios/var/status.dat"); #$foo->debug(1); $foo->parse_statusfile(); $foo->evaluate(); my @alerts = $foo->get_alerts(["host_name", "service_description", "plugin_output"]); my $ct = "Content-Type: text/html\n\n"; $ct .= "\n"; $ct .= "\n"; $ct .= "\t\n"; $ct .= "\t\tNagios Status\n"; $ct .= "\t\t\n"; $ct .= "\t\t\n"; $ct .= "\t\t\n"; $ct .= "\t\t\n"; $ct .= "\t\n"; $ct .= "\t\n"; $ct .= "\t\t\n"; if (scalar @alerts == 0) { $ct .= "\t\t\t\n"; } foreach (@alerts) { $ct .= "\t\t\t\n"; $ct .= "\t\t\t\t\n"; $ct .= "\t\t\t\t\n"; $ct .= "\t\t\t\t\n"; $ct .= "\t\t\t\n"; } $ct .= "\t\t
NO PROBLEM
{'id'}1\" " if defined($_->{'id'}); $ct .= "class=\"$_->{'type'}\">$_->{'host_name'}{'id'}2\" " if defined($_->{'id'}); $ct .= "class=\"$_->{'type'}\">$_->{'service_description'}{'id'}3\" " if defined($_->{'id'}); $ct .= "class=\"$_->{'type'}\">$_->{'plugin_output'}
\n"; $ct .= "\t\n"; $ct .= ""; print $ct;