#!/usr/bin/perl -w
#
# check_nagios_performance - nagios plugin
#
# Copyright (C) 2007,2008 Hendrik Baecker,
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# Report bugs to:
#
# Last Updated: 07.02.2008 Version 0.5.0
#
# ChangeLog
# -------------------------------------------------------------------
# By: Michael Luebben
# Date: 23.01.2008
# Version: 0.3.1
# Changes:
# - Change Output to HTML-Output
# - Add more information and metric in output
# - Fix bug in output for version
#
# By: Michael Luebben
# Date: 29.01.2008
# Version: 0.4.0
# Changes:
# - Fix bug in object-parameter
# - Add check for supported nagios version
# - Add option m for average/last in minutes
# - Move opject lat to alat
# - Add object plat for passive host/service latency (average)
#
# By: Michael Luebben
# Date: 07.02.2008
# Version: 0.5.0
# Changes:
# - Add object cobu check for command buffer usage
# - Add object ecol for last external commands
# - Delete switch command
# - Cleanup and documantation source code
#
# NOTE:
# =======
# Peformance monitoring for passive host/service checks (object plat) use
# nagiostat 3.0rc2 or higher!!!!
# Earlier versions have a bug.
# -------------------===== Set path =====--------------------
# path to util.pm !!
use lib "/usr/local/nagios/libexec";
# path to your nagiostats binary
my $bin="/usr/local/nagios/bin/nagiostats";
# path to your external command file
my $nagios_extcmd_file="/usr/local/nagios/var/rw/nagios.cmd";
# ------------------===== Used modules =====-----------------
use strict;
use Getopt::Long;
use vars qw($PROGNAME);
use utils qw ($TIMEOUT %ERRORS &print_revision &support);
# ---------------===== Declare variables =====---------------
my $opt_V; # Version
my $opt_h; # Help
my $opt_e; # External command
my $opt_x; # Hostname for external command
my $opt_y; # Service description for external command
my $opt_w; # WARNING treshold
my $opt_c; # CRITICAL treshold
my $opt_o=""; # Object
my $opt_t="10"; # Timeout (sec); Default 10 Second
my $opt_m = "1"; # Average (min); Default 1 Minute
my $version="0.4.1";
my $getNagiosVersion;
my @nagiosVersion;
my $line;
my $value;
my %classService;
my $state = "OK";
my $output = "OK - ";
my %data;
my %outputText;
my %outputMetric;
my %outputPerfdata;
my $perfdata="";
my $perfdataFlag="0";
my $metricMin;
my $TotCmdBuf;
my $UsedCmdBuf;
my $HighCmdBuf;
my $TotChkBuf;
my $UsedChkBuf;
my $HighChkBuf;
sub print_help ();
sub print_usage ();
$PROGNAME="check_nagios_performance";
# -------------------===== Functions =====-------------------
sub _parse {
my $string = shift;
chomp $string;
my $tmp_string = $string;
$string =~ s/^;?([\d\.-]+)?;\s*//;
if( $tmp_string eq $string) {
printf("DEBUG: No pattern match in function _parse($string)\n");
return undef;
}
return undef unless ((defined $1 && $1 ne "") && ($string ne ";"));
return ($string,$1);
}
sub print_usage () {
print "Usage:\n";
print " $PROGNAME -o
===== The PNP Template =====
===== Screenshots =====
==== Nagios Service output ====
{{projects:check_nagios_performance:service_output_cobu.png|}}
==== PNP-Graph ====