1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
|
From 83795bee374466b865a99af479d7cfa0e1ed1e08 Mon Sep 17 00:00:00 2001
From: Michael Friedrich <michael.friedrich@gmail.com>
Date: Mon, 25 May 2015 14:35:53 +0200
Subject: [PATCH] Get rid of utils.pm entirely
It's only used for $TIMEOUT and %ERRORS which have
been implemented partly inside the plugins already.
This commit removes the file, the plugin dir lib
inclusion as well as the install.sh checks entirely.
Documentation has been updated as well.
fix #10
---
check_snmp_boostedge.pl | 8 ++-
check_snmp_cpfw.pl | 3 +-
check_snmp_css.pl | 9 ++--
check_snmp_css_main.pl | 9 ++--
check_snmp_env.pl | 9 ++--
check_snmp_int.pl | 3 +-
check_snmp_linkproof_nhr.pl | 9 ++--
check_snmp_load.pl | 3 +-
check_snmp_mem.pl | 3 +-
check_snmp_nsbox.pl | 9 ++--
check_snmp_process.pl | 3 +-
check_snmp_storage.pl | 9 ++--
check_snmp_vrrp.pl | 3 +-
check_snmp_win.pl | 5 +-
install.sh | 105 +++++++++++++++---------------------
utils.pm | 67 -----------------------
17 files changed, 75 insertions(+), 192 deletions(-)
delete mode 100644 plugins/utils.pm
--- a/check_snmp_boostedge.pl
+++ b/check_snmp_boostedge.pl
@@ -16,12 +16,10 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
+# Icinga specific
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
--- a/check_snmp_cpfw.pl
+++ b/check_snmp_cpfw.pl
@@ -17,8 +17,7 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
+# Icinga specific
my $TIMEOUT = 15;
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
--- a/check_snmp_css.pl
+++ b/check_snmp_css.pl
@@ -16,12 +16,9 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+# Icinga specific
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
--- a/check_snmp_css_main.pl
+++ b/check_snmp_css_main.pl
@@ -16,12 +16,9 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+# Icinga specific
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
--- a/check_snmp_env.pl
+++ b/check_snmp_env.pl
@@ -16,12 +16,9 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+# Icinga specific
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
my @Nagios_state = ("UNKNOWN","OK","WARNING","CRITICAL"); # Nagios states coding
--- a/check_snmp_int.pl
+++ b/check_snmp_int.pl
@@ -20,8 +20,7 @@
my $o_base_dir="/tmp/tmp_Nagios_int.";
my $file_history=200; # number of data to keep in files.
-# Nagios specific
-
+# Icinga specific
my $TIMEOUT = 15;
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
--- a/check_snmp_linkproof_nhr.pl
+++ b/check_snmp_linkproof_nhr.pl
@@ -16,12 +16,9 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+# Icinga specific
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
--- a/check_snmp_load.pl
+++ b/check_snmp_load.pl
@@ -15,8 +15,7 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
+# Icinga specific
my $TIMEOUT = 15;
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
--- a/check_snmp_mem.pl
+++ b/check_snmp_mem.pl
@@ -16,8 +16,7 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
+# Icinga specific
my $TIMEOUT = 15;
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
--- a/check_snmp_nsbox.pl
+++ b/check_snmp_nsbox.pl
@@ -16,12 +16,9 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+# Icinga specific
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
my $ns_service_status= "1.3.6.1.4.1.14020.2.2.1.3.0"; # service status 1= ok ??
--- a/check_snmp_process.pl
+++ b/check_snmp_process.pl
@@ -21,8 +21,7 @@
my $file_history=200; # number of data to keep in files.
my $delta_of_time_to_make_average=300; # 5minutes by default
-# Nagios specific
-
+# Icinga specific
my $TIMEOUT = 15;
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
--- a/check_snmp_storage.pl
+++ b/check_snmp_storage.pl
@@ -15,12 +15,9 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+# Icinga specific
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
my $storage_table= '1.3.6.1.2.1.25.2.3.1';
--- a/check_snmp_vrrp.pl
+++ b/check_snmp_vrrp.pl
@@ -15,8 +15,7 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
+# Icinga specific
my $TIMEOUT = 15;
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
--- a/check_snmp_win.pl
+++ b/check_snmp_win.pl
@@ -15,10 +15,7 @@
use Net::SNMP;
use Getopt::Long;
-# Nagios specific
-
-#use lib "/usr/local/nagios/libexec";
-#use utils qw(%ERRORS $TIMEOUT);
+# Icinga specific
my $TIMEOUT = 15;
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
--- a/install.sh
+++ b/install.sh
@@ -12,13 +12,13 @@
# USAGE : ./install [<perl script name> | AUTO <dir> <tmp_dir> <perl_dir> [<install_location>] ]
# USAGE : by default all scripts will be installed
#
-# REQUIREMENTS : /bin/bash and sed
+# REQUIREMENTS : /bin/bash and sed
#
-# This script will :
+# This script will:
# - Check perl binary (and asks for path)
-# - Ask for nagios plugin path and checks for file "utils.pm" in it (default /usr/local/nagios/libexec)
+# - Ask for monitoring plugin path (default /usr/local/icinga/libexec)
# - Ask for temporary file location (default /tmp)
-# - Check Net::SNMP version
+# - Check Net::SNMP version
# - Install plugins in the plugins directory and modify paths if necessary.
############################ script list
@@ -27,11 +27,11 @@
if [ $# -gt 0 ] ; then INSTSCRIPT=$1 ; else INSTSCRIPT="all" ; fi
-if [ $INSTSCRIPT != "AUTO" ] ; then
+if [ $INSTSCRIPT != "AUTO" ] ; then
############################ Manual installation
- echo
- echo "###### Nagios snmp scripts installer ######"
- echo
+ echo
+ echo "###### Manubulon snmp scripts installer ######"
+ echo
echo "Will install $INSTSCRIPT script(s)"
echo
@@ -41,7 +41,7 @@
PERLHOME=`which perl 2>&1`
if [ $? -ne 0 ]; then PERLHOME="" ; fi
- PLUGHOME=/usr/local/nagios/libexec
+ PLUGHOME=/usr/local/icinga/libexec
TMPDATA=/tmp
############################ Checking Perl
@@ -49,24 +49,24 @@
read USERPERL
if [ "ZZ$USERPERL" != "ZZ" ]; then PERLHOME=$USERPERL ; fi
- if [ "z$PERLHOME" == "z" ]; then
+ if [ "z$PERLHOME" == "z" ]; then
echo "Can't find perl binary... exiting"
echo "######### ERROR ########"
exit 1
fi
NETSNMP=`$PERLHOME -e 'if (eval "require Net::SNMP") { print "Yes" ;}'`
- if [ $? -ne 0 ] ; then
+ if [ $? -ne 0 ] ; then
echo "Error while checking Net::SNMP module"
echo "######### ERROR ########"
- exit 1;
+ exit 1;
fi
if [ "zz$NETSNMP" != "zzYes" ]; then
echo "Module Net::SNMP not found!"
echo "Install it with CPAN or manually : http://www.manubulon.com/nagios/faq.html#FAQ2"
echo "######### ERROR ########"
- exit 1;
+ exit 1;
fi
SNMPVER=`$PERLHOME -e 'require Net::SNMP;print Net::SNMP->VERSION'`
@@ -77,35 +77,28 @@
echo "Module Getopt::Long not found!"
echo "Install it with CPAN or manually"
echo "######### ERROR ########"
- exit 1;
+ exit 1;
fi
echo "Module Getopt::Long found [OK]"
- ############################ Check nagios plugin directory and utils.pm
+ ############################ Check monitoring plugin directory
echo
- echo "What is your nagios plugin location ? "
- echo -n "Note : file utils.pm must be present in it [$PLUGHOME] "
+ echo "What is your monitoring plugin location ? "
read USERPLUG
if [ "z$USERPLUG" != "z" ]; then PLUGHOME=$USERPLUG ; fi
- if [ ! -d $PLUGHOME ] ; then
+ if [ ! -d $PLUGHOME ] ; then
echo "Directory $PLUGHOME does not exist !"
echo "######### ERROR ########"
exit 1
fi
- if [ ! -f $PLUGHOME/utils.pm ] ; then
- echo "File $PLUGHOME/utils.pm does not exist !"
- echo "Install it from nagios plugins"
- echo "######### ERROR ########"
- exit 1
- fi
############################ Asking for temp directory
echo
echo "Where do you want the plugins to put temporary data (only used by some plugins) ? "
- echo -n "Nagios user must be able to write files in it [$TMPDATA] "
+ echo -n "Icinga user must be able to write files in it [$TMPDATA] "
read USERTMP
if [ "z$USERTMP" != "z" ]; then TMPDATA=$USERTMP ; fi
@@ -119,17 +112,11 @@
############################ Looks OK, copying with changes if necessary
TRANS=""
- # Change '#!/usr/bin/perl -w'
+ # Change '#!/usr/bin/perl -w'
if [ $PERLHOME != "/usr/bin/perl" ] ; then
TRANS="-r -e s#/usr/bin/perl#$PERLHOME#"
fi
- # Change 'use lib "/usr/local/nagios/libexec";'
- if [ $PLUGHOME != "/usr/local/nagios/libexec" ] ; then
- if [ "z$TRANS" == "z" ]; then TRANS="-r -e s#/usr/local/nagios/libexec#$PLUGHOME#"
- else TRANS="$TRANS -e s#/usr/local/nagios/libexec#$PLUGHOME#";fi
- fi
-
# Change 'my $o_base_dir="/tmp/tmp_Nagios_'
if [ $TMPDATA != "/tmp" ] ; then
if [ "z$TRANS" == "z" ]; then TRANS="-r -e s#/tmp/tmp_Nagios#$TMPDATA/tmp_Nagios#"
@@ -143,11 +130,11 @@
echo "in directory : $PLUGHOME"
echo "perl : $PERLHOME"
echo "temp directory : $TMPDATA"
- echo
+ echo
echo -n "OK ? [Y/n]"
read INSTOK
- if [ "$INSTOK" == "n" ]; then
+ if [ "$INSTOK" == "n" ]; then
echo "Aborting....."
echo "######### ERROR ########"
exit 1
@@ -155,24 +142,24 @@
ERROR=0
- if [ $INSTSCRIPT == "all" ] ; then
+ if [ $INSTSCRIPT == "all" ] ; then
for i in $PLUGINS ; do
- echo
- if [ ! -f $i ] ; then
+ echo
+ if [ ! -f $i ] ; then
echo "Can't find source file $i : ##### ERROR #####"
else
echo -n "Installing $i : "
- if [ "z$TRANS" == "z" ] ; then
+ if [ "z$TRANS" == "z" ] ; then
cp $i $PLUGHOME/$i 2>&1
else
sed $TRANS $i > $PLUGHOME/$i 2>&1
fi
- if [ $? -ne 0 ] ; then
- echo "##### ERROR #####";
- rm -f $PLUGHOME/$i
+ if [ $? -ne 0 ] ; then
+ echo "##### ERROR #####";
+ rm -f $PLUGHOME/$i
ERROR=1
- else
- echo "OK"
+ else
+ echo "OK"
chmod 755 $PLUGHOME/$i 2>&1
fi
fi
@@ -183,7 +170,7 @@
echo "Can't find source file $INSTSCRIPT : ##### ERROR #####"
else
echo -n "Installing $INSTSCRIPT : "
- if [ "z$TRANS" == "z" ] ; then
+ if [ "z$TRANS" == "z" ] ; then
cp $INSTSCRIPT > $PLUGHOME/$INSTSCRIPT
else
sed $TRANS $INSTSCRIPT > $PLUGHOME/$INSTSCRIPT 2>&1
@@ -193,10 +180,10 @@
rm -f $PLUGHOME/$INSTSCRIPT
ERROR=1
exit 1;
- else
- echo "OK"
+ else
+ echo "OK"
chmod 755 $PLUGHOME/$INSTSCRIPT 2>&1
- fi
+ fi
fi
fi
@@ -208,9 +195,9 @@
echo "Installation completed OK"
echo "You can delete all the source files and directory"
- echo "Remember to look for informtation at http://www.manubulon.com/nagios/"
+ echo "Remember to look for informtation at http://www.manubulon.com/nagios/"
exit 0;
-
+
else
####################### Silent install with parameters ############
# PARAM AUTO <dir> <tmp_dir> <perl_dir> [<install_location>]
@@ -221,19 +208,13 @@
PLUGHOME=$2
TMPDATA=$3
INSTALLDIR=$5
-
+
TRANS=""
- # Change '#!/usr/bin/perl -w'
+ # Change '#!/usr/bin/perl -w'
if [ $PERLHOME != "/usr/bin/perl" ] ; then
TRANS="-r -e s#/usr/bin/perl#$PERLHOME#"
fi
- # Change 'use lib "/usr/local/nagios/libexec";'
- if [ $PLUGHOME != "/usr/local/nagios/libexec" ] ; then
- if [ "z$TRANS" == "z" ]; then TRANS="-r -e s#/usr/local/nagios/libexec#$PLUGHOME#"
- else TRANS="$TRANS -e s#/usr/local/nagios/libexec#$PLUGHOME#";fi
- fi
-
# Change 'my $o_base_dir="/tmp/tmp_Nagios_'
if [ $TMPDATA != "/tmp" ] ; then
if [ "z$TRANS" == "z" ]; then TRANS="-r -e s#/tmp/tmp_Nagios#$TMPDATA/tmp_Nagios#"
@@ -246,18 +227,18 @@
PLUGHOME=$INSTALLDIR
fi
for i in $PLUGINS ; do
- if [ ! -f $i ] ; then
+ if [ ! -f $i ] ; then
ERROR=1
else
- if [ "z$TRANS" == "z" ] ; then
+ if [ "z$TRANS" == "z" ] ; then
cp $i $PLUGHOME/$i 2>&1
else
sed $TRANS $i > $PLUGHOME/$i 2>&1
fi
- if [ $? -ne 0 ] ; then
- rm -f $PLUGHOME/$i
+ if [ $? -ne 0 ] ; then
+ rm -f $PLUGHOME/$i
ERROR=1
- else
+ else
chmod 755 $PLUGHOME/$i 2>&1
fi
fi
|