Permalink
Browse files

Merge branch 'master' of github.com:willixix/WL-NagiosPlugins

  • Loading branch information...
2 parents 68f2a49 + 1d08b69 commit 5061d36ecb7389b775b70a8dcde206b9a363f119 @willixix committed May 3, 2013
View
36 Naglio.pm
@@ -22,7 +22,7 @@ our $AUTHOR = "William Leibzon";
# THIS IS WORK IN PROGRESS, THE LIBRARY HAS NOT BEEN RELEASED YET AND INTERFACES MAY CHANGE
#
# ============================= LIBRARY HISTORY AND VERSIONS ====================================
-#
+#
# Note: you may safely skip this section if you're looking at documentation about this library or plugin
#
# [2006-2008] The history of this library goes back to plugins such as check_snmp_temperature.pl,
@@ -31,7 +31,7 @@ our $AUTHOR = "William Leibzon";
# these thresholds. Several of my plugins had common architecture supporting multiple
# variables or attributes to be checked using -a/--attributes/--variables option and
# --warn and --crit options with list of thresholds for these attributes and --perfvars
-# specifying variables whose data would only go as PERFOUT for graphing.
+# specifying variables whose data would only go as PERFOUT for graphing.
#
# [2008-2011] Threshold parsing and check code had been rewritten and support added for specifying
# range per plugin guidelines: http://nagiosplug.sourceforge.net/developer-guidelines.html
@@ -115,7 +115,7 @@ my $DEFAULT_PERF_OK_STATUS_REGEX = 'GAUGE|COUNTER|^DATA$|BOOLEAN';
# plugin_description => string - plugin longer description
# plugin_authors => string - list of plugin authors
# knownStatsVars => reference to hash - hash array defining known variables, what type they are, their description
-# usage_text => string, - text string to display when calling default usage function
+# usage_text => string, - text string to display when calling default usage function
# usage_function => &ref - OR function that would display helpful text in case of error with options for this plugin
# verbose => 1 or "" or "filename" - set to 1 or "" if verbose/debug or to filename to send data to (may not be called "0" or "1")
# output_comparison_symbols => 0 or 1 - 1 means library output in case threshold is met can use "<", ">", "="
@@ -301,7 +301,7 @@ sub readable_time {
my ($self,$total_sec) = _self_args(@_);
my ($sec,$mins,$hrs,$days);
my $txtout="";
-
+
sub div_mod { return int( $_[0]/$_[1]) , ($_[0] % $_[1]); }
($mins,$sec) = div_mod($total_sec,60);
@@ -325,7 +325,7 @@ sub verb {
if (defined($o_verb) || (defined($self) && defined($self->{'verbose'}) && $self->{'verbose'} ne 0)) {
$debug_file_name = $self->{'debug_file'} if defined($self) && $self->{'debug_file'} ne "";
- $debug_file_name = $self->{'verbose'} if $debug_file_name ne "" && defined($self) &&
+ $debug_file_name = $self->{'verbose'} if $debug_file_name ne "" && defined($self) &&
($self->{'verbose'} ne 0 && $self->{'verbose'} ne 1 && $self->{'verbose'} ne '');
$debug_file_name = $o_verb if $debug_file_name ne "" && defined($o_verb) && $o_verb ne "";
if ($debug_file_name ne "") {
@@ -702,7 +702,7 @@ sub check_threshold {
$issymb = 0 if defined($self) && $self->{'output_comparison_symbols'} eq 0;
# verb("debug check_threshold: $mod : ".(defined($lv1)?$lv1:'')." : ".(defined($lv2)?$lv2:''));
- return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
+ return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
return " " . $attrib . " is " . $data . ( ($issymb==1)?' = ':' equal to ' ). $lv1 if $mod eq '=' && $data eq $lv1;
return " " . $attrib . " is " . $data . ( ($issymb==1)?' != ':' not equal to ' ). $lv1 if $mod eq '!' && $data ne $lv1;
return " " . $attrib . " is " . $data . ( ($issymb==1)?' > ':' more than ' ) . $lv1 if $mod eq '>' && $data>$lv1;
@@ -734,7 +734,7 @@ sub parse_threshold {
# link to an array that holds processed threshold data
# array: 1st is type of check, 2nd is threshold value or value1 in range, 3rd is value2 in range,
# 4th is extra options such as ^, 5th is nagios spec string representation for perf out
- my $th_array = [ '', undef, undef, '', '' ];
+ my $th_array = [ '', undef, undef, '', '' ];
my $th = $thin;
my $at = '';
@@ -801,7 +801,7 @@ sub threshold_specok {
return 1 if defined($warn_thar) && defined($warn_thar->[1]) &&
defined($crit_thar) && defined($crit_thar->[1]) &&
isnum($warn_thar->[1]) && isnum($crit_thar->[1]) &&
- $warn_thar->[0] eq $crit_thar->[0] &&
+ $warn_thar->[0] eq $crit_thar->[0] &&
(!defined($warn_thar->[3]) || $warn_thar->[3] !~ /\^/) &&
(!defined($crit_thar->[3]) || $crit_thar->[3] !~ /\^/) &&
(($warn_thar->[1]>$crit_thar->[1] && ($warn_thar->[0] =~ />/ || $warn_thar->[0] eq '@')) ||
@@ -915,7 +915,7 @@ sub vardata {
# SAVED:YES|NO - put results in saved data (this really should not be set manually)
# PATTERN:<regex> - enables regex match allowing more than one real data name to match this threshold
# NAME:<string> - overrides output status and perf name for this variable
-# UOM:<string> - unit of measurement symbol to add to perf
+# UOM:<string> - unit of measurement symbol to add to perf
# @RETURNS : Returns reference to a hash array, a library's structure for holding processed MULTI-THRESHOLD spec
# Note that this is MULTI-THRESHOLD hash structure, it itself contains threshold hashes returned by parse_threshold()
# @PRIVACY & USE : PUBLIC, but its use is discouraged. Maybe used directly or as an object instance function.
@@ -934,7 +934,7 @@ sub parse_thresholds_list {
$t !~ /^PATTERN/ && $t !~ /^NAME/ && $t !~ /^UOM/) {
if (scalar(@tin)==2) {
if (defined($self)) {
- $thres->{'WARN'} = $self->parse_threshold($tin[0]);
+ $thres->{'WARN'} = $self->parse_threshold($tin[0]);
$thres->{'CRIT'} = $self->parse_threshold($tin[1]);
}
else {
@@ -1147,7 +1147,7 @@ sub additional_options_list {
push @VarOptions,$v."=s";
if ($self->{'enable_rate_of_change'} eq 1 && $known_vars->{$v}[1] eq 'COUNTER' && ($o_rprefix ne '' || $o_rsuffix ne '')) {
$v2 = $o_rprefix.$v.$o_rsuffix;
- push @VarOptions,$v2."=s"
+ push @VarOptions,$v2."=s"
}
}
}
@@ -1261,7 +1261,7 @@ sub options_startprocessing {
for (my $i=0; $i<scalar(@{$perfVars}); $i++) {
$perfVars->[$i] = '&'.$1 if $perfVars->[$i] =~ /^$o_rprefix(.*)$o_rsuffix$/;
}
- }
+ }
}
if (defined($o_warn) || defined($o_crit) || defined($o_variables)) {
if (defined($o_variables)) {
@@ -1319,7 +1319,7 @@ sub _options_setthresholds {
$o_rsuffix = $self->{'o_rsuffix'} if exists($self->{'o_rsuffix'});
if (scalar(@{$ar_warnLv})!=scalar(@{$ar_varsL}) || scalar(@{$ar_critLv})!=scalar(@{$ar_varsL})) {
- printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number of attributes specified at '-a' (%d). If you need to ignore some attribute do it as ',,'\n", scalar(@{$ar_warnLv}), scalar(@{$ar_critLv}), scalar(@{$ar_varsL});
+ printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number of attributes specified at '-a' (%d). If you need to ignore some attribute do it as ',,'\n", scalar(@{$ar_warnLv}), scalar(@{$ar_critLv}), scalar(@{$ar_varsL});
$self->verb("Warning Levels: ".join(",",@{$ar_warnLv}));
$self->verb("Critical Levels: ".join(",",@{$ar_critLv}));
if (defined($self)) { $self->usage(); }
@@ -1490,7 +1490,7 @@ sub set_statuscode {
# @DESCRIPTION : This function is called closer to end of the code after plugin retrieved data and
# assigned values to variables. This function checks variables against all thresholds.
-# It prepares statusdata and statusinfo and exitcode.
+# It prepares statusdata and statusinfo and exitcode.
# @LAST CHANGED : 09-03-12 by WL
# @INPUT : none
# @RETURNS : nothing (future: 1 on success, 0 on error)
@@ -1552,7 +1552,7 @@ sub main_checkvars {
$self->addto_statusdata_output($dvar,$aname." is ".$dataresults->{$dvar}[0]);
# if we were asked to output performance, prepare it but do not output until later
- if ((defined($self->{'o_perf'}) && defined($avar) && !exists($thresholds->{$avar}{'PERF'})) ||
+ if ((defined($self->{'o_perf'}) && defined($avar) && !exists($thresholds->{$avar}{'PERF'})) ||
(exists($thresholds->{$avar}{'PERF'}) && $thresholds->{$avar}{'PERF'} eq 'YES')) {
$perf_str = perf_name($aname).'='.$dataresults->{$dvar}[0];
$self->set_perfdata($dvar, $perf_str, undef, "IFNOTSET"); # with undef UOM would get added
@@ -1608,7 +1608,7 @@ sub main_perfvars {
}
else {
$self->verb(" -- not adding to perfdata because of it is '".$known_vars->{$avar}[1]."' type variable --");
- }
+ }
}
else {
$self->verb("Perfvar: $avar selected for PERFOUT but data not defined");
@@ -1706,7 +1706,7 @@ sub get_shortname {
$name = uc basename( $ENV{NAGIOS_PLUGIN} || $0 );
}
$name=$1 if $name =~ /^check(.*)/;
- $name=$1 if $name =~ /(.*)\.(.*)$/;
+ $name=$1 if $name =~ /(.*)\.(.*)$/;
return $name;
}
@@ -1804,4 +1804,4 @@ sub check_messages {
return ($ret_code,$ret_msg);
}
-##################################### END OF THE LIBRARY FUNCTIONS #########################################
+##################################### END OF THE LIBRARY FUNCTIONS #########################################
View
52 check_by_snmp.pl
@@ -39,12 +39,12 @@
#
# This program is written and maintained by:
# William Leibzon - william(at)leibzon.org
-#
+#
# ============================= SETUP NOTES ====================================
-#
+#
# To find all available options do:
# ./check_by_snmp -help
-#
+#
# All SNMP Versions (1,2,3) and authentication options are supported and
# similar to my other check_snmp plugins.
#
@@ -76,17 +76,17 @@
# with same exit code as remote command (usualy nagios plugin) and it gives
# nagios exit errors if SNMP connection can not be established.
#
-# If more than one Extend name or OID are specified, than exit code is from
+# If more than one Extend name or OID are specified, than exit code is from
# last one though it really does not make mush sense to specify more than one
-# when you're basically using check_by_snmp to execute remote plugin
+# when you're basically using check_by_snmp to execute remote plugin
#
# -F option is used to specify which files the remote data should be written to
# on nagios server. If you have a plugin on nagios that is expecting certain
# file you can use this to make it available to the plugin. Be warned that you
# may have multiple of the same plugin executed for different remote systems
# so really each file should be unique for each run which is why -T is better.
# -F can also be useful for debugging as even if you write to standard output
-# you can use this to also write data to some debug/log file.
+# you can use this to also write data to some debug/log file.
#
# -T option will have this plugin write data to temporary file name of its choice.
# The directory is normally /tmp but if you want you can specify different
@@ -99,7 +99,7 @@
# Please note that you MUST NOT specify --exec="command". This is really not your
# standard option, it basically just indicates where ARG processing should end
# and rest is used as ARGV parameters for a command to be executed.
-#
+#
# You would use this option when real processing is to be done by some other
# nagios plugin which would use data retrieved from a remote system with
# check_by_snmp. Very often these would be dumping of files in /proc,
@@ -122,16 +122,16 @@
# And if you are using -F then check_by_snmp will just use exec to replace
# itself with specified command. If files specified in -F is a temporary file
# name, you are responsible for deleting it.
-#
+#
# -v is a debug option when you're testing this plugin directly on the shell
-# command line, you will find it useful if you run into any problems
+# command line, you will find it useful if you run into any problems
#
# ========================= SETUP EXAMPLES ==================================
#
# For example on how to set this up I will use check_drbd plugin by Brandon Lee Poyner
# (you can find it on exchange.nagios.org) as it happened to be good victim and can
# be used with check_by_snmp in multiple ways:
-#
+#
# 1) -S option with no --exec (this is default behavior when no options are specified)
# Returns results from SNMP to standard output. This is what you may call "snmp cat"
# and so most similar to check_nrpe or check_by_ssh in that it lets you simply
@@ -152,7 +152,7 @@
# or more temporary files and execute specified nagios plugin. The plugin
# will parse arguments in the actual check command to be executed and replace
# %FILE1% with a name of the first file it wrote
-# %FILE2% with a name of the 2nd file it wrote
+# %FILE2% with a name of the 2nd file it wrote
# ...
# If these were temporary files, they will be deleted after plugin finished
#
@@ -181,9 +181,9 @@
# define command {
# command_name check_drbd
# command_line $USER1$/check_by_snmp -O 1.3.6.1.4.1.2021.202 -H $HOSTADDRESS$ -L sha,aes -l $_HOSTSNMP_V3_USER$ -x $_HOSTSNMP_V3_AUTH$ -X $_HOSTSNMP_V3_PRIV$ -S --exec $USER1$/check_drbd-0.5.2 -p - -d All
-# }
+# }
#
-# 4) -F with --exec
+# 4) -F with --exec
# Last case which is my least favorite is to specify actual files to
# write with -F option and then execute another plugin which will know
# these file names and read them for processing. If these are meant to
@@ -245,7 +245,7 @@
eval 'use Net::SNMP';
if ($@) {
$no_snmp=1;
-}
+}
# These are nsExtendResult and nsExtendOutLine table bases
my $oid_ExtendExitStatus="1.3.6.1.4.1.8072.1.3.2.3.1.4";
@@ -259,7 +259,7 @@
my $opt_extlist=undef; # List of Extend names to e retrieved
my @extends= (); #
my $opt_oidlist= undef; # List of OIDs to retrieve data from
-my @oids= (); #
+my @oids= (); #
my $opt_filelist=undef; # List of files to write
my @files=(); #
@@ -294,14 +294,14 @@ sub print_usage {
sub isnum { # Return true if arg is a number
my $num = shift;
if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 1 ;}
- return 0;
+ return 0;
}
sub help {
print "\nCheck By SNMP (using Extend or Exec) for Nagios, version ",$Version,"\n";
print "GPL licence, (c) 20011-2012 William Leibzon\n\n";
- print_usage();
- print <<EOT;
+ print_usage();
+ print <<EOT;
Debug & Console Options:
-v, --verbose
@@ -316,7 +316,7 @@ sub help {
If you added "extend name command" in /etc/snmp/snmpd.conf such as
"exec cpustat /bin/cat /proc/stat"
then "-E cpustat" would return data from executing "/bin/cat /proc/stat".
- You can specify more than one such name here to be queried at once,
+ You can specify more than one such name here to be queried at once,
wuth at least one extend name or exec OID (see below) required.
-O, --oid=<oid>[,<oid>[,<oid>..]]
OID of where results have been put with snmp exec. At least one is required.
@@ -481,7 +481,7 @@ sub check_options {
{
print "Put snmp login info!\n";
print_usage(); exit $ERRORS{"UNKNOWN"};
- }
+ }
if (defined($opt_filelist)) {
if (defined($o_tempfiles)) {
@@ -525,7 +525,7 @@ sub replace_macros {
verb("Replacing '".$reg."' in '".$args->[$i]."' with '".$rep."'");
$args->[$i] =~ s/$reg/$rep/g;
}
- }
+ }
}
}
@@ -616,7 +616,7 @@ sub snmp_session {
my $retcode = undef; # return exit value of the last executed command
my ($i,$b,$e);
-# Convert Extend Name into OIDs which are base + ASCII code of each character in the name
+# Convert Extend Name into OIDs which are base + ASCII code of each character in the name
for($i=0; $i<scalar(@extends);$i++) {
my @chars = split //, $extends[$i];
$oids[$i]=$oid_ExtendDataLines.'.'.scalar(@chars);
@@ -625,8 +625,8 @@ sub snmp_session {
$oids[$i] .= '.' . ord($c);
$oid_exitcode .= '.' . ord($c);
}
- verb("Converted Extends Name '".$extends[$i]."' to Data Lines OID ".$oids[$i]);
- verb("Converted Extends Name '".$extends[$i]."' to Exit Status OID ".$oid_exitcode);
+ verb("Converted Extends Name '".$extends[$i]."' to Data Lines OID ".$oids[$i]);
+ verb("Converted Extends Name '".$extends[$i]."' to Exit Status OID ".$oid_exitcode);
}
# Read the data from SNMP
@@ -710,7 +710,7 @@ sub snmp_session {
replace_macros(\@exec_args,\@files);
verb("Command to be executed (after MACRO processing): ".join(' ',@exec_args));
if (defined($o_stdout) || defined($o_tempfiles)) {
- pipe(OUT_FROMPIPE, OUT_TOPIPE) or die "Could not create pipe - $!";
+ pipe(OUT_FROMPIPE, OUT_TOPIPE) or die "Could not create pipe - $!";
pipe(IN_FROMPIPE, IN_TOPIPE) or die "Could not create pipe - $!";
$pid = fork();
if (!defined($pid)) {
@@ -752,7 +752,7 @@ sub snmp_session {
close OUT_TOPIPE;
close IN_FROMPIPE;
open(STDIN, "<&=".fileno(OUT_FROMPIPE)) or die "Could not redirect STDIN - $!";
- # below will not work with embedded perl, so have to use dup2
+ # below will not work with embedded perl, so have to use dup2
# open(STDOUT, ">&=".fileno(IN_TOPIPE)) or die "Could not redirect STDOUT - $!";
dup2(fileno(IN_TOPIPE),1);
if (!exec(@exec_args)) {
View
2 check_daytime.pl
@@ -138,7 +138,7 @@ sub check_options {
print_usage();
exit $ERRORS{"UNKNOWN"};
}
- if (!defined($o_protocol) || !defined($o_host)) {
+ if (!defined($o_protocol) || !defined($o_host)) {
print "Hostname (-H) and protocol (-P) are required parameters for this plugin\n\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
View
2 check_dnsname.pl
@@ -4,7 +4,7 @@
#
# Program : check_dnsname.pl
# Version : 0.11
-# Date : Nov 24 2006
+# Date : Nov 24 2006
# (added all the top comments you see, no code changes since 2005?)
# Author : William Leibzon - william@leibzon.org
# Summary : This is a nagios plugin that makes sure two dns hostnames point
View
44 check_files.pl
@@ -2,7 +2,7 @@
#
# ============================== SUMMARY =====================================
#
-# Program : check_files.pl
+# Program : check_files.pl
# Version : 0.41
# Date : Mar 23, 2013
# Author : William Leibzon - william@leibzon.org
@@ -41,11 +41,11 @@
# List of files to check are specified with -F option. These should be
# specified in a way you'd specify files for ls, so for example to check
# all perl files you use "*.pl" which is specified as:
-# $ ./check_files.pl -L Files -F '*.pl' -w 4 -c 7
+# $ ./check_files.pl -L Files -F '*.pl' -w 4 -c 7
# (above will give a warning if there are > 4 *.pl files and critical alert if > 7)
#
# You can specify more than one file type to check, for example:
-# $ ./check_files.pl -L Files -F '*.pl,*.sh' -w 4,3 -c 7,5
+# $ ./check_files.pl -L Files -F '*.pl,*.sh' -w 4,3 -c 7,5
# (above will give a warning if there are more than 4 .pl or more than 3 *.sh files
# and CRITICAL alert if there are more than 7 .pl or more than 5 *.sh files)
#
@@ -56,7 +56,7 @@
# Search largest file:
# $ ./check_files.pl -D /opt/oradata -F "t" -f -s -H "10.0.0.1"
# OK - Largest size file is 3896 octet, 2 t files found | 't'=2 size_largest=3896o size_smallest=1o
-#
+#
# About Threhold Format:
#
# Warning and critical levels are specified with '-w' and '-c' and each one
@@ -73,7 +73,7 @@
# Supported are also two specifications of range formats:
# number1:number2 issue alert if data is OUTSIDE of range [number1..number2]
# i.e. alert if data<$number1 or data>$number2
-# @number1:number2 issue alert if data is WITHIN range [number1..number2]
+# @number1:number2 issue alert if data is WITHIN range [number1..number2]
# i.e. alert if data>=$number and $data<=$number2
#
# A special modifier '^' can also be used to disable checking that warn values
@@ -101,11 +101,11 @@
# output number of files of each type and age of oldest and newest files.
#
# Execution Options:
-#
+#
# This plugin checks list of files by executing 'ls' on a local system where
# it is run. It can also execute ls on a remote system or process the output
# from ls command executed through some other plugin. Options -C, -H and -I
-# are used to specify how and where to execute 'ls' and process results.
+# are used to specify how and where to execute 'ls' and process results.
#
# With -I the plugin will expect output from "ls -l" in standard input.
#
@@ -122,7 +122,7 @@
#
# [0.2] Apr 19, 2012 - First version written based on check_netstat.pl 0.351
# [0.3] Apr 21, 2012 - Added -l -r and -T options and fixed bugs
-# [0.32] Apr 21, 2012 - Added -I as an alternative to -C
+# [0.32] Apr 21, 2012 - Added -I as an alternative to -C
# [0.33] Apr 27, 2012 - Fixed bug with determining file ages
# [0.34] Jun 22, 2012 - Added better reporting of file age than just seconds
# [0.35] Aug 21, 2012 - Option '-T' was broken. Bug reported by Jeremy Mauro
@@ -178,7 +178,7 @@
my @o_filesL= (); # array of regex based on above
my $o_warn= undef; # warning level option
my @o_warnLv= (); # array from warn options, before further processing
-my @o_warnL= (); # array of warn options, each array element is an array of threshold spec
+my @o_warnL= (); # array of warn options, each array element is an array of threshold spec
my $o_crit= undef; # Critical level option
my @o_critLv= (); # array of critical options before processing
my @o_critL= (); # array of critical options, each element is an array of threshold spec
@@ -202,7 +202,7 @@
my $ls_pid= undef;
-# For verbose output
+# For verbose output
sub verb { my $t=shift; print $t,"\n" if defined($o_verb) ; }
sub print_version { print "$0: $Version\n" };
@@ -232,7 +232,7 @@ sub check_threshold {
my $lv2 = $th_array->[2];
# verb("debug check_threshold: $mod : ".(defined($lv1)?$lv1:'')." : ".(defined($lv2)?$lv2:''));
- return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
+ return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
return " " . $attrib . " is " . $data . " (equal to $lv1)" if $mod eq '=' && $data eq $lv1;
return " " . $attrib . " is " . $data . " (not equal to $lv1)" if $mod eq '!' && $data ne $lv1;
return " " . $attrib . " is " . $data . " (more than $lv1)" if $mod eq '>' && $data>$lv1;
@@ -250,7 +250,7 @@ sub parse_threshold {
# link to an array that holds processed threshold data
# array: 1st is type of check, 2nd is value2, 3rd is value2, 4th is option, 5th is nagios spec string representation for perf out
- my $th_array = [ '', undef, undef, '', '' ];
+ my $th_array = [ '', undef, undef, '', '' ];
my $th = $thin;
my $at = '';
@@ -339,7 +339,7 @@ sub help {
print extra debugging information
File and Directory Selection options:
-
+
-F, --files=STR[,STR[,STR[..]]]
Which files to check. What is here is similar to what you use for listing
file with ls i.e. *.temp would look for all temp files. This is converted
@@ -355,7 +355,7 @@ sub help {
-l, --lsfiles
When present this adds specified file spec to ls. Now ls will list
only files you specified with -F where as by default 'ls -l' will
- list all files in directory and choose some with regex. This option
+ list all files in directory and choose some with regex. This option
should be used if there are a lot of files in a directory.
WARNING: using this option will cause -r not to work on most system
@@ -376,7 +376,7 @@ sub help {
on the remote server with ssh. Beware the script must be run with an account
that has its public key to the remote server.
This option does not work with the -C option
-
+
Threshold Checks and Performance Data options:
-f, --perfparse
@@ -516,7 +516,7 @@ sub check_options {
}
}
- if ((defined($o_stdin) && defined($o_cmd)) ||
+ if ((defined($o_stdin) && defined($o_cmd)) ||
(defined($o_stdin) && defined($o_host)) ||
(defined($o_host) && defined($o_cmd))) {
print "Can use only one of -C or -I or -H\n";
@@ -526,14 +526,14 @@ sub check_options {
}
sub parse_filespec {
- my $spec = shift;
+ my $spec = shift;
$spec =~ s/\./\\\./g;
$spec =~ s/\?/\.\?/g;
$spec =~ s/\*/\.\*/g;
return $spec;
}
-# ls -l line example:
+# ls -l line example:
# -rwxr-xr-x 1 WLeibzon users 21747 Apr 20 23:04 check_files.pl
sub parse_lsline {
my @parsed = split (/\s+/, shift);
@@ -546,7 +546,7 @@ sub parse_lsline {
}
else {
$ret{'type'}='file';
- }
+ }
$mod += 400 if $2 =~ /r/;
$mod += 200 if $2 =~ /w/;
$mod += 100 if $2 =~ /x/;
@@ -589,7 +589,7 @@ sub open_shell_stream {
my $shell_command_ref = shift;
my $cd_dir=undef;
my $shell_command=undef;
-
+
if (defined($o_stdin)) {
$shell_command = "<stdin>";
$shell_command_ref = $shell_command if defined($shell_command_ref);
@@ -700,7 +700,7 @@ sub open_shell_stream {
$matched=0;
for (my $i=0; $i<scalar(@o_filesL); $i++) {
if ($ls[$nlines]{'filename'} =~ /$o_filesL[$i]/) {
- $nmatches[$i] = 0 if !defined($nmatches[$i]);
+ $nmatches[$i] = 0 if !defined($nmatches[$i]);
$nmatches[$i]++;
verb(" file matches regex '".$o_filesL[$i]."' for file spec '".$o_filesLv[$i]."'");
$matched=1;
@@ -873,4 +873,4 @@ sub open_shell_stream {
print " |".$perfdata if $perfdata;
print "\n";
-exit $ERRORS{$statuscode};
+exit $ERRORS{$statuscode};
View
22 check_jboss.pl
@@ -53,7 +53,7 @@
# Warning and critical levels are specified with '-w' and '-c' and each
# one must have exact same number of values (separated by ',') as number
# of attribute names specified with '-a'. Any values you dont want
-# to compare you specify as ~ (or just not specify a value, i.e. ',,').
+# to compare you specify as ~ (or just not specify a value, i.e. ',,').
# There are also number of other one-letter modifiers that can be used
# before actual data value to direct how data is to be checked.
# These are as follows:
@@ -78,7 +78,7 @@
# 3. As an option instead of using "twiddle" the data is retrieved
# from JBoss HTTP status/config data.
# 4. Add full "help" output in the "check_help" function
-# 5. [0.2 DONE] Need to change how twiddle its called so that pid of twiddle
+# 5. [0.2 DONE] Need to change how twiddle its called so that pid of twiddle
# process is saved and used to kill that process during timeout
# 6. [0.31 DONE] Added -S parameter to specify JMX service instead of type
# shell is kept and that process can be killed during timeout (otherise
@@ -160,7 +160,7 @@ sub check_options {
'h' => \$o_help, 'help' => \$o_help,
'H:s' => \$o_host, 'hostname:s' => \$o_host,
'J:s' => \$o_jmxmbean, 'jmx_mbean:s' => \$o_jmxmbean,
- 'T:s' => \$o_datatype, 'data_type:s' => \$o_datatype,
+ 'T:s' => \$o_datatype, 'data_type:s' => \$o_datatype,
'S:s' => \$o_servicetype, 'service_type:s' => \$o_servicetype,
't:i' => \$o_timeout, 'timeout:i' => \$o_timeout,
'V' => \$o_version, 'version' => \$o_version,
@@ -190,7 +190,7 @@ sub check_options {
exit $ERRORS{"UNKNOWN"};
}
if (scalar(@o_warnLv)!=scalar(@o_jmxattrL) || scalar(@o_critLv)!=scalar(@o_jmxattrL)) {
- printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number of attributes specified at '-a' (%d). If you need to ignore some attribute do it as ',,'\n", scalar(@o_warnLv), scalar(@o_critLv), scalar(@o_jmxattrL);
+ printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number of attributes specified at '-a' (%d). If you need to ignore some attribute do it as ',,'\n", scalar(@o_warnLv), scalar(@o_critLv), scalar(@o_jmxattrL);
print_usage();
exit $ERRORS{"UNKNOWN"};
}
@@ -255,7 +255,7 @@ sub changedir {
if (!defined($tempdir) || ! -d $tempdir) {
$tempdir="/tmp"
}
- my $cnt=0;
+ my $cnt=0;
my $twextra="";
do {
$twextra="/".$twdir_prefix.$cnt if $cnt!=0;
@@ -271,15 +271,15 @@ sub changedir {
}
else {
print "Unable to find or create directory within $tempdir tree with writable $twlogfile file\n";
- exit $ERRORS{"UNKNOWN"};
+ exit $ERRORS{"UNKNOWN"};
}
}
########## MAIN #######
check_options();
-# Check global timeout if something goes wrong
+# Check global timeout if something goes wrong
if (defined($TIMEOUT)) {
verb("Alarm at $TIMEOUT");
alarm($TIMEOUT);
@@ -307,8 +307,8 @@ sub changedir {
$dataresults{$o_jmxattrL[$i]} = ["check", undef];
}
for ($i=0;$i<scalar(@o_perfattrL);$i++) {
- $twcall .= " $o_perfattrL[$i]" if !defined($dataresults{$o_perfattrL[$i]});
- $dataresults{$o_perfattrL[$i]} = ["perf", undef];
+ $twcall .= " $o_perfattrL[$i]" if !defined($dataresults{$o_perfattrL[$i]});
+ $dataresults{$o_perfattrL[$i]} = ["perf", undef];
}
# here we actually collect the data and put in our hash, very simple actually
@@ -341,7 +341,7 @@ sub changedir {
$statusdata .= "," if ($statusdata);
$statusdata .= " " . $o_jmxattrL[$i] . " is " . $dataresults{$o_jmxattrL[$i]}[1] ;
}
- $perfdata .= " " . $o_jmxattrL[$i] . "=" . $dataresults{$o_jmxattrL[$i]}[1] if defined($o_perf) && $dataresults{$o_jmxattrL[$i]}[0] ne "perf";
+ $perfdata .= " " . $o_jmxattrL[$i] . "=" . $dataresults{$o_jmxattrL[$i]}[1] if defined($o_perf) && $dataresults{$o_jmxattrL[$i]}[0] ne "perf";
}
else {
$statuscode="CRITICAL";
@@ -358,7 +358,7 @@ sub changedir {
print "JBOSS " . $statuscode . $statusinfo;
print " -".$statusdata if $statusdata;
-print " |".$perfdata if $perfdata;
+print " |".$perfdata if $perfdata;
print "\n";
exit $ERRORS{$statuscode};
View
34 check_linux_procstat.pl
@@ -28,20 +28,20 @@
#
# This plugin parses data from /proc/stat on linux system and outputs CPU utilization
# and load data as well as several linux system schedule parameters
-#
+#
# It can be used either directly on the same machine, with check_nrpe or with SNMP,
# either directly or with check_by_snmp, see examples for more information
#
# The plugin outputs lots of useful performance data for graphing and pnp4nagios
# and nagiosgrapher templates are provided for your convinience or NagiosExchange
-#
+#
# ============================= SETUP NOTES ====================================
-#
+#
# To find all available options I recommend you do
# ./check_linux_procstat.pl -help
#
-# Usage: ./check_linux_procstat.pl [-v] [[-P <filename> | -] | [-O oid -H <host> (-C <snmp_community>) [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>) [-p <port>]]] [-w <warn cpu%> -c <crit cpu%>] [-f] [-t <timeout>] [-V] [-N <number of real cpus> [-n <number of cpu cores>]]
-#
+# Usage: ./check_linux_procstat.pl [-v] [[-P <filename> | -] | [-O oid -H <host> (-C <snmp_community>) [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>) [-p <port>]]] [-w <warn cpu%> -c <crit cpu%>] [-f] [-t <timeout>] [-V] [-N <number of real cpus> [-n <number of cpu cores>]]
+#
# In above options (none of which is actually required) mean:
# -w and -c allow to specify cpu threshold above which warning or critical alert is issued
# -N option allows to specify number of real CPUs, this is only used to make nice output
@@ -77,7 +77,7 @@
# define service{
# use prod-service
# hostgroup_name linux
-# service_description Linux CPU Load and System Scheduler
+# service_description Linux CPU Load and System Scheduler
# check_command check_linux_cpustat!75!95
# notification_options c,r
# }
@@ -87,7 +87,7 @@
# exec .1.3.6.1.4.1.2021.201 cpustat /bin/cat /proc/stat
# ----
# in /etc/snmp/snmpd.conf (exact OID is your choice, but don't forget to adjust -O)
-#
+#
# define command {
# command_name check_snmp_linuxcpustat
# command_line $USER1$/check_linux_procstat.pl -O 1.3.6.1.4.1.2021.201 -H $HOSTADDRESS$ -L sha,aes -l $_HOSTSNMP_V3_USER$ -x $_HOSTSNMP_V3_AUTH$ -X $_HOSTSNMP_V3_PRIV$ -f -w $ARG1$ -c $ARG2$
@@ -105,7 +105,7 @@
# command_line $USER1$/check_by_snmp -O 1.3.6.1.4.1.2021.201 -H $HOSTADDRESS$ -L sha,aes -l $_HOSTSNMP_V3_USER$ -x $_HOSTSNMP_V3_AUTH$ -X $_HOSTSNMP_V3_PRIV$ --exec $USER1$/check_linux_procstat.pl -f -w $ARG1$ -c $ARG2$ -P -
# }
#
-# check_by_snmp can be obtained from my site at http://william.leibzon.org/nagios/
+# check_by_snmp can be obtained from my site at http://william.leibzon.org/nagios/
# or from Nagios Exchange and has been written in part based on check_linux_procstat
# in order to allow using this mechanism with other plugins.
#
@@ -117,7 +117,7 @@
#
# And here is an older example (from 2007 on linux 2.4 kernel) with performance data:
# ./check_linux_procstat.pl -f -N 2 -n 4
-# OK - 2 real (4 virtual) CPUs - CPU(all) 47.0% used,
+# OK - 2 real (4 virtual) CPUs - CPU(all) 47.0% used,
# CPU0 49.0% used, CPU1 46.0% used, CPU2 46.0% used, CPU3 45.0% used |
# cpu0_idle=1170345521 cpu0_iowait=1552433 cpu0_irq=6108869 cpu0_nice=2711 cpu0_softirq=24130393
# cpu0_system=675077539 cpu0_used=1149243863 cpu0_user=442374629 cpu1_idle=1232342280 cpu1_iowait=1619125
@@ -185,7 +185,7 @@
eval 'use Net::SNMP';
if ($@) {
$no_snmp=1;
-}
+}
my $procstatfile = "/proc/stat";
my $o_procstat = undef; # option to specify /proc/stat filename
@@ -228,7 +228,7 @@ sub print_usage {
sub isnum { # Return true if arg is a number
my $num = shift;
if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 1 ;}
- return 0;
+ return 0;
}
# returns big integer object from larger number in input string
@@ -241,8 +241,8 @@ sub bint {
sub help {
print "\nLinux /proc/stat Monitor for Nagios version ",$Version,"\n";
print "GPL licence, (c) 2008-2012 William Leibzon\n\n";
- print_usage();
- print <<EOT;
+ print_usage();
+ print <<EOT;
Debug & Console Options:
-v, --verbose
@@ -270,7 +270,7 @@ sub help {
This is good to catch overflow (which did happen in 2.4 kernel and system up > 2 months)
-P, --procstat <filename> | -
By default /proc/stat is read. This allows to modify that and have this plugin read
- specified file or get data from stdin if instead of file name - is specified
+ specified file or get data from stdin if instead of file name - is specified
This can not be combined with SNMP options below.
SNMP Access Options (if none of these are specified, local system is checked):
@@ -368,7 +368,7 @@ sub check_options {
}
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd)) )
{ print "Put snmp login info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}
- }
+ }
else {
if (defined($o_host) || defined($o_community)) {
print "You specified hostname or community but not SNMP OID string\n";
@@ -389,7 +389,7 @@ sub check_options {
print_usage();
exit $ERRORS{"UNKNOWN"};
}
- # I still have one old install using -Y
+ # I still have one old install using -Y
if (defined($o_realcpus) && !defined($o_virtcpus) && defined($o_hyper)) {
$o_virtcpus=2*$o_realcpus;
}
@@ -590,7 +590,7 @@ sub snmp_session {
}
}
-# page and swap data is not present in many systems
+# page and swap data is not present in many systems
$stats{"data_paged_out"} = 0 if defined($stats{"data_paged_in"});
$stats{"swap_paged_out"} = 0 if defined($stats{"swap_paged_in"});
View
2 check_localtime.pl
@@ -55,7 +55,7 @@
# }
#
# =================================== TODO ===================================
-#
+#
# 1. Currently accepts fixed format parameters "hour:minute-hour:minute".
# It maybe interesting to extend for example to specify day of the week
# to allow for one CRITICAL period during the week...
View
84 check_memcached.pl
@@ -61,7 +61,7 @@
# Plugin currently does not support authentication so the only connection
# parameters are "-H hostname" and "-p port". The default port is 11211
# and you must specify the hostname (if localhost specify it as -H 127.0.0.1)
-#
+#
# 2. Response Time, HitRate, Memory Utilization
#
# To get response time you use "-T" or "--response_time" option. By itself
@@ -74,7 +74,7 @@
# and previous performance data is feed back, the data is based on real
# hitrate with lifelong info also given in paramphesis. As with -T you
# can specify -R by itself or with thresholds as -R warn,crit
-#
+#
# Memory utilization corresponds to what some others call "size". This is
# percent of max memory currently in use. The option is -U or --utilization
# and as you probably guessed can be used by itself or as -U warn,crit
@@ -136,12 +136,12 @@
#
# 4. Memcache Statistics Variables and Calculating their Rate of Change
#
-# All statistics variables from memcached 'stats' can be checked with the plugin.
-# And as some people know there are actually several stats arrays in memcached.
+# All statistics variables from memcached 'stats' can be checked with the plugin.
+# And as some people know there are actually several stats arrays in memcached.
# By default the plugin will get statistics for 'misc' and 'malloc'. You can
# specify a list of statistics array names (corresponding to 'stats name'
# command in memcached) with -s or --stats command. Known arrays are:
-# misc, malloc, sizes, maps, cachedump, slabs, items
+# misc, malloc, sizes, maps, cachedump, slabs, items
# And example of trying to retrieve all of them is:
# -s misc,malloc,sizes,maps,cachedump,slabs,items
# However not all of them will have data in your system and arrays like
@@ -151,7 +151,7 @@
# To see stat variables in plugin status output line and or specify thresholds
# based on their values you would use -a or --variables argument. For example:
# -a curr_connections,evictions
-# You must specify same number of warning and critical thresholds with
+# You must specify same number of warning and critical thresholds with
# -w or --warn and -c or --crit argument as a number of variables specified
# in -a. If you simply want variable values on status without checking their value
# then either use ~ in place of threshold value or nothing at all. For example:
@@ -166,7 +166,7 @@
# is a format used internally by plugin. As an alternative you can specify how to
# label these with --rate_label option where you can specify prefix and/or suffix.
# For example '--rate_label=dt_' would have the output being "dt_total_connections'
-# where as '---rate_label=,_rate' is plugin default giving 'total_connections_rate'.
+# where as '---rate_label=,_rate' is plugin default giving 'total_connections_rate'.
# You can use these names with -a and -A such as:
# --rate_label=,_rate -a total_connections_rate -w 1000 -c ~
#
@@ -176,7 +176,7 @@
# In commands.cfg this would be specified as:
# -P "$SERVICEPERFDATA$"
# And don't forget the quotes, in this case they are not just for documentation.
-#
+#
# 5. Threshold Specification
#
# The plugin fully supports Nagios plug-in specification for specifying thresholds:
@@ -191,7 +191,7 @@
# There are two two specifications of range formats as with other nagios plugins:
# number1:number2 issue alert if data is OUTSIDE of range [number1..number2]
# i.e. alert if data<$number1 or data>$number2
-# @number1:number2 issue alert if data is WITHIN range [number1..number2]
+# @number1:number2 issue alert if data is WITHIN range [number1..number2]
# i.e. alert if data>=$number and $data<=$number2
#
# The plugin will attempt to check that WARNING values is less than CRITICAL
@@ -220,7 +220,7 @@
# find at the top of the code (further below) and plugin author does not claim
# to have identified all variables correctly. Please email if you find an error
# or want to add more variables.
-#
+#
# As noted above performance data is also used to calcualte rate of change
# by feeding it back with -P option. In that regard even if you did not specify
# -f or -A but you have specified &variable, its actual data would be sent out
@@ -268,7 +268,7 @@
#
# In above the -v option means "verbose" and with it plugin will output some debugging
# information about what it is doing. The option is not intended to be used when plugin
-# is called from nagios itself.
+# is called from nagios itself.
#
# ======================= VERSION HISTORY and TODO ================================
#
@@ -295,7 +295,7 @@
# [0.63 - Jun 10 2012] Documentation fixes.
# Default rate variable name changed from &Delta_variable to
# variable_rate to be in sync with check_redis.pl. One of the reasons
-# is that in the future I'll plan to add variables that are real
+# is that in the future I'll plan to add variables that are real
# delta i.e new_value-old_value and not (new_value-old_value)/time
# Also I've decided that specifying prefix & suffix or rate label
# variables will not be one-letter option and only long-name option
@@ -332,7 +332,7 @@
# These would mean you specify '--connected_clients' in similar way to '--hitrate'
# Internally these would be convered into -A, -w, -c as appropriate an used
# together with these options. So in practice it will now allow to get any data
-# just a different way to specify options for this plugin.
+# just a different way to specify options for this plugin.
# (c) Allow regex when selecting variable name(s) with -a, this will be enabled with
# a special option and not be default
# [DONE]
@@ -345,7 +345,7 @@
# be implimented by allowing regex checks in place of specific variable name.
# [DONE]
#
-# Others are welcome recommand a new feature to be added here. If so please email to
+# Others are welcome recommand a new feature to be added here. If so please email to
# william@leibzon.org.
# And don't worry, I'm not a company with some hidden agenda to use your idea
# but an actual person who you can easily get hold of by email, find on forums
@@ -421,7 +421,7 @@
'pid' => [ 'misc', 'STATUSINFO', '' ],
);
-# Here you can also specify which variables should go into perf data,
+# Here you can also specify which variables should go into perf data,
# For right now it is 'GAUGE', 'COUNTER', 'DATA' (but not 'TEXTDATA'), and 'BOOLEAN'
# you may want to remove BOOLEAN if you don't want too much data
my $PERF_OK_STATUS_REGEX = 'GAUGE|COUNTER|^DATA$|BOOLEAN';
@@ -441,7 +441,7 @@
my @o_check= (); # General check option that maybe repeated more than once
my $o_timeout= undef; # Timeout to use - note that normally timeout is take from nagios anyway
my $o_mdsopt= undef; # Stat List to get data for
-my @o_mdslist= ('misc','malloc'); # Default List, if -S option is entered, this is replaced
+my @o_mdslist= ('misc','malloc'); # Default List, if -S option is entered, this is replaced
my $o_timecheck=undef; # threshold spec for connection time
my $o_hitrate= undef; # threshold spec for hitrate%
my $o_utilsize= undef; # threshold spec for utilization%
@@ -564,15 +564,15 @@ sub help {
Measured/Calculated Data:
-T, --response_time=[WARN,CRIT]
- If this is used as just -T the plugin will measure and output connection
+ If this is used as just -T the plugin will measure and output connection
response time in seconds. With -f this would also be provided on perf variables.
You can also specify values for this parameter, these are interprted as
- WARNING and CRITICAL thresholds (separated by ',').
+ WARNING and CRITICAL thresholds (separated by ',').
-R, --hitrate=[WARN,CRIT]
Calculates Hitrate %: cache_miss/(cache_hits+cache_miss). If this is used
as just -R then this info just goes to output line. With '-R -f' these
go as performance data. You can also specify values for this parameter,
- these are interprted as WARNING and CRITICAL thresholds (separated by ',').
+ these are interprted as WARNING and CRITICAL thresholds (separated by ',').
The format for WARN and CRIT is same as what you would use in -w and -c.
-U, --utilization=[WARN,CRIT]
This calculates percent of space in use, which is bytes/limit_maxbytes
@@ -607,7 +607,7 @@ sub help {
# Licence : LGPL - full text at http://www.fsf.org/licenses/lgpl.txt
#
# ============================= LIBRARY HISTORY AND VERSIONS ====================================
-#
+#
# Note: you may safely skip this section if you're looking at documentation about this library or plugin
#
# [2006-2008] The history of this library goes back to plugins such as check_snmp_temperature.pl,
@@ -616,7 +616,7 @@ sub help {
# these thresholds. Several of my plugins had common architecture supporting multiple
# variables or attributes to be checked using -a/--attributes/--variables option and
# --warn and --crit options with list of thresholds for these attributes and --perfvars
-# specifying variables whose data would only go as PERFOUT for graphing.
+# specifying variables whose data would only go as PERFOUT for graphing.
#
# [2008-2011] Threshold parsing and check code had been rewritten and support added for specifying
# range per plugin guidelines: http://nagiosplug.sourceforge.net/developer-guidelines.html
@@ -884,7 +884,7 @@ sub uptime_info {
$upinfo .= "$days days" if $days>0;
$upinfo .= (($upinfo ne '')?' ':'').$hrs." hours" if $hrs>0;
$upinfo .= (($upinfo ne '')?' ':'').$mins." minutes" if $mins>0 && ($days==0 || $hrs==0);
- $upinfo .= (($upinfo ne '')?' ':'').$secs." seconds" if $secs>0 && $days==0 && $hrs==0;
+ $upinfo .= (($upinfo ne '')?' ':'').$secs." seconds" if $secs>0 && $days==0 && $hrs==0;
return $upinfo;
}
@@ -899,7 +899,7 @@ sub verb {
if (defined($o_verb) || (defined($self) && defined($self->{'verbose'}) && $self->{'verbose'} ne 0)) {
$debug_file_name = $self->{'debug_file'} if defined($self) && $self->{'debug_file'} ne "";
- $debug_file_name = $self->{'verbose'} if $debug_file_name ne "" && defined($self) &&
+ $debug_file_name = $self->{'verbose'} if $debug_file_name ne "" && defined($self) &&
($self->{'verbose'} ne 0 && $self->{'verbose'} ne 1 && $self->{'verbose'} ne '');
$debug_file_name = $o_verb if $debug_file_name ne "" && defined($o_verb) && $o_verb ne "";
if ($debug_file_name ne "") {
@@ -1276,7 +1276,7 @@ sub check_threshold {
$issymb = 0 if defined($self) && $self->{'output_comparison_symbols'} eq 0;
# verb("debug check_threshold: $mod : ".(defined($lv1)?$lv1:'')." : ".(defined($lv2)?$lv2:''));
- return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
+ return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
return " " . $attrib . " is " . $data . ( ($issymb==1)?' = ':' equal to ' ). $lv1 if $mod eq '=' && $data eq $lv1;
return " " . $attrib . " is " . $data . ( ($issymb==1)?' != ':' not equal to ' ). $lv1 if $mod eq '!' && $data ne $lv1;
return " " . $attrib . " is " . $data . ( ($issymb==1)?' > ':' more than ' ) . $lv1 if $mod eq '>' && $data>$lv1;
@@ -1308,7 +1308,7 @@ sub parse_threshold {
# link to an array that holds processed threshold data
# array: 1st is type of check, 2nd is threshold value or value1 in range, 3rd is value2 in range,
# 4th is extra options such as ^, 5th is nagios spec string representation for perf out
- my $th_array = [ '', undef, undef, '', '' ];
+ my $th_array = [ '', undef, undef, '', '' ];
my $th = $thin;
my $at = '';
@@ -1375,7 +1375,7 @@ sub threshold_specok {
return 1 if defined($warn_thar) && defined($warn_thar->[1]) &&
defined($crit_thar) && defined($crit_thar->[1]) &&
isnum($warn_thar->[1]) && isnum($crit_thar->[1]) &&
- $warn_thar->[0] eq $crit_thar->[0] &&
+ $warn_thar->[0] eq $crit_thar->[0] &&
(!defined($warn_thar->[3]) || $warn_thar->[3] !~ /\^/) &&
(!defined($crit_thar->[3]) || $crit_thar->[3] !~ /\^/) &&
(($warn_thar->[1]>$crit_thar->[1] && ($warn_thar->[0] =~ />/ || $warn_thar->[0] eq '@')) ||
@@ -1489,7 +1489,7 @@ sub vardata {
# SAVED:YES|NO - put results in saved data (this really should not be set manually)
# PATTERN:<regex> - enables regex match allowing more than one real data name to match this threshold
# NAME:<string> - overrides output status and perf name for this variable
-# UOM:<string> - unit of measurement symbol to add to perf
+# UOM:<string> - unit of measurement symbol to add to perf
# @RETURNS : Returns reference to a hash array, a library's structure for holding processed MULTI-THRESHOLD spec
# Note that this is MULTI-THRESHOLD hash structure, it itself contains threshold hashes returned by parse_threshold()
# @PRIVACY & USE : PUBLIC, but its use is discouraged. Maybe used directly or as an object instance function.
@@ -1508,7 +1508,7 @@ sub parse_thresholds_list {
$t !~ /^PATTERN/ && $t !~ /^NAME/ && $t !~ /^UOM/) {
if (scalar(@tin)==2) {
if (defined($self)) {
- $thres->{'WARN'} = $self->parse_threshold($tin[0]);
+ $thres->{'WARN'} = $self->parse_threshold($tin[0]);
$thres->{'CRIT'} = $self->parse_threshold($tin[1]);
}
else {
@@ -1721,7 +1721,7 @@ sub additional_options_list {
push @VarOptions,$v."=s";
if ($self->{'enable_rate_of_change'} eq 1 && $known_vars->{$v}[1] eq 'COUNTER' && ($o_rprefix ne '' || $o_rsuffix ne '')) {
$v2 = $o_rprefix.$v.$o_rsuffix;
- push @VarOptions,$v2."=s"
+ push @VarOptions,$v2."=s"
}
}
}
@@ -1835,7 +1835,7 @@ sub options_startprocessing {
for (my $i=0; $i<scalar(@{$perfVars}); $i++) {
$perfVars->[$i] = '&'.$1 if $perfVars->[$i] =~ /^$o_rprefix(.*)$o_rsuffix$/;
}
- }
+ }
}
if (defined($o_warn) || defined($o_crit) || defined($o_variables)) {
if (defined($o_variables)) {
@@ -1893,7 +1893,7 @@ sub _options_setthresholds {
$o_rsuffix = $self->{'o_rsuffix'} if exists($self->{'o_rsuffix'});
if (scalar(@{$ar_warnLv})!=scalar(@{$ar_varsL}) || scalar(@{$ar_critLv})!=scalar(@{$ar_varsL})) {
- printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number of attributes specified at '-a' (%d). If you need to ignore some attribute do it as ',,'\n", scalar(@{$ar_warnLv}), scalar(@{$ar_critLv}), scalar(@{$ar_varsL});
+ printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number of attributes specified at '-a' (%d). If you need to ignore some attribute do it as ',,'\n", scalar(@{$ar_warnLv}), scalar(@{$ar_critLv}), scalar(@{$ar_varsL});
$self->verb("Warning Levels: ".join(",",@{$ar_warnLv}));
$self->verb("Critical Levels: ".join(",",@{$ar_critLv}));
if (defined($self)) { $self->usage(); }
@@ -2064,7 +2064,7 @@ sub set_statuscode {
# @DESCRIPTION : This function is called closer to end of the code after plugin retrieved data and
# assigned values to variables. This function checks variables against all thresholds.
-# It prepares statusdata and statusinfo and exitcode.
+# It prepares statusdata and statusinfo and exitcode.
# @LAST CHANGED : 09-03-12 by WL
# @INPUT : none
# @RETURNS : nothing (future: 1 on success, 0 on error)
@@ -2126,7 +2126,7 @@ sub main_checkvars {
$self->addto_statusdata_output($dvar,$aname." is ".$dataresults->{$dvar}[0]);
# if we were asked to output performance, prepare it but do not output until later
- if ((defined($self->{'o_perf'}) && defined($avar) && !exists($thresholds->{$avar}{'PERF'})) ||
+ if ((defined($self->{'o_perf'}) && defined($avar) && !exists($thresholds->{$avar}{'PERF'})) ||
(exists($thresholds->{$avar}{'PERF'}) && $thresholds->{$avar}{'PERF'} eq 'YES')) {
$perf_str = perf_name($aname).'='.$dataresults->{$dvar}[0];
$self->set_perfdata($dvar, $perf_str, undef, "IFNOTSET"); # with undef UOM would get added
@@ -2182,7 +2182,7 @@ sub main_perfvars {
}
else {
$self->verb(" -- not adding to perfdata because of it is '".$known_vars->{$avar}[1]."' type variable --");
- }
+ }
}
else {
$self->verb("Perfvar: $avar selected for PERFOUT but data not defined");
@@ -2273,7 +2273,7 @@ sub check_options {
my $nlib = shift;
my %Options = ();
Getopt::Long::Configure("bundling");
- GetOptions(\%Options,
+ GetOptions(\%Options,
'v:s' => \$o_verb, 'verbose:s' => \$o_verb, "debug:s" => \$o_verb,
'h' => \$o_help, 'help' => \$o_help,
'H:s' => \$o_host, 'hostname:s' => \$o_host,
@@ -2303,7 +2303,7 @@ sub check_options {
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} };
# access/connection options
- if (!defined($o_host)) { print "Please specify hostname (-H)\n"; print_usage(); exit $ERRORS{"UNKNOWN"}; }
+ if (!defined($o_host)) { print "Please specify hostname (-H)\n"; print_usage(); exit $ERRORS{"UNKNOWN"}; }
@o_mdslist=split(/,/, lc $o_mdsopt) if defined($o_mdsopt) && $o_mdsopt ne '';
# now start options processing in the library
@@ -2380,17 +2380,17 @@ sub check_options {
my $start_time;
my $dsn = $HOSTNAME.":".$PORT;
-$nlib->verb("connecting to $dsn");
+$nlib->verb("connecting to $dsn");
$start_time = [ Time::HiRes::gettimeofday() ] if defined($o_timecheck);
$memd = new Cache::Memcached { 'servers' => [ $dsn ] };
if (!$memd) {
- print "CRITICAL ERROR - Memcache error connecting to '$HOSTNAME' on port $PORT\n";
+ print "CRITICAL ERROR - Memcache error connecting to '$HOSTNAME' on port $PORT\n";
exit $ERRORS{'CRITICAL'};
}
# This returns hashref of various statistics data on memcached
-# Basically results of 'stats', 'stats malloc', 'stats sizes', etc.
+# Basically results of 'stats', 'stats malloc', 'stats sizes', etc.
$nlib->verb("Requesting statistics on: ".join(',',@o_mdslist));
my $stats = $memd->stats(\@o_mdslist);
@@ -2435,7 +2435,7 @@ sub check_options {
else {
$vval = $stats->{'hosts'}{$dsn}{$vstat};
chop($vval);
- my @lines = split("\n",$vval);
+ my @lines = split("\n",$vval);
my $count=0;
foreach my $ln (@lines) {
$count++;
@@ -2449,10 +2449,10 @@ sub check_options {
$dnam = $vstat."_".$count;
$vval = $ln;
$vval =~ s/\s/_/g;
- }
+ }
$nlib->verb("Stats Data: $vstat($dnam) = $vval");
$nlib->add_data($dnam, $vval);
- }
+ }
}
}
}
View
52 check_mysqld.pl
@@ -57,15 +57,15 @@
# this plugin if new version comes out and remember to not have read-all
# unix permissions which is default.
# 3. Specify login credentials in [client] section of my.cnf file and use
-# -F option. You can use common user/pass in each file and specify
+# -F option. You can use common user/pass in each file and specify
# host with -H or may even decide to use different files for each host
# being checked specifying this command like this:
# define command{
# command_name check_mysqld
# command_line $USER1$/check_mysqld.pl -F /path/to/configs/my_$HOSTADDRESS$.cfg -T -a uptime,threads_connected,questions,slow_queries,open_tables -w ",,,," -c ",,,,"
# }
-#
-# The attributes/parameters checked are mysql internal variables retuned from
+#
+# The attributes/parameters checked are mysql internal variables retuned from
# "SHOW STATUS" or "SHOW GLOBAL STATUS" (which one depends on mysql version).
# For each attribute to be checked which you specify in '-a' you must
# also specify warning and critical threshold value in the same order
@@ -79,7 +79,7 @@
# Warning and critical thresholds are specified with '-w' and '-c' and each
# one must have exact same number of values to be checked (separated by ',')
# as number of variables specified with '-a'. Any values you dont want to
-# compare you specify as ~ (or just not specify a value, i.e. ',,').
+# compare you specify as ~ (or just not specify a value, i.e. ',,').
#
# There are also number of other one-letter modifiers that can be used
# as prefix before actual data value to direct how data is to be checked.
@@ -92,7 +92,7 @@
# Additionally supported are two specifications of range formats:
# number1:number2 issue alert if data is OUTSIDE of range [number1..number2]
# i.e. alert if data<$number1 or data>$number2
-# @number1:number2 issue alert if data is WITHIN range [number1..number2]
+# @number1:number2 issue alert if data is WITHIN range [number1..number2]
# i.e. alert if data>=$number and $data<=$number2
#
# A special modifier '^' can also be used to disable checking that warn values
@@ -101,18 +101,18 @@
# warning alert if value is < 100 and critical alert if its greater then 200.
#
# You can specify more then one type of threshold for the same variable -
-# simply repeat the variable more then once in the list in '-a'
+# simply repeat the variable more then once in the list in '-a'
#
# --------------------------------------------------------------------------
#
# If you're using version 5.02 or newer of mysql server then this plugin
# will do "SHOW GLOBAL STATUS" rather than "SHOW STATUS". For more information
-# on differences see:
+# on differences see:
# http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
#
# Note that it maybe the case that you do actually want "SHOW STATUS" even with
# mysqld 5.0.2, then specify query line with '-q' option like
-# ./check_mysqld.pl -p foo -f -u nagios -A uptime,threads_connected,slow_queries,open_tables -H nagios -q 'SHOW STATUS'
+# ./check_mysqld.pl -p foo -f -u nagios -A uptime,threads_connected,slow_queries,open_tables -H nagios -q 'SHOW STATUS'
#
# Sample command and service definitions:
#
@@ -146,28 +146,28 @@
# [0.7 - May 2006] First public release. Very limited threshold specification.
# [0.8 - Dec 2007] Update to my latest format & code for parsing
# warning & critical parameters so they can be of the form
-# "<value" (alert if value is less then specified),
+# "<value" (alert if value is less then specified),
# ">value" (alert if its greatr then specified, default)
# as well as "1,~,1" or '1,,1' (ignore 2nd)
# Note: for backward compatibility specifying '0' for threshold is
# more or less same as '~', if you really want 0 then prefix
-# it with '<' or '>' or '=' to force the check
+# it with '<' or '>' or '=' to force the check
# Number of other code cleanup and fixes. This includes allowing
# more then one threshold for same variable (repeat the variable in
# the list of variables with 'a') but making sure that in performance
-# variables its listed only once and in proper order.
-# [0.85 - Dec 2007] Thanks to the suggestion by Mike Lykov plugin can now do
+# variables its listed only once and in proper order.
+# [0.85 - Dec 2007] Thanks to the suggestion by Mike Lykov plugin can now do
# 'SHOW GLOBAL STATUS' since mysqld newer then 5.0.2
# will only report one session data in 'SHOW STATUS'. Also in
# part to allow override default behavior (choosing which SHOW
# to do) and to extend plugin functionality a new option '-q'
# is added that allows to specify which query to execute. This
-# will let plugin be used with others types of mysql 'SHOW' commands
+# will let plugin be used with others types of mysql 'SHOW' commands
# [0.851 - Dec 2007] Fixed bug: -t (timeout) parameter was ignored before
# [0.9 - Jan 2008] Threshold parsing and check code has been rewritten and now
# supports ranges in similar way to nagios plugin specification.
# [0.901 - Jan 2008] Added forced closing of db connection at alarm
-# [0.902 - Jan 2008] Bug fixed in comparison of non-numeric data
+# [0.902 - Jan 2008] Bug fixed in comparison of non-numeric data
# [0.91 - Dec 2011] Bug fixes. If unable to connect check if TCP port is even open
# [0.92 - Feb 2012] Patch by Diego Salvi to add -F option that allows to use
# mysql configuration file for login credentials
@@ -228,9 +228,9 @@
my $o_perfvars= undef; # list of variables to include in perfomance data
my @o_perfvarsL=(); # array from above list
my $o_warn= undef; # warning level option
-my @o_warnL= (); # array of warn data processing threshold
+my @o_warnL= (); # array of warn data processing threshold
my $o_crit= undef; # Critical level option
-my @o_critL= (); # array of critical data processing thresholds
+my @o_critL= (); # array of critical data processing thresholds
my $o_perf= undef; # Performance data option
my $o_timeout= undef; # Timeout to use - note that normally timeout is take from nagios anyway
my $o_replication=undef; # Normal replication status value, if something else then you'll see CRITICAL error
@@ -286,10 +286,10 @@ sub help {
-q, --query=STRING
Specify query to do instead of 'SHOW STATUS'. This is useful to check
some other specialized mysql commands and tables. In order to work
- returned data should be similar to one from "SHOW STATUS", i.e.
+ returned data should be similar to one from "SHOW STATUS", i.e.
table with two columns.
-a, --variables=STRING,[STRING,[STRING...]]
- List of variables as found in 'SHOW STATUS' which should be monitored.
+ List of variables as found in 'SHOW STATUS' which should be monitored.
The list can be arbitrarily long and the default (if option is not used)
is not to monitor any variable. You can repeat same variable if you need
it checked for both below and above thresholds.
@@ -317,7 +317,7 @@ sub help {
-s, --slave=status
If slave status (normally it is 'OFF') is anything other then what is
specified with, then CRITICAL alert would be sent. This can also be done
- with '=' option so seperate option is kept for backward compatibility
+ with '=' option so seperate option is kept for backward compatibility
-r, --replication=status
If replication status (normally it is NULL) is anything other then what
is specified with this option, then CRITICAL alert would be sent.
@@ -360,7 +360,7 @@ sub check_threshold {
my $lv2 = $th_array->[2];
# verb("debug check_threshold: $mod : ".(defined($lv1)?$lv1:'')." : ".(defined($lv2)?$lv2:''));
- return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
+ return "" if !defined($lv1) || ($mod eq '' && $lv1 eq '');
return " " . $attrib . " is " . $data . " = " . $lv1 if $mod eq '=' && $data eq $lv1;
return " " . $attrib . " is " . $data . " != " . $lv1 if $mod eq '!' && $data ne $lv1;
return " " . $attrib . " is " . $data . " > " . $lv1 if $mod eq '>' && $data>$lv1;
@@ -378,7 +378,7 @@ sub parse_threshold {
# link to an array that holds processed threshold data
# array: 1st is type of check, 2nd is value2, 3rd is value2, 4th is option, 5th is nagios spec string representation for perf out
- my $th_array = [ '', undef, undef, '', '' ];
+ my $th_array = [ '', undef, undef, '', '' ];
my $th = $thin;
my $at = '';
@@ -508,11 +508,11 @@ sub check_options {
exit $ERRORS{"UNKNOWN"};
}
unshift(@o_varsL,"connection_time");
- unshift(@ar_warnLv,$o_timeth[0]);
+ unshift(@ar_warnLv,$o_timeth[0]);
unshift(@ar_critLv,$o_timeth[1]);
}
if (scalar(@ar_warnLv)!=scalar(@o_varsL) || scalar(@ar_critLv)!=scalar(@o_varsL)) {
- printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number of attributes specified at '-a' (%d). If you need to ignore some attribute do it as ',,'\n", scalar(@ar_warnLv), scalar(@ar_critLv), scalar(@o_varsL);
+ printf "Number of specified warning levels (%d) and critical levels (%d) must be equal to the number of attributes specified at '-a' (%d). If you need to ignore some attribute do it as ',,'\n", scalar(@ar_warnLv), scalar(@ar_critLv), scalar(@o_varsL);
verb("Warning Levels: ".join(",",@ar_warnLv));
verb("Critical Levels: ".join(",",@ar_critLv));
print_usage();
@@ -590,7 +590,7 @@ sub check_options {
$dsn.=":port=$PORT" if $PORT;
$dsn.=";mysql_read_default_file=$MY_CNF" if $MY_CNF;
-verb("connecting using credentials specified in $MY_CNF file") if $MY_CNF;
+verb("connecting using credentials specified in $MY_CNF file") if $MY_CNF;
my $vstr = "connecting";
$vstr .= " to database '".$DATABASE."'" if $DATABASE;
$vstr .= " on host '".$HOSTNAME."'" if $HOSTNAME;
@@ -610,7 +610,7 @@ sub check_options {
);
if ($sock) {
close($sock);
- print "CRITICAL ERROR - Unable to connect to database '$DATABASE' on server '$HOSTNAME' on port $PORT with user '$USERNAME' - $DBI::errstr\n";
+ print "CRITICAL ERROR - Unable to connect to database '$DATABASE' on server '$HOSTNAME' on port $PORT with user '$USERNAME' - $DBI::errstr\n";
}
else {
print "CRITICAL ERROR - Can not connect to '$HOSTNAME' on port $PORT\n";
@@ -623,7 +623,7 @@ sub check_options {
}
my $db_command="SELECT VERSION()";
-verb ("Mysql Query: $db_command");
+verb ("Mysql Query: $db_command");
my $sth=$dbh->prepare($db_command);
if (!$sth->execute()) {
print "CRITICAL ERROR - Unable to execute '$db_command' on server '$HOSTNAME' connected as user '$USERNAME' - $DBI::errstr\n";
View
222 check_netint.pl
@@ -14,7 +14,7 @@
# *** IF YOU NEED A STABLE VERSION, PLEASE GET 2.36 VERSION OF THIS PLUGIN ***
# *** AT HTTP://william.leibzon.org/nagios/ or http://exchange.nagios.org/ ***
# ****************************************************************************
-#
+#
# =========================== PROGRAM LICENSE =================================
#
# This program is free software; you can redistribute it and/or modify
@@ -40,7 +40,7 @@
# cache cisco port names, port link data and switch STP status and more)
# The plugin can use nagios-stored previous performance data to give port
# traffic & utilization without creation of temporary files. This new 2.4
-# version supports checking interface on a local linux server without SNMP.
+# version supports checking interface on a local linux server without SNMP.
#
# ====================== SETUP AND PLUGIN USE NOTES =========================
#
@@ -69,7 +69,7 @@
# as a regular expression (eth will match eth0,eth1,eth2...). You can disable
# this with the -r option : the interface will be selected if it's description
# exactly matches the name given by -n
-#
+#
# The script will return OK if ALL interfaces selected are UP, or CRITICAL
# if at least one interface is down. You can make the script return a OK
# value when all interfaces are down (and CRITICAL when at least one is up)
@@ -79,7 +79,7 @@
#
# To make output shorter, specially when you have many interfaces, you can put
# the -s option. It will get only the first <n> characters of the interface
-# description. If the number is negative then get the last <n> characters.
+# description. If the number is negative then get the last <n> characters.
# Ex : EL20005 3Com Gigabit NIC (3C2000 Family)
# -s 4 will output : "EL20".
# -s -4 will output : "ily)".
@@ -99,12 +99,12 @@
# -d : delta in seconds (default is 300s)
# -w : warning levels
# -c : critical levels
-#
+#
# If you specify '-k' a temporary file will be created in "/tmp" by default
-# (unless -P option is also used, see below). Directory and start of filename
+# (unless -P option is also used, see below). Directory and start of filename
# can be set with '-F' option with result file being like
# tmp_Nagios_int.<host IP>.<Interface name>, one file per interface
-#
+#
# If you do "-k -P \$SERVICEPERFDATA\$ -T \$LASTSERVICECHECK\$" then no file
# is created and instead data from previous check is feed back into plugin.
#
@@ -128,7 +128,7 @@
# -M & -G not set | Kbps | KBps
# -M set | Mbps | MBps
# -G set | Gbps | GBps
-#
+#
# It is possible to put warning and critical levels with -b option.
# 0 means no warning or critical level checks
#
@@ -158,20 +158,20 @@
# Msg size option (-o option)
# In case you get a "ERROR: running table: Message size exceeded maxMsgSize"
# error, you may need to adjust the maxMsgSize, i.e. the maximum size of
-# snmp message with the -o option. Try a value with -o AND the -v option,
+# snmp message with the -o option. Try a value with -o AND the -v option,
# the script will output the actual value so you can add some octets to it
# with the -o option.
#
# --label option
-# This option will put label before performance data value:
+# This option will put label before performance data value:
# Without : eth1:UP (10.3Kbps/4.4Kbps), eth0:UP (10.9Kbps/16.4Kbps):2 UP: OK
# With : eth1:UP (in=14.4Kbps/out=6.2Kbps), eth0:UP (in=15.3Kbps/out=22.9Kbps):2 UP: OK
#
# Note: Do not rely on this option meaning same thing in the future, it may be
# changed to specify label to put prior to plugin output with this
# option changing to something else...
#
-# -----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Below is documentation for options & features unique to check_snmp_netint
# that were not part of check_snmp_int:
#
@@ -194,7 +194,7 @@
# interfaces need to be queried. So no aditional description table
# lookup is necessary. Similarly data for '--cisco' and '--stp'
# maps is also cached and reused. There is only one SNMP query done
-# together for all data OIDs (status & performance data) and
+# together for all data OIDs (status & performance data) and
# for all interfaces; this query also includes query for specific
# description OID (but not reading entire table) which is then
# compared against cached result to make sure ifindex has not changed.
@@ -227,7 +227,7 @@
# If you have only one interface checked with this plugin its probably
# safe to increase this to 3 or 4, but larger values or more interfaces
# are an issue unless you increased size of nagios buffer used to
-# store performance data.
+# store performance data.
#
# III.For those of you with Cisco switches you may have noticed that they
# do not provide appropriate port names at standard SNMP ifdescr table.
@@ -236,11 +236,11 @@
# those names with "--cisco=use_portnames" option.
# 2. Another option is specify custom description table with
# "-N 1.3.6.1.2.1.31.1.1.1.1"
-# and optionally display "set port name" as a comment.
+# and optionally display "set port name" as a comment.
# Its recommended you try both:
# "-N 1.3.6.1.2.1.31.1.1.1.1 --cisco=show_portnames" and
# "-O 1.3.6.1.2.1.31.1.1.1.1 --cisco=use_portnames"
-# and see which works best in your case
+# and see which works best in your case
#
# Additionally when using "--cisco" option the plugin will attempt to
# retrieve port status information from 3 cisco-specific tables (see below).
@@ -256,7 +256,7 @@
# retrieve data from all 3 tables first time (stop with '--cisco=noauto')
# but if you use caching (-m) it will output and cache which table actually
# had usable data and will not attempt to retrieve from tables that did
-# not exist on subsequent calls.
+# not exist on subsequent calls.
#
# IV. Support is also provided to query STP (Spanning Tree Protocol) status
# of the port. Although only tested with cisco switches, this is
@@ -294,7 +294,7 @@
# define command {
# command_name check_snmp_network_interface_linux
# command_line $USER1$/check_snmp_int.pl -2 -f -e -C $USER6$ -H $HOSTADDRESS$
-# -n $ARG1$ -w $ARG2$ -c $ARG3$ -d 200 -q -k -y -M -B
+# -n $ARG1$ -w $ARG2$ -c $ARG3$ -d 200 -q -k -y -M -B
# -m -P "$SERVICEPERFDATA$" -T "$LASTSERVICECHECK$"
# }
# define service{
@@ -313,7 +313,7 @@
# define command {
# command_name check_snmp_network_interface_alteon
# command_line $USER1$/check_snmp_netint.pl -f -C $USER5$ -H $HOSTADDRESS$
-# -N 1.3.6.1.2.1.2.2.1.1 -n $ARG1$ -w $ARG2$ -c $ARG3$ -d 200 -k -y
+# -N 1.3.6.1.2.1.2.2.1.1 -n $ARG1$ -w $ARG2$ -c $ARG3$ -d 200 -k -y
# -M -B -m -P "$SERVICEPERFDATA$" -T "$LASTSERVICECHECK$"
# }
# define service{
@@ -324,7 +324,7 @@
# check_command check_snmp_network_interface_alteon!"257"!0,0!0,0
# }
#
-# Cisco CatOS switch (will work for 5500 and many others), full set of possible options is given:
+# Cisco CatOS switch (will work for 5500 and many others), full set of possible options is given:
# define command {
# command_name check_snmp_network_interface_catos
# command_line $USER1$/check_snmp_netint.pl -2 -f -C $USER5$
@@ -356,7 +356,7 @@
# check_command check_snmp_network_interface_cisco2960!"GigabitEthernet0/1$"!0,0,0,0,0,0!0,0,0,0,0,0
# }
#
-# Other ports on above switches are defined similarly as separate services -
+# Other ports on above switches are defined similarly as separate services -
# you don't have to do it this way though, but all 48 ports is too much for
# one check to handle so if you have that many split checks into groups of
# no more then 12 ports
@@ -381,7 +381,7 @@
# The first changes for performance improvements were started in around
# October 2006 with code base at version 1.4.1 of Patrick's check_snmp_int
# plugin. Patricks's latest code from about May 2007 was ported back into
-# code maintained by WL (exact 1.4.x version of this port is unclear).
+# code maintained by WL (exact 1.4.x version of this port is unclear).
# Those early performance improvement code changes are now invoked with
# 'minimize_queries' (but without -P) option and allow to do query
# for status data for all ports together. Additionally -N option to
@@ -396,7 +396,7 @@
# saving list of ports to check (i.e. result of regex) which means that
# port/interface names table do not need to be checked with SNMP every
# time and instead specific ports OIDs can be retrieved with bulk request
-# (this is what results in up to 75% performance improvement).
+# (this is what results in up to 75% performance improvement).
# About 30-40% of the original code was rewritten for these changes and
# '--minimize_queries' (or '-m') option added - back then it acted more
# like '--minimum_queries' or '-mm' in 2.0 release
@@ -412,7 +412,7 @@
# [1.5.7] 07/22/07 - This is when code to support retrieval of STP data
# and '--stp' option were added. Also some more code cleanup related
# to 1.5.x to better support cisco switches.
-#
+#
# A code from locally maintained but never released to public 1.5.7
# branch was sent by William to Patrick sometime in early August 2007.
# He briefly responded back that he'll look at it later but never
@@ -429,7 +429,7 @@
# [2.0] 12/20/07 - First public release as check_snmp_netint plugin. Primary
# changes from 1.5.7 are the "header" with history and documentation
# which are necessary for such public release, copyright notice changed
-# (W. Leibzon was listed only as contributor before), etc.
+# (W. Leibzon was listed only as contributor before), etc.
#
# [2.1] 12/26/07 - Support for more then one set of previous data in
# performance output to create short history for better bandwidth
@@ -454,7 +454,7 @@
# [2.18] 04/03/08 - Rewrite of cisco additional port status data extensions.
# Now 3 tables: portOperStatus=1.3.6.1.4.1.9.5.1.4.1.1.6
# portLinkFaultStatus = 1.3.6.1.4.1.9.5.1.4.1.1.22
-# portAdditionalOperStatus = 1.3.6.1.4.1.9.5.1.4.1.1.23
+# portAdditionalOperStatus = 1.3.6.1.4.1.9.5.1.4.1.1.23
# are supported but user can specify as option to --cisco= which one
# is to be retrieved. When its not specified the plugin defaults to
# "auto" mode (unless --cisco=noauto is used) and will try to retrieve
@@ -465,7 +465,7 @@
# complex behavior such as this...
# [2.19] 04/06/08 - For STP port changes previous state is now reported in
# the output (instead of just saying STP changed)
-#
+#
# [2.20] 04/10/08 - Releasing 2.2 version as stable. No code changes but
# documentation above has been updated
# [2.201] 04/15/08 - Minor results text info issue (',' was not added before operstatus)
@@ -484,7 +484,7 @@
#
# [2.3] 12/15/10 - Various small fixes. Plus a patch sent by Tristan Horn to better
# support minimum and maximum warning and critical thresholds
-# [2.31] 01/10/11 - Bug fix when reporting in_prct/out_prct performance metric
+# [2.31] 01/10/11 - Bug fix when reporting in_prct/out_prct performance metric
# [2.32] 12/22/11 - Fixes for bugs reported by Joe Trungale and Nicolas Parpandet
# Updates to check on existance of utils.pm and use but not require it
# Patch by Steve Hanselman that adds "-I" option:
@@ -522,7 +522,7 @@
#
# Specific info on each alpha/beta release will be removed in the future and only
# summary of below will appear in documentation on features and updated in 2.4 release
-#
+#
# 2.4a1 - 07/07/12 - Implemented in this release:
# 1) The plugin has been renamed "check_netint" from "check_snmp_netint".
# It can now check interfaces on a local Linux system and in the
@@ -608,7 +608,7 @@
$do_snmp=0;
}
-# Version
+# Version
my $Version='2.4';
############### BASE DIRECTORY FOR TEMP FILE (override this with -F) ########
@@ -656,7 +656,7 @@
# Standard options
my $o_host = undef; # hostname
-my $o_timeout= undef; # Timeout (Default 10)
+my $o_timeout= undef; # Timeout (Default 10)
my $o_descr = undef; # description filter
my $o_help= undef; # wan't some help ?
my $o_admin= undef; # admin status instead of oper
@@ -679,7 +679,7 @@
my @o_crit_max= undef; # critical levels of perfcheck
my $o_checkperf= undef; # checks in/out/err/disc values
my $o_delta= 300; # delta of time of perfcheck (default 5min)
-my $o_ext_checkperf= undef; # extended perf checks (+error+discard)
+my $o_ext_checkperf= undef; # extended perf checks (+error+discard)
my $o_highperf= undef; # Use 64 bits counters
my $o_meg= undef; # output in MBytes or Mbits (-M)
my $o_gig= undef; # output in GBytes or Gbits (-G)
@@ -706,7 +706,7 @@
# WL: These are for previous performance data that nagios can send data to the plugin
# with $SERVICEPERFDATA$ macro (and $SERVICESAVEDDATA$ for future naios versions).
# This allows to calculate traffic without temporary file and also used to cache
-# SNMP table info so as not to retreive it every time
+# SNMP table info so as not to retreive it every time
my $o_prevperf= undef; # performance data given with $SERVICEPERFDATA$ macro
my $o_prevtime= undef; # previous time plugin was run $LASTSERVICECHECK$ macro
my @o_minsnmp= (); # see below
@@ -762,34 +762,34 @@
my $saved_out=''; # saved data accumulator (added to perf)
# Functions
-sub read_file {
+sub read_file {
# Input : File, items_number
- # Returns : array of value : [line][item]
+ # Returns : array of value : [line][item]
my ($traffic_file,$items_number)=@_;
- my ($ligne,$n_rows)=(undef,0);
+ my ($ligne,$n_rows)=(undef,0);
my (@last_values,@file_values,$i);
- open(FILE,"<".$traffic_file) || return (1,0,0);
-
+ open(FILE,"<".$traffic_file) || return (1,0,0);
+
while($ligne = <FILE>)
{
chomp($ligne);
@file_values = split(":",$ligne);
#verb("@file_values");
- if ($#file_values >= ($items_number-1)) {
+ if ($#file_values >= ($items_number-1)) {
# check if there is enough data, else ignore line
for ( $i=0 ; $i< $items_number ; $i++ ) {$last_values[$n_rows][$i]=$file_values[$i];}
$n_rows++;
- }
+ }
}
close FILE;
- if ($n_rows != 0) {
+ if ($n_rows != 0) {
return (0,$n_rows,@last_values);
} else {
return (1,0,0);
}
}
-sub write_file {
+sub write_file {
# Input : file , rows, items, array of value : [line][item]
# Returns : 0 / OK, 1 / error
my ($file_out,$rows,$item,@file_values)=@_;
@@ -885,10 +885,10 @@ sub help {
then instead of overriding it would issue a critical alert if speed is not
the same (CRITICAL<> behavior). You must specify alert type before speed now.
-y, --perfprct ; -Y, --perfspeed ; -Z, --perfoctet
- -y : output performance data in % of max speed
+ -y : output performance data in % of max speed
-Y : output performance data in bits/s or Bytes/s (depending on -B)
-Z : output performance data in octets i.e. bytes (always so with -P)
--k, --perfcheck ; -q, --extperfcheck
+-k, --perfcheck ; -q, --extperfcheck
-k check the input/ouput bandwidth of the interface
-q also check the error and discard input/output
--label
@@ -924,7 +924,7 @@ sub help {
This is used with -P and is a previous time plugin data was obtained,
use it as '-T \$LASTSERVICECHECK\$'. This is now optional as plugin
will also save time as part of performance variables and get it with -P
---pcount=INTEGER
+--pcount=INTEGER
Default: 2
How many sets of previus data to keep as performance data. By keeping
at least couple sets allows for more realistic and less 'bursty' results
@@ -939,11 +939,11 @@ sub help {
later then this value, it'll discard all previous performance data
and start calculation again next time it is run.
-F, --filestore[=<filename>|<directory>]
- When you use -P option that causes plugin to use previous performance data
+ When you use -P option that causes plugin to use previous performance data
that is passed as an argument to plugin to calculate in/out bandwidth
instead of storing data in temporary file. This option is an alternative
to -P and causes results of previous check to be saved in a file.
- If this option has a parameter and it is a directory, then temporary
+ If this option has a parameter and it is a directory, then temporary
file will be saved in this directory, otherwise /tmp is used.
If parameter is a filename then it is used as a first part in
how temporary file is named.
@@ -961,19 +961,19 @@ sub help {
-2, --v2c
use snmp v2c (can not be used with -l, -x)
-l, --login=LOGIN ; -x, --passwd=PASSWD
- Login and auth password for snmpv3 authentication
- If no priv password exists, implies AuthNoPriv
+ Login and auth password for snmpv3 authentication
+ If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>