Skip to content

Commit

Permalink
whitespace only: Remove trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Cook committed Apr 29, 2013
1 parent 9d001eb commit acf7d87
Show file tree
Hide file tree
Showing 32 changed files with 602 additions and 602 deletions.
36 changes: 18 additions & 18 deletions Naglio.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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 "<", ">", "="
Expand Down Expand Up @@ -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);
Expand All @@ -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 "") {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 = '';

Expand Down Expand Up @@ -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 '@')) ||
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down Expand Up @@ -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"
}
}
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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(); }
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -1804,4 +1804,4 @@ sub check_messages {
return ($ret_code,$ret_msg);
}

##################################### END OF THE LIBRARY FUNCTIONS #########################################
##################################### END OF THE LIBRARY FUNCTIONS #########################################
52 changes: 26 additions & 26 deletions check_by_snmp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
#
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand All @@ -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=(); #

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -525,7 +525,7 @@ sub replace_macros {
verb("Replacing '".$reg."' in '".$args->[$i]."' with '".$rep."'");
$args->[$i] =~ s/$reg/$rep/g;
}
}
}
}
}

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion check_daytime.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
Expand Down
2 changes: 1 addition & 1 deletion check_dnsname.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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 - [email protected]
# Summary : This is a nagios plugin that makes sure two dns hostnames point
Expand Down
Loading

0 comments on commit acf7d87

Please sign in to comment.