Parcourir la source

Merge branch 'maint'

John C. Frickson il y a 9 ans
Parent
commit
17f8834a93

+ 2 - 0
.gitignore

@@ -2,6 +2,8 @@
 tags
 tags
 cscope.out
 cscope.out
 nbproject/
 nbproject/
+.kdev4/
+plugins.kdev4
 
 
 # In all paths
 # In all paths
 NP-VERSION-FILE
 NP-VERSION-FILE

+ 0 - 75
.travis.yml

@@ -1,75 +0,0 @@
-sudo: required
-dist: trusty
-language: c
-
-before_install:
-  # Trusty related fixed
-  # multiverse is no on trusty activated (https://github.com/travis-ci/travis-ci/issues/4979)
-  - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty multiverse" && sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty-updates multiverse"
-  # /etc/hosts has IPv6 hosts (https://github.com/travis-ci/travis-ci/issues/4978)
-  - sudo [ $(ip addr show | grep "inet6 ::1" | wc -l) -lt "1" ] && sudo sed -i '/^::1/d' /etc/hosts
-  # Trusty has running ntpd on localhost, but we don't like that for our tests
-  - sudo killall -9 ntpd
-  # Trusty has no swap, lets create some
-  - sudo fallocate -l 20M /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile
-  - sudo add-apt-repository -y ppa:waja/trusty-backports
-  - sudo apt-get update -qq
-  - sudo apt-get purge -qq gawk
-  # http://docs.travis-ci.com/user/trusty-ci-environment/ indicates, no MySQL on Trusty (yet)
-  # # ensure we have a test database in place for tests
-  # - mysql -e "create database IF NOT EXISTS test;" -uroot
-
-install:
-  - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libfreeradius-client-dev libkrb5-dev libnet-snmp-perl procps
-  - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd
-  - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl
-  - sudo apt-get install -qq --no-install-recommends slapd ldap-utils
-  - sudo apt-get install -qq --no-install-recommends autoconf automake
-  - sudo apt-get install -qq --no-install-recommends faketime
-  # Trusty related dependencies (not yet provided)
-  - sudo apt-get install -qq --no-install-recommends mariadb-client mariadb-server
-
-before_script:
-  # ensure we have a test database in place for tests
-  - mysql -e "create database IF NOT EXISTS test;" -uroot
-  # Detect LDAP configuration (seems  volatile on trusty env)
-  - sed -e 's/cn=admin,dc=nodomain/'$(sudo /usr/sbin/slapcat|grep ^dn:|grep cn=|awk '{print $2}')'/' -i plugins/t/NPTest.cache.travis
-  - tools/setup
-  - ./configure --enable-libtap
-  - make
-  - export NPTEST_CACHE="$(pwd)/plugins/t/NPTest.cache.travis"
-  - ssh-keygen -t dsa -N "" -f ~/.ssh/id_dsa
-  - cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
-  - ssh-keyscan localhost >> ~/.ssh/known_hosts
-  - touch ~/.ssh/config
-  - sudo rm -f /usr/share/mibs/ietf/SNMPv2-PDU /usr/share/mibs/ietf/IPSEC-SPD-MIB /usr/share/mibs/ietf/IPATM-IPMC-MIB /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
-  - sudo mkdir -p /var/lib/snmp/mib_indexes
-
-script:
-  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make test; fi
-
-notifications:
-  irc:
-    channels:
-      - "chat.freenode.net#Monitoring-Plugins"
-    on_success: change
-    on_failure: always
-    skip_join: true
-  email:
-    - team@monitoring-plugins.org
-
-env:
-  global:
-    # This is the encrypted COVERITY_SCAN_TOKEN, created via the "travis
-    # encrypt" command using the project repository's public key.
-    - secure: "ggJ9c/VfKcwtrwz/My+ne4My7D8g3qi3vz5Hh+yLiri0+oIXCy313ZD6ssIEY/5beQZEOnuHhBgBJd/Y3clSQNc2M9fRNc+wxOkIO992lgnY0MZJN3y9MLfpqUbTClhU9Fst0qXQqGpI6UI8yz1tj7yKi7DPrycJLRrjMpyTfyo="
-
-addons:
-  coverity_scan:
-    project:
-      name: "monitoring-plugins/monitoring-plugins"
-      description: "Monitoring Plugins"
-    notification_email: team@monitoring-plugins.org
-    build_command_prepend: tools/setup && ./configure
-    build_command: make
-    branch_pattern: coverity.*

+ 31 - 0
NEWS

@@ -1,5 +1,36 @@
 This file documents the major additions and syntax changes between releases.
 This file documents the major additions and syntax changes between releases.
 
 
+2.2.0 2017-01-19
+	ENHANCEMENTS
+	check_flexlm: if `-F <license file>` is not specified, will use `LM_LICENSE_FILE` environment var
+	check_load: Added per cpu load average message
+	check_smtp: add -L flag to support LMTP (LHLO instead of HELO/EHLO)
+
+	FIXES
+	check_http: -e breaks -f
+	check_mrtg: Add state to status output
+	check_ping: ping runs 30 times when host is down
+	check_icmp: does not have the -p argument in the help
+	check_dns: Segfaulting with timeout > 26 sec
+	check_disk: missing -lrt on Solaris
+	check_http: segmentation fault
+	check_http: help text update for virtual hosts
+	check_snmp: Thresholds were being shown twice
+	check_hpjd: some jd 610 cards have a false flag that printer is offline
+	check_http: Handle reference redirect like //www.site.org/test
+	check_disk: alerts issued too soon
+	fix: Allocator sizeof operand mismatch
+	fix: Dead assignment
+	Shellcheck: fix most of the shellcheck warnings.
+	check_ntp: touch ntp servers at most once every seconds
+	check_dns: authoritative test (-A) is broken
+	check_dns: reports TXT records incorrectly
+	check_file_age: does not handle filenames WITHOUT space!
+	de,fr.po: fix syntax errors end-of-line within string
+	lib/parse_ini.c: fix gcc warning: implicit declaration of function ‘idpriv_temp_drop’ and ‘idpriv_temp_restore’
+	add openssl 1.1 support
+
+
 2.1.4 2016-11-17
 2.1.4 2016-11-17
 	FIXES
 	FIXES
 	check_http: Don't include default Accept header if one is provided
 	check_http: Don't include default Accept header if one is provided

+ 1 - 1
NP-VERSION-GEN

@@ -6,7 +6,7 @@
 SRC_ROOT=`dirname $0`
 SRC_ROOT=`dirname $0`
 
 
 NPVF=NP-VERSION-FILE
 NPVF=NP-VERSION-FILE
-DEF_VER=2.1.4.git
+DEF_VER=2.2.0.git
 
 
 LF='
 LF='
 '
 '

+ 4 - 0
THANKS.in

@@ -66,6 +66,7 @@ Craig Orsinger
 Damian Myerscough
 Damian Myerscough
 Daniel Austin
 Daniel Austin
 Daniel Bimschas
 Daniel Bimschas
+Daniel Leib
 Daniël van Eeden
 Daniël van Eeden
 Dann Frazier
 Dann Frazier
 Darian Rackham
 Darian Rackham
@@ -106,6 +107,7 @@ Frederic Krueger
 Frederic Krueger
 Frederic Krueger
 Gabriele Tozzi
 Gabriele Tozzi
 Garry Cook
 Garry Cook
+Geert Hendrickx
 Geoff Oakham
 Geoff Oakham
 Geoff Oakham
 Geoff Oakham
 Gerd Mueller
 Gerd Mueller
@@ -182,6 +184,7 @@ Julius Kriukas
 Justin McOmie
 Justin McOmie
 Karl Ewald
 Karl Ewald
 Kenny Root
 Kenny Root
+Kees Monshouwer
 Kev Green
 Kev Green
 Kjell Sundtjonn
 Kjell Sundtjonn
 Koen Wilde
 Koen Wilde
@@ -206,6 +209,7 @@ Marc Remy
 Marcel Kuiper
 Marcel Kuiper
 Marco Beck
 Marco Beck
 Marcos Della
 Marcos Della
+Mario Trangoni
 Mario Witte
 Mario Witte
 Mark Favas
 Mark Favas
 Mark Jewiss
 Mark Jewiss

+ 8 - 8
configure.ac

@@ -1,6 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.59)
 AC_PREREQ(2.59)
-AC_INIT(nagios-plugins,2.1.4)
+AC_INIT(nagios-plugins,2.2.0)
 AC_CONFIG_SRCDIR(NPTest.pm)
 AC_CONFIG_SRCDIR(NPTest.pm)
 AC_CONFIG_FILES([gl/Makefile
 AC_CONFIG_FILES([gl/Makefile
 	nagios-plugins.spec])
 	nagios-plugins.spec])
@@ -516,15 +516,15 @@ if ! test x"$with_openssl" = x"no"; then
 	dnl Check for crypto lib
 	dnl Check for crypto lib
 	_SAVEDLIBS="$LIBS"
 	_SAVEDLIBS="$LIBS"
 	LIBS="-L${with_openssl}/lib"
 	LIBS="-L${with_openssl}/lib"
-	AC_CHECK_LIB(crypto,CRYPTO_lock)
-	if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
+	AC_CHECK_LIB(crypto,CRYPTO_new_ex_data)
+	if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
 		dnl Check for SSL lib
 		dnl Check for SSL lib
 		AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
 		AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
 	fi
 	fi
 	LIBS="$_SAVEDLIBS"
 	LIBS="$_SAVEDLIBS"
 
 
 	dnl test headers and libs to decide whether check_http should use SSL
 	dnl test headers and libs to decide whether check_http should use SSL
-	if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
+	if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
 		if test "$ac_cv_lib_ssl_main" = "yes"; then
 		if test "$ac_cv_lib_ssl_main" = "yes"; then
 			if test "$FOUNDINCLUDE" = "yes"; then
 			if test "$FOUNDINCLUDE" = "yes"; then
 				FOUNDOPENSSL="yes"
 				FOUNDOPENSSL="yes"
@@ -1098,10 +1098,10 @@ then
 	ac_cv_ping_packets_first=yes
 	ac_cv_ping_packets_first=yes
 	AC_MSG_RESULT([$with_ping_command])
 	AC_MSG_RESULT([$with_ping_command])
 
 
-elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
+elif $PATH_TO_PING -n -U -W 10 -c 1 127.0.0.1 2>/dev/null | \
 	egrep -i "^round-trip|^rtt" >/dev/null
 	egrep -i "^round-trip|^rtt" >/dev/null
 then
 then
-	with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
+	with_ping_command="$PATH_TO_PING -n -U -W %d -c %d %s"
 	ac_cv_ping_packets_first=yes
 	ac_cv_ping_packets_first=yes
 	ac_cv_ping_has_timeout=yes
 	ac_cv_ping_has_timeout=yes
 	AC_MSG_RESULT([$with_ping_command])
 	AC_MSG_RESULT([$with_ping_command])
@@ -1214,10 +1214,10 @@ elif test "x$PATH_TO_PING6" != "x"; then
 		ac_cv_ping6_packets_first=yes
 		ac_cv_ping6_packets_first=yes
 		AC_MSG_RESULT([$with_ping6_command])
 		AC_MSG_RESULT([$with_ping6_command])
 
 
-	elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
+	elif $PATH_TO_PING6 -n -U -W 10 -c 1 ::1 2>/dev/null | \
 		egrep -i "^round-trip|^rtt" >/dev/null
 		egrep -i "^round-trip|^rtt" >/dev/null
 	then
 	then
-		with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
+		with_ping6_command="$PATH_TO_PING6 -n -U -W %d -c %d %s"
 		ac_cv_ping6_packets_first=yes
 		ac_cv_ping6_packets_first=yes
 		ac_cv_ping_has_timeout=yes
 		ac_cv_ping_has_timeout=yes
 		AC_MSG_RESULT([$with_ping6_command])
 		AC_MSG_RESULT([$with_ping6_command])

+ 1 - 1
lib/extra_opts.c

@@ -112,7 +112,7 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name){
 	}
 	}
 
 
 	/* done processing arguments. now create a new argv array... */
 	/* done processing arguments. now create a new argv array... */
-	argv_new=(char**)malloc((ea_num+1)*sizeof(char**));
+	argv_new=(char**)malloc((ea_num+1)*sizeof(char*));
 	if(argv_new==NULL) die(STATE_UNKNOWN, _("malloc() failed!\n"));
 	if(argv_new==NULL) die(STATE_UNKNOWN, _("malloc() failed!\n"));
 
 
 	/* starting with program name */
 	/* starting with program name */

+ 30 - 30
lib/parse_ini.c

@@ -1,29 +1,30 @@
 /*****************************************************************************
 /*****************************************************************************
-* 
+*
 * Nagios-plugins parse_ini library
 * Nagios-plugins parse_ini library
-* 
+*
 * License: GPL
 * License: GPL
 * Copyright (c) 2007-2014 Nagios Plugins Development Team
 * Copyright (c) 2007-2014 Nagios Plugins Development Team
-* 
+*
 * This program is free software: you can redistribute it and/or modify
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * (at your option) any later version.
-* 
+*
 * This program is distributed in the hope that it will be useful,
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * GNU General Public License for more details.
-* 
+*
 * You should have received a copy of the GNU General Public License
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
-* 
-* 
+*
+*
 *****************************************************************************/
 *****************************************************************************/
 
 
 #include "common.h"
 #include "common.h"
 #include "utils_base.h"
 #include "utils_base.h"
 #include "parse_ini.h"
 #include "parse_ini.h"
+#include "../gl/idpriv.h"
 #include <ctype.h>
 #include <ctype.h>
 
 
 #include <sys/types.h>
 #include <sys/types.h>
@@ -123,33 +124,32 @@ np_arg_list* np_get_defaults(const char *locator, const char *default_section){
 
 
 	parse_locator(locator, default_section, &i);
 	parse_locator(locator, default_section, &i);
 	/* If a file was specified or if we're using the default file. */
 	/* If a file was specified or if we're using the default file. */
-        if (i.file != NULL && strlen(i.file) > 0) {
-                if (strcmp(i.file, "-") == 0) {
-                        inifile = stdin;
-                } else {
-                        /* We must be able to stat() the thing. */
-                        if (lstat(i.file, &fstat) != 0)
-                                die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file."), strerror(errno));
-                        /* The requested file must be a regular file. */
-                        if (!S_ISREG(fstat.st_mode))
-                                die(STATE_UNKNOWN, "%s\n", _("Can't read config file. Requested path is not a regular file."));
-                        /* We must be able to read the requested file. */
-                        if (access(i.file, R_OK|F_OK) != 0)
-                                die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file."), strerror(errno));
-                        /* We need to successfully open the file for reading... */
-                        if ((inifile=fopen(i.file, "r")) == NULL)
-                                die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file."), strerror(errno));
-                }
+	if (i.file != NULL && strlen(i.file) > 0) {
+		if (strcmp(i.file, "-") == 0) {
+			inifile = stdin;
+		} else {
+			/* We must be able to stat() the thing. */
+			if (lstat(i.file, &fstat) != 0)
+				die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file."), strerror(errno));
+			/* The requested file must be a regular file. */
+			if (!S_ISREG(fstat.st_mode))
+				die(STATE_UNKNOWN, "%s\n", _("Can't read config file. Requested path is not a regular file."));
+			/* We must be able to read the requested file. */
+			if (access(i.file, R_OK|F_OK) != 0)
+				die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file."), strerror(errno));
+			/* We need to successfully open the file for reading... */
+			if ((inifile=fopen(i.file, "r")) == NULL)
+				die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file."), strerror(errno));
+		}
 
 
 		/* before attempting access, let's make sure inifile is not null, this should never be the case though */
 		/* before attempting access, let's make sure inifile is not null, this should never be the case though */
 		if (inifile == NULL)
 		if (inifile == NULL)
 			die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file:"), strerror(errno));
 			die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file:"), strerror(errno));
-                /* inifile points to an open FILE our ruid/rgid can access, parse its contents. */
-                if (read_defaults(inifile, i.stanza, &defaults) == FALSE)
-                        die(STATE_UNKNOWN,"%s%s%s%s'\n", _("Invalid section '"), i.stanza, _("' in config file '"), i.file);
-
-                if (inifile != stdin) fclose(inifile);
-        } 
+		/* inifile points to an open FILE our ruid/rgid can access, parse its contents. */
+		if (read_defaults(inifile, i.stanza, &defaults) == FALSE)
+			die(STATE_UNKNOWN,"%s%s%s%s'\n", _("Invalid section '"), i.stanza, _("' in config file '"), i.file);
+		if (inifile != stdin) fclose(inifile);
+	}
 
 
 	if (i.file != NULL) {
 	if (i.file != NULL) {
 		free(i.file);
 		free(i.file);

+ 0 - 1
plugins-root/check_dhcp.c

@@ -581,7 +581,6 @@ int get_dhcp_offer(int sock){
 		bzero(&via,sizeof(via));
 		bzero(&via,sizeof(via));
 		bzero(&offer_packet,sizeof(offer_packet));
 		bzero(&offer_packet,sizeof(offer_packet));
 
 
-		result=OK;
 		result=receive_dhcp_packet(&offer_packet,sizeof(offer_packet),sock,dhcpoffer_timeout,&source);
 		result=receive_dhcp_packet(&offer_packet,sizeof(offer_packet),sock,dhcpoffer_timeout,&source);
 
 
 		if(result!=OK){
 		if(result!=OK){

+ 8 - 6
plugins-root/check_icmp.c

@@ -654,7 +654,7 @@ main(int argc, char **argv)
 	}
 	}
 
 
 	host = list;
 	host = list;
-	table = malloc(sizeof(struct rta_host **) * targets);
+	table = malloc(sizeof(struct rta_host *) * targets);
 	i = 0;
 	i = 0;
 	while(host) {
 	while(host) {
 		host->id = i*packets;
 		host->id = i*packets;
@@ -692,9 +692,9 @@ run_checks()
 
 
 			/* we're still in the game, so send next packet */
 			/* we're still in the game, so send next packet */
 			(void)send_icmp_ping(icmp_sock, table[t]);
 			(void)send_icmp_ping(icmp_sock, table[t]);
-			result = wait_for_reply(icmp_sock, target_interval);
+			(void)wait_for_reply(icmp_sock, target_interval);
 		}
 		}
-		result = wait_for_reply(icmp_sock, pkt_interval * targets);
+		(void)wait_for_reply(icmp_sock, pkt_interval * targets);
 	}
 	}
 
 
 	if(icmp_pkts_en_route && targets_alive) {
 	if(icmp_pkts_en_route && targets_alive) {
@@ -714,7 +714,7 @@ run_checks()
 		 * haven't yet */
 		 * haven't yet */
 		if(debug) printf("Waiting for %u micro-seconds (%0.3f msecs)\n",
 		if(debug) printf("Waiting for %u micro-seconds (%0.3f msecs)\n",
 						 final_wait, (float)final_wait / 1000);
 						 final_wait, (float)final_wait / 1000);
-		result = wait_for_reply(icmp_sock, final_wait);
+		(void)wait_for_reply(icmp_sock, final_wait);
 	}
 	}
 }
 }
 
 
@@ -1082,7 +1082,6 @@ finish(int sig)
 
 
 	/* iterate once more for pretty perfparse output */
 	/* iterate once more for pretty perfparse output */
 	printf("|");
 	printf("|");
-	i = 0;
 	host = list;
 	host = list;
 	while(host) {
 	while(host) {
 		if(debug) write(STDOUT_FILENO, "\n", 1);
 		if(debug) write(STDOUT_FILENO, "\n", 1);
@@ -1273,7 +1272,7 @@ get_timevar(const char *str)
 
 
 	/* unit might be given as ms|m (millisec),
 	/* unit might be given as ms|m (millisec),
 	 * us|u (microsec) or just plain s, for seconds */
 	 * us|u (microsec) or just plain s, for seconds */
-	u = p = '\0';
+	p = '\0';
 	u = str[len - 1];
 	u = str[len - 1];
 	if(len >= 2 && !isdigit((int)str[len - 2])) p = str[len - 2];
 	if(len >= 2 && !isdigit((int)str[len - 2])) p = str[len - 2];
 	if(p && u == 's') u = p;
 	if(p && u == 's') u = p;
@@ -1381,6 +1380,9 @@ print_help(void)
   printf (" %s\n", "-n");
   printf (" %s\n", "-n");
   printf ("    %s", _("number of packets to send (currently "));
   printf ("    %s", _("number of packets to send (currently "));
   printf ("%u)\n",packets);
   printf ("%u)\n",packets);
+  printf (" %s\n", "-p");
+  printf ("    %s", _("number of packets to send (currently "));
+  printf ("%u)\n",packets);
   printf (" %s\n", "-i");
   printf (" %s\n", "-i");
   printf ("    %s", _("max packet interval (currently "));
   printf ("    %s", _("max packet interval (currently "));
   printf ("%0.3fms)\n",(float)pkt_interval / 1000);
   printf ("%0.3fms)\n",(float)pkt_interval / 1000);

+ 1 - 1
plugins-scripts/check_file_age.pl

@@ -77,7 +77,7 @@ if (! $opt_f) {
 	exit $ERRORS{'UNKNOWN'};
 	exit $ERRORS{'UNKNOWN'};
 }
 }
 
 
-$opt_f = '"' . $opt_f . '"';
+$opt_f = '"' . $opt_f . '"' if $opt_f =~ / /;
 
 
 # Check that file(s) exists (can be directory or link)
 # Check that file(s) exists (can be directory or link)
 $perfdata = "";
 $perfdata = "";

+ 7 - 4
plugins-scripts/check_flexlm.pl

@@ -70,9 +70,12 @@ unless (defined $opt_t) {
 if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
 if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
 
 
 unless (defined $opt_F) {
 unless (defined $opt_F) {
-	print "Missing license.dat file\n";
-	print_usage();
-	exit $ERRORS{'UNKNOWN'};
+	$opt_F = $ENV{'LM_LICENSE_FILE'};
+	unless (defined $opt_F) {
+		print "Missing license.dat file\n";
+		print_usage();
+		exit $ERRORS{'UNKNOWN'};
+	}
 }
 }
 # Just in case of problems, let's not hang Nagios
 # Just in case of problems, let's not hang Nagios
 $SIG{'ALRM'} = sub {
 $SIG{'ALRM'} = sub {
@@ -227,7 +230,7 @@ Check available flexlm license managers
 	print_usage();
 	print_usage();
 	print "
 	print "
 -F, --filename=FILE
 -F, --filename=FILE
-   Name of license file (usually \"license.dat\")
+   Name of license file (like \"/usr/local/flexlm/licenses/license.dat\")
 -v, --verbose
 -v, --verbose
    Print some extra debugging information (not advised for normal operation)
    Print some extra debugging information (not advised for normal operation)
 -t, --timeout
 -t, --timeout

+ 30 - 30
plugins-scripts/check_log.sh

@@ -60,14 +60,14 @@
 
 
 PATH="@TRUSTED_PATH@"
 PATH="@TRUSTED_PATH@"
 export PATH
 export PATH
-PROGNAME=`basename $0`
-PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
+PROGNAME=$(basename "$0")
+PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
 REVISION="@NP_VERSION@"
 REVISION="@NP_VERSION@"
 PATH="@TRUSTED_PATH@"
 PATH="@TRUSTED_PATH@"
 
 
 export PATH
 export PATH
 
 
-. $PROGPATH/utils.sh
+. "$PROGPATH"/utils.sh
 
 
 print_usage() {
 print_usage() {
     echo "Usage: $PROGNAME -F logfile -O oldlog -q query"
     echo "Usage: $PROGNAME -F logfile -O oldlog -q query"
@@ -79,7 +79,7 @@ print_usage() {
 }
 }
 
 
 print_help() {
 print_help() {
-    print_revision $PROGNAME $REVISION
+    print_revision "$PROGNAME" $REVISION
     echo ""
     echo ""
     print_usage
     print_usage
     echo ""
     echo ""
@@ -93,7 +93,7 @@ print_help() {
 
 
 if [ $# -lt 1 ]; then
 if [ $# -lt 1 ]; then
     print_usage
     print_usage
-    exit $STATE_UNKNOWN
+    exit "$STATE_UNKNOWN"
 fi
 fi
 
 
 # Grab the command line arguments
 # Grab the command line arguments
@@ -106,19 +106,19 @@ while test -n "$1"; do
     case "$1" in
     case "$1" in
         --help)
         --help)
             print_help
             print_help
-            exit $STATE_OK
+            exit "$STATE_OK"
             ;;
             ;;
         -h)
         -h)
             print_help
             print_help
-            exit $STATE_OK
+            exit "$STATE_OK"
             ;;
             ;;
         --version)
         --version)
-            print_revision $PROGNAME $REVISION
-            exit $STATE_OK
+            print_revision "$PROGNAME" $REVISION
+            exit "$STATE_OK"
             ;;
             ;;
         -V)
         -V)
-            print_revision $PROGNAME $REVISION
-            exit $STATE_OK
+            print_revision "$PROGNAME" $REVISION
+            exit "$STATE_OK"
             ;;
             ;;
         --filename)
         --filename)
             logfile=$2
             logfile=$2
@@ -163,7 +163,7 @@ while test -n "$1"; do
         *)
         *)
             echo "Unknown argument: $1"
             echo "Unknown argument: $1"
             print_usage
             print_usage
-            exit $STATE_UNKNOWN
+            exit "$STATE_UNKNOWN"
             ;;
             ;;
     esac
     esac
     shift
     shift
@@ -171,22 +171,22 @@ done
 
 
 # If the source log file doesn't exist, exit
 # If the source log file doesn't exist, exit
 
 
-if [ ! -e $logfile ]; then
+if [ ! -e "$logfile" ]; then
     echo "Log check error: Log file $logfile does not exist!"
     echo "Log check error: Log file $logfile does not exist!"
-    exit $STATE_UNKNOWN
-elif [ ! -r $logfile ] ; then
+    exit "$STATE_UNKNOWN"
+elif [ ! -r "$logfile" ] ; then
     echo "Log check error: Log file $logfile is not readable!"
     echo "Log check error: Log file $logfile is not readable!"
-    exit $STATE_UNKNOWN
+    exit "$STATE_UNKNOWN"
 fi
 fi
 
 
 # If the old log file doesn't exist, this must be the first time
 # If the old log file doesn't exist, this must be the first time
 # we're running this test, so copy the original log file over to
 # we're running this test, so copy the original log file over to
 # the old diff file and exit
 # the old diff file and exit
 
 
-if [ ! -e $oldlog ]; then
-    cat $logfile > $oldlog
+if [ ! -e "$oldlog" ]; then
+    cat "$logfile" > "$oldlog"
     echo "Log check data initialized..."
     echo "Log check data initialized..."
-    exit $STATE_OK
+    exit "$STATE_OK"
 fi
 fi
 
 
 # The old log file exists, so compare it to the original log now
 # The old log file exists, so compare it to the original log now
@@ -194,35 +194,35 @@ fi
 # The temporary file that the script should use while
 # The temporary file that the script should use while
 # processing the log file.
 # processing the log file.
 if [ -x /bin/mktemp ]; then
 if [ -x /bin/mktemp ]; then
-    tempdiff=`/bin/mktemp /tmp/check_log.XXXXXXXXXX`
+    tempdiff=$(/bin/mktemp /tmp/check_log.XXXXXXXXXX)
 else
 else
-    tempdiff=`/bin/date '+%H%M%S'`
+    tempdiff=$(/bin/date '+%H%M%S')
     tempdiff="/tmp/check_log.${tempdiff}"
     tempdiff="/tmp/check_log.${tempdiff}"
-    touch $tempdiff
-    chmod 600 $tempdiff
+    touch "$tempdiff"
+    chmod 600 "$tempdiff"
 fi
 fi
 
 
-diff $logfile $oldlog | grep -v "^>" > $tempdiff
+diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
 
 
 # Count the number of matching log entries we have
 # Count the number of matching log entries we have
-count=`grep -c "$query" $tempdiff`
+count=$(grep -c "$query" "$tempdiff")
 
 
 # Get the last matching entry in the diff file
 # Get the last matching entry in the diff file
-lastentry=`grep "$query" $tempdiff | tail -1`
+lastentry=$(grep "$query" "$tempdiff" | tail -1)
 
 
-rm -f $tempdiff
-cat $logfile > $oldlog
+rm -f "$tempdiff"
+cat "$logfile" > "$oldlog"
 
 
 if [ "$count" = "0" ]; then # no matches, exit with no error
 if [ "$count" = "0" ]; then # no matches, exit with no error
     echo "Log check ok - 0 pattern matches found|match=$count;;;0"
     echo "Log check ok - 0 pattern matches found|match=$count;;;0"
     exitstatus=$STATE_OK
     exitstatus=$STATE_OK
 else # Print total matche count and the last entry we found
 else # Print total matche count and the last entry we found
     echo "($count) $lastentry|match=$count;;;0"
     echo "($count) $lastentry|match=$count;;;0"
-    if [ $MAX_WARNING ] && [ $count -le $MAX_WARNING ] ; then
+    if [ "$MAX_WARNING" ] && [ "$count" -le "$MAX_WARNING" ] ; then
         exitstatus=$STATE_WARNING
         exitstatus=$STATE_WARNING
     else
     else
         exitstatus=$STATE_CRITICAL
         exitstatus=$STATE_CRITICAL
     fi
     fi
 fi
 fi
 
 
-exit $exitstatus
+exit "$exitstatus"

+ 121 - 121
plugins-scripts/check_oracle.sh

@@ -8,12 +8,12 @@
 
 
 PATH="@TRUSTED_PATH@"
 PATH="@TRUSTED_PATH@"
 export PATH
 export PATH
-PROGNAME=`basename $0`
-PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
+PROGNAME=$(basename "$0")
+PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
 REVISION="@NP_VERSION@"
 REVISION="@NP_VERSION@"
 PATH="@TRUSTED_PATH@"
 PATH="@TRUSTED_PATH@"
 
 
-. $PROGPATH/utils.sh
+. "$PROGPATH"/utils.sh
 
 
 
 
 print_usage() {
 print_usage() {
@@ -30,7 +30,7 @@ print_usage() {
 }
 }
 
 
 print_help() {
 print_help() {
-  print_revision $PROGNAME $REVISION
+  print_revision "$PROGNAME" $REVISION
   echo ""
   echo ""
   print_usage
   print_usage
   echo ""
   echo ""
@@ -87,48 +87,48 @@ esac
 # Information options
 # Information options
 case "$cmd" in
 case "$cmd" in
 --help)
 --help)
-		print_help
-    exit $STATE_OK
+    print_help
+    exit "$STATE_OK"
     ;;
     ;;
 -h)
 -h)
-		print_help
-    exit $STATE_OK
+    print_help
+    exit "$STATE_OK"
     ;;
     ;;
 --version)
 --version)
-		print_revision $PROGNAME $REVISION
-    exit $STATE_OK
+    print_revision "$PROGNAME" $REVISION
+    exit "$STATE_OK"
     ;;
     ;;
 -V)
 -V)
-		print_revision $PROGNAME $REVISION
-    exit $STATE_OK
+    print_revision "$PROGNAME" $REVISION
+    exit "$STATE_OK"
     ;;
     ;;
 esac
 esac
 
 
 # Hunt down a reasonable ORACLE_HOME
 # Hunt down a reasonable ORACLE_HOME
 if [ -z "$ORACLE_HOME" ] ; then
 if [ -z "$ORACLE_HOME" ] ; then
-	# Adjust to taste
-	for oratab in /var/opt/oracle/oratab /etc/oratab
-	do
-	[ ! -f $oratab ] && continue
-	ORACLE_HOME=`IFS=:
-		while read SID ORACLE_HOME junk;
-		do
-			if [ "$SID" = "$2" -o "$SID" = "*" ] ; then
-				echo $ORACLE_HOME;
-				exit;
-			fi;
-		done < $oratab`
-	[ -n "$ORACLE_HOME" ] && break
-	done
+    # Adjust to taste
+    for oratab in /var/opt/oracle/oratab /etc/oratab
+    do
+    [ ! -f $oratab ] && continue
+    ORACLE_HOME=`IFS=:
+        while read SID ORACLE_HOME junk;
+        do
+            if [ "$SID" = "$2" -o "$SID" = "*" ] ; then
+                echo "$ORACLE_HOME";
+                exit;
+            fi;
+        done < $oratab`
+    [ -n "$ORACLE_HOME" ] && break
+    done
 fi
 fi
 # Last resort
 # Last resort
-[ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle
+[ -z "$ORACLE_HOME" -a -d "$PROGPATH"/oracle ] && ORACLE_HOME=$PROGPATH/oracle
 
 
 if [ "$cmd" != "--db" ]; then
 if [ "$cmd" != "--db" ]; then
-	if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then
-		echo "Cannot determine ORACLE_HOME for sid $2"
-		exit $STATE_UNKNOWN
-	fi
+    if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then
+        echo "Cannot determine ORACLE_HOME for sid $2"
+        exit "$STATE_UNKNOWN"
+    fi
 fi
 fi
 PATH=$PATH:$ORACLE_HOME/bin
 PATH=$PATH:$ORACLE_HOME/bin
 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
@@ -136,81 +136,81 @@ export ORACLE_HOME PATH LD_LIBRARY_PATH
 
 
 case "$cmd" in
 case "$cmd" in
 --tns)
 --tns)
-    tnschk=` tnsping $2`
-    tnschk2=` echo  $tnschk | grep -c OK`
-    if [ ${tnschk2} -eq 1 ] ; then 
-	tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*}
-	echo "OK - reply time ${tnschk3} from $2"
-	exit $STATE_OK
+    tnschk=$(tnsping "$2")
+    tnschk2=$(echo "$tnschk" | grep -c OK)
+    if [ "${tnschk2}" -eq 1 ] ; then 
+        tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*}
+        echo "OK - reply time ${tnschk3} from $2"
+        exit "$STATE_OK"
     else
     else
-	echo "No TNS Listener on $2"
-	exit $STATE_CRITICAL
+        echo "No TNS Listener on $2"
+        exit "$STATE_CRITICAL"
     fi
     fi
     ;;
     ;;
 --oranames)
 --oranames)
-    namesctl status $2 | awk '
+    namesctl status "$2" | awk '
     /Server has been running for:/ {
     /Server has been running for:/ {
-	msg = "OK: Up"
-	for (i = 6; i <= NF; i++) {
-	    msg = msg " " $i
-	}
-	status = '$STATE_OK'
+        msg = "OK: Up"
+        for (i = 6; i <= NF; i++) {
+            msg = msg " " $i
+        }
+        status = '"$STATE_OK"'
     }
     }
     /error/ {
     /error/ {
-	msg = "CRITICAL: " $0
-	status = '$STATE_CRITICAL'
+        msg = "CRITICAL: " $0
+        status = '"$STATE_CRITICAL"'
     }
     }
     END {
     END {
-	print msg
-	exit status
+        print msg
+        exit status
     }'
     }'
     ;;
     ;;
 --db)
 --db)
-    pmonchk=`ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$"`
-    if [ ${pmonchk} -ge 1 ] ; then
-	echo "${2} OK - ${pmonchk} PMON process(es) running"
-	exit $STATE_OK
+    pmonchk=$(pgrep -f "(asm|ora)_pmon_${2}$")
+    if [ "${pmonchk}" -ge 1 ] ; then
+        echo "${2} OK - ${pmonchk} PMON process(es) running"
+        exit "$STATE_OK"
     #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then
     #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then
-	#if [ ${pmonchk} -eq 1 ] ; then
+        #if [ ${pmonchk} -eq 1 ] ; then
     #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55`
     #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55`
-	    #echo "${2} OK - running since ${utime}"
-	    #exit $STATE_OK
-	#fi
+            #echo "${2} OK - running since ${utime}"
+            #exit $STATE_OK
+        #fi
     else
     else
-	echo "${2} Database is DOWN"
-	exit $STATE_CRITICAL
+        echo "${2} Database is DOWN"
+        exit "$STATE_CRITICAL"
     fi
     fi
     ;;
     ;;
 --login)
 --login)
-    loginchk=`sqlplus dummy/user@$2 < /dev/null`
-    loginchk2=` echo  $loginchk | grep -c ORA-01017`
-    if [ ${loginchk2} -eq 1 ] ; then 
-	echo "OK - dummy login connected"
-	exit $STATE_OK
+    loginchk=$(sqlplus dummy/user@"$2" < /dev/null)
+    loginchk2=$(echo "$loginchk" | grep -c ORA-01017)
+    if [ "${loginchk2}" -eq 1 ] ; then 
+        echo "OK - dummy login connected"
+        exit "$STATE_OK"
     else
     else
-	loginchk3=` echo "$loginchk" | grep "ORA-" | head -1`
-	echo "CRITICAL - $loginchk3"
-	exit $STATE_CRITICAL
+        loginchk3=$(echo "$loginchk" | grep "ORA-" | head -1)
+        echo "CRITICAL - $loginchk3"
+        exit "$STATE_CRITICAL"
     fi
     fi
     ;;
     ;;
 --connect)
 --connect)
-    connectchk=`sqlplus $2 < /dev/null`
-    connectchk2=` echo  $connectchk | grep -c ORA-`
-    if [ ${connectchk2} -eq 0 ] ; then
-	echo "OK - login successful"
-	exit $STATE_OK
+    connectchk=$(sqlplus "$2" < /dev/null)
+    connectchk2=$(echo "$connectchk" | grep -c ORA-)
+    if [ "${connectchk2}" -eq 0 ] ; then
+        echo "OK - login successful"
+        exit "$STATE_OK"
     else
     else
-	connectchk3=` echo "$connectchk" | grep "ORA-" | head -1`
-	echo "CRITICAL - $connectchk3"
-	exit $STATE_CRITICAL
+        connectchk3=$(echo "$connectchk" | grep "ORA-" | head -1)
+        echo "CRITICAL - $connectchk3"
+        exit "$STATE_CRITICAL"
     fi
     fi
     ;;
     ;;
 --cache)
 --cache)
-    if [ ${5} -gt ${6} ] ; then
-	echo "UNKNOWN - Warning level is less then Crit"
-	exit $STATE_UNKNOWN
+    if [ "${5}" -gt "${6}" ] ; then
+        echo "UNKNOWN - Warning level is less then Crit"
+        exit "$STATE_UNKNOWN"
     fi
     fi
-    result=`sqlplus -s ${3}/${4}@${2} << EOF
+    result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
 set pagesize 0
 set pagesize 0
 set numf '9999999.99'
 set numf '9999999.99'
 select (1-(pr.value/(dbg.value+cg.value)))*100
 select (1-(pr.value/(dbg.value+cg.value)))*100
@@ -220,48 +220,48 @@ and dbg.name='db block gets'
 and cg.name='consistent gets';
 and cg.name='consistent gets';
 EOF`
 EOF`
 
 
-    if [ -n "`echo $result | grep ORA-`" ] ; then
-      error=` echo "$result" | grep "ORA-" | head -1`
-      echo "CRITICAL - $error"
-      exit $STATE_CRITICAL
+    if echo "$result" | grep -q 'ORA-' ; then
+        error=$(echo "$result" | grep "ORA-" | head -1)
+        echo "CRITICAL - $error"
+        exit "$STATE_CRITICAL"
     fi
     fi
 
 
-    buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` 
-    buf_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` 
-    result=`sqlplus -s ${3}/${4}@${2} << EOF
+    buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
+    buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
+    result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
 set pagesize 0
 set pagesize 0
 set numf '9999999.99'
 set numf '9999999.99'
 select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
 select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
 from v\\$librarycache lc;
 from v\\$librarycache lc;
 EOF`
 EOF`
-	
-    if [ -n "`echo $result | grep ORA-`" ] ; then
-      error=` echo "$result" | grep "ORA-" | head -1`
-      echo "CRITICAL - $error"
-      exit $STATE_CRITICAL
+
+    if echo "$result" | grep -q 'ORA-' ; then
+        error=$(echo "$result" | grep "ORA-" | head -1)
+        echo "CRITICAL - $error"
+        exit "$STATE_CRITICAL"
     fi
     fi
 
 
-    lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'`
-    lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'`
+    lib_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
+    lib_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
 
 
-    if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then
-  	echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
-	exit $STATE_CRITICAL
+    if [ "$buf_hr" -le "${5}" -o "$lib_hr" -le "${5}" ] ; then
+        echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
+        exit "$STATE_CRITICAL"
     fi
     fi
-    if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then
-  	echo "${2} WARNING  - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
-	exit $STATE_WARNING
+    if [ "$buf_hr" -le "${6}" -o "$lib_hr" -le "${6}" ] ; then
+        echo "${2} WARNING  - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
+        exit "$STATE_WARNING"
     fi
     fi
     echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
     echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
 
 
-    exit $STATE_OK
+    exit "$STATE_OK"
     ;;
     ;;
 --tablespace)
 --tablespace)
-    if [ ${6} -lt ${7} ] ; then
-	echo "UNKNOWN - Warning level is more then Crit"
-	exit $STATE_UNKNOWN
+    if [ "${6}" -lt "${7}" ] ; then
+        echo "UNKNOWN - Warning level is more then Crit"
+        exit "$STATE_UNKNOWN"
     fi
     fi
-    result=`sqlplus -s ${3}/${4}@${2} << EOF
+    result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
 set pagesize 0
 set pagesize 0
 set numf '9999999.99'
 set numf '9999999.99'
 select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
 select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
@@ -274,32 +274,32 @@ from dba_free_space group by tablespace_name) B
 ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
 ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
 EOF`
 EOF`
 
 
-    if [ -n "`echo $result | grep ORA-`" ] ; then
-      error=` echo "$result" | grep "ORA-" | head -1`
-      echo "CRITICAL - $error"
-      exit $STATE_CRITICAL
+    if echo "$result" | grep -q 'ORA-'; then
+        error=$(echo "$result" | grep 'ORA-' | head -1)
+        echo "CRITICAL - $error"
+        exit "$STATE_CRITICAL"
     fi
     fi
 
 
-    ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'` 
-    ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` 
-    ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` 
-    ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'` 
+    ts_free=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}')
+    ts_total=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}')
+    ts_pct=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}')
+    ts_pctx=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}')
     if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then
     if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then
         echo "No data returned by Oracle - tablespace $5 not found?"
         echo "No data returned by Oracle - tablespace $5 not found?"
-        exit $STATE_UNKNOWN
+        exit "$STATE_UNKNOWN"
     fi
     fi
-    if [ "$ts_pct" -ge ${6} ] ; then
-  	echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
-	exit $STATE_CRITICAL
+    if [ "$ts_pct" -ge "${6}" ] ; then
+        echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
+        exit "$STATE_CRITICAL"
     fi
     fi
-    if [ "$ts_pct" -ge ${7} ] ; then
-  	echo "${2} : ${5} WARNING  - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
-	exit $STATE_WARNING
+    if [ "$ts_pct" -ge "${7}" ] ; then
+        echo "${2} : ${5} WARNING  - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
+        exit "$STATE_WARNING"
     fi
     fi
     echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
     echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
-    exit $STATE_OK
+    exit "$STATE_OK"
     ;;
     ;;
 *)
 *)
     print_usage
     print_usage
-		exit $STATE_UNKNOWN
+    exit "$STATE_UNKNOWN"
 esac
 esac

+ 23 - 21
plugins-scripts/check_sensors.sh

@@ -1,62 +1,64 @@
 #!/bin/sh
 #!/bin/sh
 
 
-PROGNAME=`basename $0`
-PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
+PROGNAME=$(basename "$0")
+PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
 REVISION="@NP_VERSION@"
 REVISION="@NP_VERSION@"
 PATH="@TRUSTED_PATH@"
 PATH="@TRUSTED_PATH@"
 
 
 export PATH
 export PATH
 
 
-. $PROGPATH/utils.sh
+. "$PROGPATH"/utils.sh
 
 
 print_usage() {
 print_usage() {
 	echo "Usage: $PROGNAME" [--ignore-fault]
 	echo "Usage: $PROGNAME" [--ignore-fault]
 }
 }
 
 
 print_help() {
 print_help() {
-	print_revision $PROGNAME $REVISION
+	print_revision "$PROGNAME" "$REVISION"
 	echo ""
 	echo ""
 	print_usage
 	print_usage
 	echo ""
 	echo ""
 	echo "This plugin checks hardware status using the lm_sensors package."
 	echo "This plugin checks hardware status using the lm_sensors package."
 	echo ""
 	echo ""
 	support
 	support
-	exit $STATE_OK
+	exit "$STATE_OK"
 }
 }
 
 
 case "$1" in
 case "$1" in
 	--help)
 	--help)
 		print_help
 		print_help
-		exit $STATE_OK
+		exit "$STATE_OK"
 		;;
 		;;
 	-h)
 	-h)
 		print_help
 		print_help
-		exit $STATE_OK
+		exit "$STATE_OK"
 		;;
 		;;
 	--version)
 	--version)
-		print_revision $PROGNAME $REVISION
-		exit $STATE_OK
+		print_revision "$PROGNAME" $REVISION
+		exit "$STATE_OK"
 		;;
 		;;
 	-V)
 	-V)
-		print_revision $PROGNAME $REVISION
-		exit $STATE_OK
+		print_revision "$PROGNAME" $REVISION
+		exit "$STATE_OK"
 		;;
 		;;
 	*)
 	*)
-		sensordata=`sensors 2>&1`
+		sensordata=$(sensors 2>&1)
 		status=$?
 		status=$?
-		if test ${status} -eq 127; then
+		if [ $status -eq 127 ] ; then
 			text="SENSORS UNKNOWN - command not found (did you install lmsensors?)"
 			text="SENSORS UNKNOWN - command not found (did you install lmsensors?)"
 			exit=$STATE_UNKNOWN
 			exit=$STATE_UNKNOWN
-		elif test ${status} -ne 0; then
+		elif [ "$status" != 0 ] ; then
 			text="WARNING - sensors returned state $status"
 			text="WARNING - sensors returned state $status"
 			exit=$STATE_WARNING
 			exit=$STATE_WARNING
-		elif echo ${sensordata} | egrep ALARM > /dev/null; then
+		elif echo "${sensordata}" | egrep -q ALARM > /dev/null ; then
 			text="SENSOR CRITICAL - Sensor alarm detected!"
 			text="SENSOR CRITICAL - Sensor alarm detected!"
 			exit=$STATE_CRITICAL
 			exit=$STATE_CRITICAL
-		elif echo ${sensordata} | egrep FAULT > /dev/null \
-		    && test "$1" != "-i" -a "$1" != "--ignore-fault"; then
-			text="SENSOR UNKNOWN - Sensor reported fault"
-			exit=$STATE_UNKNOWN
+		elif echo "${sensordata}" | egrep -q FAULT  > /dev/null -a; then
+			if [ "$(test "$1")" != "-i" -a \
+				"$1" != "--ignore-fault" ] ; then
+				text="SENSOR UNKNOWN - Sensor reported fault"
+				exit=$STATE_UNKNOWN
+			fi
 		else
 		else
 			text="SENSORS OK"
 			text="SENSORS OK"
 			exit=$STATE_OK
 			exit=$STATE_OK
@@ -64,8 +66,8 @@ case "$1" in
 
 
 		echo "$text"
 		echo "$text"
 		if test "$1" = "-v" -o "$1" = "--verbose"; then
 		if test "$1" = "-v" -o "$1" = "--verbose"; then
-			echo ${sensordata}
+			echo "${sensordata}"
 		fi
 		fi
-		exit $exit
+		exit "$exit"
 		;;
 		;;
 esac
 esac

+ 6 - 6
plugins/check_disk.c

@@ -363,7 +363,7 @@ main (int argc, char **argv)
       else {
       else {
 	      xasprintf(&flag_header, "");
 	      xasprintf(&flag_header, "");
       }
       }
-      xasprintf (&output, "%s %s %.0f %s (%.0f%%",
+      xasprintf (&output, "%s %s %.0f %s (%.2f%%",
                 output,
                 output,
                 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
                 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
                 path->dfree_units,
                 path->dfree_units,
@@ -414,17 +414,17 @@ double calculate_percent(uintmax_t value, uintmax_t total) {
   double pct = -1;
   double pct = -1;
   /* I don't understand the below, but it is taken from coreutils' df */
   /* I don't understand the below, but it is taken from coreutils' df */
   /* Seems to be calculating pct, in the best possible way */
   /* Seems to be calculating pct, in the best possible way */
-  if (value <= TYPE_MAXIMUM(uintmax_t) / 100
+  if (value <= TYPE_MAXIMUM(uintmax_t) / 10000
     && total != 0) {
     && total != 0) {
-    uintmax_t u100 = value * 100;
-    pct = u100 / total + (u100 % total != 0);
+    uintmax_t u100 = value * 10000;
+    pct = (u100 / total + (u100 % total != 0)) / 100.0;
   } else {
   } else {
     /* Possible rounding errors - see coreutils' df for more explanation */
     /* Possible rounding errors - see coreutils' df for more explanation */
     double u = value;
     double u = value;
     double t = total;
     double t = total;
     if (t) {
     if (t) {
-      long int lipct = pct = u * 100 / t;
-      double ipct = lipct;
+      long int lipct = pct = u * 10000 / t;
+      double ipct = lipct / 100.0;
 
 
       /* Like 'pct = ceil (dpct);', but without ceil - from coreutils again */
       /* Like 'pct = ceil (dpct);', but without ceil - from coreutils again */
       if (ipct - 1 < pct && pct <= ipct + 1)
       if (ipct - 1 < pct && pct <= ipct + 1)

+ 24 - 20
plugins/check_dns.c

@@ -102,12 +102,11 @@ main (int argc, char **argv)
   char query_found[24] = "";
   char query_found[24] = "";
   int query_size = 24;
   int query_size = 24;
   char *temp_buffer = NULL;
   char *temp_buffer = NULL;
-  int non_authoritative = TRUE;
+  int non_authoritative = FALSE;
   int result = STATE_UNKNOWN;
   int result = STATE_UNKNOWN;
   double elapsed_time;
   double elapsed_time;
   long microsec;
   long microsec;
   struct timeval tv;
   struct timeval tv;
-  int multi_address;
   int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
   int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
   output chld_out, chld_err;
   output chld_out, chld_err;
   size_t i;
   size_t i;
@@ -137,7 +136,7 @@ main (int argc, char **argv)
 
 
   /* run the command */
   /* run the command */
   if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) {
   if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) {
-    msg = (char *)_("nslookup returned an error status");
+    msg = strdup(_("nslookup returned an error status"));
     result = STATE_WARNING;
     result = STATE_WARNING;
   }
   }
 
 
@@ -184,10 +183,8 @@ main (int argc, char **argv)
 	}
 	}
     }
     }
 
 
-    if (strstr (chld_out.line[i], "Authoritative answers can be found from:")) {
-      non_authoritative = FALSE;
+    if (strstr (chld_out.line[i], "Authoritative answers can be found from:"))
       break;
       break;
-    }
     /* the server is responding, we just got the host name...*/
     /* the server is responding, we just got the host name...*/
     if (strstr (chld_out.line[i], "Name:"))
     if (strstr (chld_out.line[i], "Name:"))
       parse_address = TRUE;
       parse_address = TRUE;
@@ -198,8 +195,14 @@ main (int argc, char **argv)
     else IF_RECORD("nameserver =", "-querytype=NS", "Found NS record\n") }
     else IF_RECORD("nameserver =", "-querytype=NS", "Found NS record\n") }
     else IF_RECORD("dname =", "-querytype=DNAME", "Found DNAME record\n") }
     else IF_RECORD("dname =", "-querytype=DNAME", "Found DNAME record\n") }
     else IF_RECORD("protocol =", "-querytype=WKS", "Found WKS record\n") }
     else IF_RECORD("protocol =", "-querytype=WKS", "Found WKS record\n") }
-    /* TODO: needs to be changed to handle txt output and max size of txt recrods */
-    else IF_RECORD("text =", "-querytype=TXT", "Found TXT record\n") }
+    else if (strstr (chld_out.line[i], "text =") && (strncmp(query_type, "-querytype=TXT", query_size) == 0 || strncmp(query_type, "-querytype=ANY", query_size) == 0)) {
+      if (verbose) printf("Found TXT record\n");
+      temp_buffer = index(chld_out.line[i], '"');
+      --temp_buffer;
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      memset(query_found, '\0', sizeof(query_found));
+      strncpy(query_found, "-querytype=TXT", sizeof(query_found)); 
+    }
     /* only matching for origin records, if requested other fields could be included at a later date */
     /* only matching for origin records, if requested other fields could be included at a later date */
     else IF_RECORD("origin =", "-querytype=SOA", "Found SOA record\n") }
     else IF_RECORD("origin =", "-querytype=SOA", "Found SOA record\n") }
     /* cnames cannot use macro as we must check for accepting them separately */
     /* cnames cannot use macro as we must check for accepting them separately */
@@ -223,7 +226,7 @@ main (int argc, char **argv)
       if ((temp_buffer = strstr(chld_out.line[i], "name = ")))
       if ((temp_buffer = strstr(chld_out.line[i], "name = ")))
         addresses[n_addresses++] = strdup(temp_buffer);
         addresses[n_addresses++] = strdup(temp_buffer);
       else {
       else {
-        msg = (char *)_("Warning plugin error");
+        xasprintf(&msg, "%s %s %s %s", _("Warning plugin error"));
         result = STATE_WARNING;
         result = STATE_WARNING;
       }
       }
     }
     }
@@ -238,7 +241,10 @@ main (int argc, char **argv)
         ? tmp : result;
         ? tmp : result;
     if (result != STATE_OK) {
     if (result != STATE_OK) {
       msg = strchr (chld_out.line[i], ':');
       msg = strchr (chld_out.line[i], ':');
-      if(msg) msg++;
+      if(msg)
+			  msg++;
+			else
+			 msg = chld_out.line[i];
       break;
       break;
     }
     }
   }
   }
@@ -250,8 +256,11 @@ main (int argc, char **argv)
 
 
     if (error_scan (chld_err.line[i]) != STATE_OK) {
     if (error_scan (chld_err.line[i]) != STATE_OK) {
       result = max_state (result, error_scan (chld_err.line[i]));
       result = max_state (result, error_scan (chld_err.line[i]));
-      msg = strchr(input_buffer, ':');
-      if(msg) msg++;
+      msg = strchr(chld_err.line[i], ':');
+      if(msg)
+			  msg++;
+			else
+			  msg = chld_err.line[i];
     }
     }
   }
   }
 
 
@@ -289,7 +298,7 @@ main (int argc, char **argv)
   }
   }
 
 
   /* check if authoritative */
   /* check if authoritative */
-  if (result == STATE_OK && expect_authority && !non_authoritative) {
+  if (result == STATE_OK && expect_authority && non_authoritative) {
     result = STATE_CRITICAL;
     result = STATE_CRITICAL;
 
 
     if (strncmp(dns_server, "", 1))
     if (strncmp(dns_server, "", 1))
@@ -312,11 +321,6 @@ main (int argc, char **argv)
   elapsed_time = (double)microsec / 1.0e6;
   elapsed_time = (double)microsec / 1.0e6;
 
 
   if (result == STATE_OK) {
   if (result == STATE_OK) {
-    if (strchr (address, ',') == NULL)
-      multi_address = FALSE;
-    else
-      multi_address = TRUE;
-
     result = get_status(elapsed_time, time_thresholds);
     result = get_status(elapsed_time, time_thresholds);
     if (result == STATE_OK) {
     if (result == STATE_OK) {
       printf ("%s %s: ", _("DNS"), _("OK"));
       printf ("%s %s: ", _("DNS"), _("OK"));
@@ -489,13 +493,13 @@ process_arguments (int argc, char **argv)
     case 'a': /* expected address */
     case 'a': /* expected address */
       if (strlen (optarg) >= ADDRESS_LENGTH)
       if (strlen (optarg) >= ADDRESS_LENGTH)
         die (STATE_UNKNOWN, "%s\n", _("Input buffer overflow"));
         die (STATE_UNKNOWN, "%s\n", _("Input buffer overflow"));
-      expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
+      expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char*));
       expected_address[expected_address_cnt] = strdup(optarg);
       expected_address[expected_address_cnt] = strdup(optarg);
       expected_address_cnt++;
       expected_address_cnt++;
       break;
       break;
     case 'q': /* querytype -- A or AAAA or ANY or SRV or TXT, etc. */
     case 'q': /* querytype -- A or AAAA or ANY or SRV or TXT, etc. */
       if (strlen (optarg) < 1 || strlen (optarg) > 5)
       if (strlen (optarg) < 1 || strlen (optarg) > 5)
-	die (STATE_UNKNOWN, "%s\n", _("Missing valid querytype parameter.  Try using 'A' or 'AAAA' or 'SRV'"));
+        die (STATE_UNKNOWN, "%s\n", _("Missing valid querytype parameter.  Try using 'A' or 'AAAA' or 'SRV'"));
       strntoupper(optarg, strlen(optarg));
       strntoupper(optarg, strlen(optarg));
       strcpy(query_type, "-querytype=");
       strcpy(query_type, "-querytype=");
       strcat(query_type, optarg);
       strcat(query_type, optarg);

+ 23 - 4
plugins/check_hpjd.c

@@ -67,6 +67,7 @@ void print_usage (void);
 char *community = NULL;
 char *community = NULL;
 char *address = NULL;
 char *address = NULL;
 int port = 0;
 int port = 0;
+char flawcorrection =0; // There are devices which report offline when that is not the case. Correct that.
 
 
 int
 int
 main (int argc, char **argv)
 main (int argc, char **argv)
@@ -146,7 +147,8 @@ main (int argc, char **argv)
 
 
 		line++;
 		line++;
 
 
-		temp_buffer = strtok (input_buffer, "=");
+		/* We want the string after the "=" */
+		(void)strtok (input_buffer, "=");
 		temp_buffer = strtok (NULL, "=");
 		temp_buffer = strtok (NULL, "=");
 
 
 		if (temp_buffer == NULL && line < 13) {
 		if (temp_buffer == NULL && line < 13) {
@@ -155,7 +157,6 @@ main (int argc, char **argv)
 				strcpy (errmsg, input_buffer);
 				strcpy (errmsg, input_buffer);
 
 
 		} else {
 		} else {
-
 			switch (line) {
 			switch (line) {
 
 
 			case 1:										/* 1st line should contain the line status */
 			case 1:										/* 1st line should contain the line status */
@@ -193,6 +194,16 @@ main (int argc, char **argv)
 				break;
 				break;
 			case 12:										/* display panel message */
 			case 12:										/* display panel message */
 				strcpy (display_message, temp_buffer + 1);
 				strcpy (display_message, temp_buffer + 1);
+				if (
+                                    (flawcorrection)                   &&
+                                    (!strcmp(display_message,"READY")) &&
+                                    (!paper_status)                    &&
+                                    (!intervention_required)           &&
+                                    (!peripheral_error)                &&
+                                    (!paper_jam)                       &&
+                                    (!paper_out)
+                                   ) 
+                                   line_status = 0;    
 				break;
 				break;
 			default:										/* fold multiline message */
 			default:										/* fold multiline message */
 				strncat (display_message, input_buffer,
 				strncat (display_message, input_buffer,
@@ -315,6 +326,7 @@ process_arguments (int argc, char **argv)
 /*  		{"critical",       required_argument,0,'c'}, */
 /*  		{"critical",       required_argument,0,'c'}, */
 /*  		{"warning",        required_argument,0,'w'}, */
 /*  		{"warning",        required_argument,0,'w'}, */
   		{"port", required_argument,0,'p'}, 
   		{"port", required_argument,0,'p'}, 
+		{"flawcorrection", no_argument, 0, 'N'},
 		{"version", no_argument, 0, 'V'},
 		{"version", no_argument, 0, 'V'},
 		{"help", no_argument, 0, 'h'},
 		{"help", no_argument, 0, 'h'},
 		{0, 0, 0, 0}
 		{0, 0, 0, 0}
@@ -325,7 +337,7 @@ process_arguments (int argc, char **argv)
 
 
 
 
 	while (1) {
 	while (1) {
-		c = getopt_long (argc, argv, "+hVH:C:p:", longopts, &option);
+		c = getopt_long (argc, argv, "+hVNH:C:p:", longopts, &option);
 
 
 		if (c == -1 || c == EOF || c == 1)
 		if (c == -1 || c == EOF || c == 1)
 			break;
 			break;
@@ -348,6 +360,9 @@ process_arguments (int argc, char **argv)
 			else
 			else
 				port = atoi(optarg);
 				port = atoi(optarg);
 			break;
 			break;
+                case 'N':                                                                       /* flaw correction */
+                        flawcorrection=1;
+                        break;
 		case 'V':									/* version */
 		case 'V':									/* version */
 			print_revision (progname, NP_VERSION);
 			print_revision (progname, NP_VERSION);
 			exit (STATE_OK);
 			exit (STATE_OK);
@@ -420,6 +435,10 @@ print_help (void)
 	printf ("    %s", _("Specify the port to check "));
 	printf ("    %s", _("Specify the port to check "));
 	printf (_("(default=%s)"), DEFAULT_PORT);
 	printf (_("(default=%s)"), DEFAULT_PORT);
 	printf ("\n");
 	printf ("\n");
+        printf (" %s\n", "-N, --flawcorrection");
+	printf ("    %s", _("Correct false offline status reports "));
+	printf (_("(default=%s)"), "false");
+	printf ("\n");
 
 
 	printf (UT_SUPPORT);
 	printf (UT_SUPPORT);
 }
 }
@@ -430,5 +449,5 @@ void
 print_usage (void)
 print_usage (void)
 {
 {
   printf ("%s\n", _("Usage:"));
   printf ("%s\n", _("Usage:"));
-	printf ("%s -H host [-C community] [-p port]\n", progname);
+	printf ("%s -H host [-C community] [-p port][-N]\n", progname);
 }
 }

+ 78 - 63
plugins/check_http.c

@@ -982,6 +982,8 @@ check_http (void)
   int page_len = 0;
   int page_len = 0;
   int result = STATE_OK;
   int result = STATE_OK;
   char *force_host_header = NULL;
   char *force_host_header = NULL;
+	int bad_response = FALSE;
+	char save_char;
 
 
   /* try to connect to the host at the given port number */
   /* try to connect to the host at the given port number */
   gettimeofday (&tv_temp, NULL);
   gettimeofday (&tv_temp, NULL);
@@ -1023,8 +1025,8 @@ check_http (void)
     elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
     elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
     if (check_cert == TRUE) {
     if (check_cert == TRUE) {
       result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
       result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
-      np_net_ssl_cleanup();
       if (sd) close(sd);
       if (sd) close(sd);
+      np_net_ssl_cleanup();
       return result;
       return result;
     }
     }
   }
   }
@@ -1169,17 +1171,17 @@ check_http (void)
     die (STATE_CRITICAL, _("HTTP CRITICAL - No data received from host\n"));
     die (STATE_CRITICAL, _("HTTP CRITICAL - No data received from host\n"));
 
 
   /* close the connection */
   /* close the connection */
+  if (sd) close(sd);
 #ifdef HAVE_SSL
 #ifdef HAVE_SSL
   np_net_ssl_cleanup();
   np_net_ssl_cleanup();
 #endif
 #endif
-  if (sd) close(sd);
 
 
   /* Save check time */
   /* Save check time */
   microsec = deltime (tv);
   microsec = deltime (tv);
   elapsed_time = (double)microsec / 1.0e6;
   elapsed_time = (double)microsec / 1.0e6;
 
 
   /* leave full_page untouched so we can free it later */
   /* leave full_page untouched so we can free it later */
-  page = full_page;
+  pos = page = full_page;
 
 
   if (verbose)
   if (verbose)
     printf ("%s://%s:%d%s is %d characters\n",
     printf ("%s://%s:%d%s is %d characters\n",
@@ -1187,36 +1189,29 @@ check_http (void)
       server_port, server_url, (int)pagesize);
       server_port, server_url, (int)pagesize);
 
 
   /* find status line and null-terminate it */
   /* find status line and null-terminate it */
-  status_line = page;
-  page = strstr(page, "\r\n");
-  page += 2;
-/*  page += (size_t) strcspn (page, "\r\n"); */
-/*  page += (size_t) strspn (page, "\r\n"); */
+  page += (size_t) strcspn (page, "\r\n");
+	save_char = *page;
+	*page = '\0';
+	status_line = strdup(pos);
+	*page = save_char;
   pos = page;
   pos = page;
 
 
-  status_line[strcspn(status_line, "\r\n")] = 0;
   strip (status_line);
   strip (status_line);
   if (verbose)
   if (verbose)
     printf ("STATUS: %s\n", status_line);
     printf ("STATUS: %s\n", status_line);
 
 
   /* find header info and null-terminate it */
   /* find header info and null-terminate it */
   header = page;
   header = page;
-/*  while (strcspn (page, "\r\n") > 0) { */
-  while (page[0] != '\r' || page[1] != '\n') {
+	for (;;) {
+		if (!strncmp(page, "\r\n\r\n", 4) || !strncmp(page, "\n\n", 2))
+		 break;
+		while (*page == '\r' || *page == '\n') { ++page; }
     page += (size_t) strcspn (page, "\r\n");
     page += (size_t) strcspn (page, "\r\n");
     pos = page;
     pos = page;
-    if ((strspn (page, "\r") == 1 && strspn (page, "\r\n") >= 2) ||
-        (strspn (page, "\n") == 1 && strspn (page, "\r\n") >= 2)) {
-      page += (size_t) 2;
-      pos += (size_t) 2;
-    }
-    else {
-      page += (size_t) 1;
-      pos += (size_t) 1;
-    }
   }
   }
   page += (size_t) strspn (page, "\r\n");
   page += (size_t) strspn (page, "\r\n");
   header[pos - header] = 0;
   header[pos - header] = 0;
+	while (*header == '\r' || *header == '\n') { ++header; }
 
 
   if (chunked_transfer_encoding(header) && *page)
   if (chunked_transfer_encoding(header) && *page)
     page = decode_chunked_page(page, page);
     page = decode_chunked_page(page, page);
@@ -1235,58 +1230,64 @@ check_http (void)
       xasprintf (&msg,
       xasprintf (&msg,
                 _("Invalid HTTP response received from host on port %d: %s\n"),
                 _("Invalid HTTP response received from host on port %d: %s\n"),
                 server_port, status_line);
                 server_port, status_line);
-    die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg);
+    bad_response = TRUE;
   }
   }
 
 
   /* Bypass normal status line check if server_expect was set by user and not default */
   /* Bypass normal status line check if server_expect was set by user and not default */
   /* NOTE: After this if/else block msg *MUST* be an asprintf-allocated string */
   /* NOTE: After this if/else block msg *MUST* be an asprintf-allocated string */
-  if ( server_expect_yn  )  {
-    xasprintf (&msg,
-              _("Status line output matched \"%s\" - "), server_expect);
-    if (verbose)
-      printf ("%s\n",msg);
+  if ( !bad_response ) {
+    if ( server_expect_yn  )  {
+      xasprintf (&msg,
+                _("Status line output matched \"%s\" - "), server_expect);
+      if (verbose)
+        printf ("%s\n",msg);
+    } else
+      xasprintf (&msg, "");
   }
   }
-  else {
-    /* Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF */
-    /* HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT */
-    /* Status-Code = 3 DIGITS */
 
 
-    status_code = strchr (status_line, ' ') + sizeof (char);
-    if (strspn (status_code, "1234567890") != 3)
-      die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status Line (%s)\n"), status_line);
+  /* Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF */
+  /* HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT */
+  /* Status-Code = 3 DIGITS */
 
 
-    http_status = atoi (status_code);
+  status_code = strchr (status_line, ' ') + sizeof (char);
+  if (strspn (status_code, "1234567890") != 3)
+    die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status Line (%s)\n"), status_line);
 
 
-    /* check the return code */
+  http_status = atoi (status_code);
 
 
-    if (http_status >= 600 || http_status < 100) {
-      die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status (%s)\n"), status_line);
-    }
-    /* server errors result in a critical state */
-    else if (http_status >= 500) {
-      xasprintf (&msg, _("%s - "), status_line);
-      result = STATE_CRITICAL;
-    }
-    /* client errors result in a warning state */
-    else if (http_status >= 400) {
-      xasprintf (&msg, _("%s - "), status_line);
-      result = max_state_alt(STATE_WARNING, result);
-    }
-    /* check redirected page if specified */
-    else if (http_status >= 300) {
+  /* check the return code */
 
 
-      if (onredirect == STATE_DEPENDENT)
-        redir (header, status_line);
-      else
-        result = max_state_alt(onredirect, result);
-      xasprintf (&msg, _("%s - "), status_line);
-    } /* end if (http_status >= 300) */
-    else {
-      /* Print OK status anyway */
-      xasprintf (&msg, _("%s - "), status_line);
-    }
+  if (http_status >= 600 || http_status < 100) {
+    die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status (%s)\n"), status_line);
+  }
+  /* server errors result in a critical state */
+  else if (http_status >= 500) {
+    xasprintf (&msg, _("%s%s - "), msg, status_line);
+    result = STATE_CRITICAL;
+  }
+  /* client errors result in a warning state */
+  else if (http_status >= 400) {
+    xasprintf (&msg, _("%s%s - "), msg, status_line);
+    result = max_state_alt(STATE_WARNING, result);
+  }
+  /* check redirected page if specified */
+  else if (http_status >= 300) {
+
+    if (onredirect == STATE_DEPENDENT)
+      redir (header, status_line);
+    else
+      result = max_state_alt(onredirect, result);
+    xasprintf (&msg, _("%s%s - "), msg, status_line);
+  } /* end if (http_status >= 300) */
+  else if (!bad_response) {
+    /* Print OK status anyway */
+    xasprintf (&msg, _("%s%s - "), msg, status_line);
+  }
+
+	free(status_line);
 
 
-  } /* end else (server_expect_yn)  */
+  if (bad_response) 
+    die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg);
 
 
   /* reset the alarm - must be called *after* redir or we'll never die on redirects! */
   /* reset the alarm - must be called *after* redir or we'll never die on redirects! */
   alarm (0);
   alarm (0);
@@ -1403,7 +1404,9 @@ check_http (void)
 #define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH
 #define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH
 #define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT
 #define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT
 #define HD4 URI_HTTP "://" URI_HOST
 #define HD4 URI_HTTP "://" URI_HOST
-#define HD5 URI_PATH
+/* HD5 - relative reference redirect like //www.site.org/test https://tools.ietf.org/html/rfc3986 */
+#define HD5 URI_HTTP "//" URI_HOST "/" URI_PATH
+#define HD6 URI_PATH
 
 
 void
 void
 redir (char *pos, char *status_line)
 redir (char *pos, char *status_line)
@@ -1481,8 +1484,19 @@ redir (char *pos, char *status_line)
       i = server_port_check (use_ssl);
       i = server_port_check (use_ssl);
     }
     }
 
 
+    /* URI_HTTP, URI_HOST, URI_PATH */
+    else if (sscanf (pos, HD5, addr, url) == 2) {
+      if(use_ssl)
+        strcpy (type,"https");
+      else
+        strcpy (type,"server_type");
+      xasprintf(&url, "/%s", url);
+      use_ssl = server_type_check (type);
+      i = server_port_check (use_ssl);
+    }
+
     /* URI_PATH */
     /* URI_PATH */
-    else if (sscanf (pos, HD5, url) == 1) {
+    else if (sscanf (pos, HD6, url) == 1) {
       /* relative url */
       /* relative url */
       if ((url[0] != '/')) {
       if ((url[0] != '/')) {
         if ((x = strrchr(server_url, '/')))
         if ((x = strrchr(server_url, '/')))
@@ -1727,6 +1741,7 @@ print_help (void)
   printf (" %s\n", _("messages from the host result in STATE_WARNING return values.  If you are"));
   printf (" %s\n", _("messages from the host result in STATE_WARNING return values.  If you are"));
   printf (" %s\n", _("checking a virtual server that uses 'host headers' you must supply the FQDN"));
   printf (" %s\n", _("checking a virtual server that uses 'host headers' you must supply the FQDN"));
   printf (" %s\n", _("(fully qualified domain name) as the [host_name] argument."));
   printf (" %s\n", _("(fully qualified domain name) as the [host_name] argument."));
+  printf (" %s\n", _("You may also need to give a FQDN or IP address using -I (or --IP-Address)."));
 
 
 #ifdef HAVE_SSL
 #ifdef HAVE_SSL
   printf ("\n");
   printf ("\n");

+ 5 - 0
plugins/check_load.c

@@ -194,7 +194,12 @@ main (int argc, char **argv)
 
 
 	/* we got this far, so assume OK until we've measured */
 	/* we got this far, so assume OK until we've measured */
 	result = STATE_OK;
 	result = STATE_OK;
+	
+	if (take_into_account_cpus == 1 && (numcpus = GET_NUMBER_OF_CPUS()) > 1){
 
 
+	xasprintf(&status_line, _("load average per CPU: %.2f, %.2f, %.2f"), la1, la5, la15);
+	}
+	else
 	xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
 	xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
 
 
 	for(i = 0; i < 3; i++) {
 	for(i = 0; i < 3; i++) {

+ 1 - 1
plugins/check_mrtg.c

@@ -148,7 +148,7 @@ main (int argc, char **argv)
 	else if (rate > value_warning_threshold)
 	else if (rate > value_warning_threshold)
 		result = STATE_WARNING;
 		result = STATE_WARNING;
 
 
-	printf("%s. %s = %lu %s|%s\n",
+	printf("%s - %s. %s = %lu %s|%s\n", state_text(result),
 	       (use_average == TRUE) ? _("Avg") : _("Max"),
 	       (use_average == TRUE) ? _("Avg") : _("Max"),
 	       label, rate, units,
 	       label, rate, units,
 	       perfdata(label, (long) rate, units,
 	       perfdata(label, (long) rate, units,

+ 1 - 1
plugins/check_nagios.c

@@ -160,7 +160,7 @@ main (int argc, char **argv)
 
 
 	/* If we get anything on stderr, at least set warning */
 	/* If we get anything on stderr, at least set warning */
 	if(chld_err.buflen)
 	if(chld_err.buflen)
-		result = max_state (result, STATE_WARNING);
+		(void)max_state (result, STATE_WARNING);
 
 
 	/* reset the alarm handler */
 	/* reset the alarm handler */
 	alarm (0);
 	alarm (0);

+ 3 - 5
plugins/check_ntp.c

@@ -356,7 +356,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
  *   we have to do it in a way that our lazy macros don't handle currently :( */
  *   we have to do it in a way that our lazy macros don't handle currently :( */
 double offset_request(const char *host, int *status){
 double offset_request(const char *host, int *status){
 	int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
 	int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
-	int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
+	int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
 	time_t now_time=0, start_ts=0;
 	time_t now_time=0, start_ts=0;
 	ntp_message *req=NULL;
 	ntp_message *req=NULL;
 	double avg_offset=0.;
 	double avg_offset=0.;
@@ -421,7 +421,6 @@ double offset_request(const char *host, int *status){
 		 * been touched in the past second or so and is still lacking
 		 * been touched in the past second or so and is still lacking
 		 * some responses.  for each of these servers, send a new request,
 		 * some responses.  for each of these servers, send a new request,
 		 * and update the "waiting" timestamp with the current time. */
 		 * and update the "waiting" timestamp with the current time. */
-		one_written=0;
 		now_time=time(NULL);
 		now_time=time(NULL);
 
 
 		for(i=0; i<num_hosts; i++){
 		for(i=0; i<num_hosts; i++){
@@ -430,8 +429,8 @@ double offset_request(const char *host, int *status){
 				if(verbose) printf("sending request to peer %d\n", i);
 				if(verbose) printf("sending request to peer %d\n", i);
 				setup_request(&req[i]);
 				setup_request(&req[i]);
 				write(socklist[i], &req[i], sizeof(ntp_message));
 				write(socklist[i], &req[i], sizeof(ntp_message));
+				if(servers[i].waiting == 0) now_time++;
 				servers[i].waiting=now_time;
 				servers[i].waiting=now_time;
-				one_written=1;
 				break;
 				break;
 			}
 			}
 		}
 		}
@@ -461,7 +460,6 @@ double offset_request(const char *host, int *status){
 				servers[i].stratum=req[i].stratum;
 				servers[i].stratum=req[i].stratum;
 				servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp);
 				servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp);
 				servers[i].rtdelay=NTP32asDOUBLE(req[i].rtdelay);
 				servers[i].rtdelay=NTP32asDOUBLE(req[i].rtdelay);
-				servers[i].waiting=0;
 				servers[i].flags=req[i].flags;
 				servers[i].flags=req[i].flags;
 				servers_readable--;
 				servers_readable--;
 				one_read = 1;
 				one_read = 1;
@@ -773,7 +771,7 @@ int main(int argc, char *argv[]){
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	textdomain (PACKAGE);
 	textdomain (PACKAGE);
 
 
-	result = offset_result = jitter_result = STATE_OK;
+	offset_result = jitter_result = STATE_OK;
 
 
 	/* Parse extra opts if any */
 	/* Parse extra opts if any */
 	argv=np_extra_opts (&argc, argv, progname);
 	argv=np_extra_opts (&argc, argv, progname);

+ 2 - 4
plugins/check_ntp_time.c

@@ -302,7 +302,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
  *   we have to do it in a way that our lazy macros don't handle currently :( */
  *   we have to do it in a way that our lazy macros don't handle currently :( */
 double offset_request(const char *host, int *status){
 double offset_request(const char *host, int *status){
 	int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
 	int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
-	int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
+	int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
 	time_t now_time=0, start_ts=0;
 	time_t now_time=0, start_ts=0;
 	ntp_message *req=NULL;
 	ntp_message *req=NULL;
 	double avg_offset=0.;
 	double avg_offset=0.;
@@ -367,7 +367,6 @@ double offset_request(const char *host, int *status){
 		 * been touched in the past second or so and is still lacking
 		 * been touched in the past second or so and is still lacking
 		 * some responses. For each of these servers, send a new request,
 		 * some responses. For each of these servers, send a new request,
 		 * and update the "waiting" timestamp with the current time. */
 		 * and update the "waiting" timestamp with the current time. */
-		one_written=0;
 		now_time=time(NULL);
 		now_time=time(NULL);
 
 
 		for(i=0; i<num_hosts; i++){
 		for(i=0; i<num_hosts; i++){
@@ -377,7 +376,6 @@ double offset_request(const char *host, int *status){
 				setup_request(&req[i]);
 				setup_request(&req[i]);
 				write(socklist[i], &req[i], sizeof(ntp_message));
 				write(socklist[i], &req[i], sizeof(ntp_message));
 				servers[i].waiting=now_time;
 				servers[i].waiting=now_time;
-				one_written=1;
 				break;
 				break;
 			}
 			}
 		}
 		}
@@ -549,7 +547,7 @@ int main(int argc, char *argv[]){
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	textdomain (PACKAGE);
 	textdomain (PACKAGE);
 
 
-	result = offset_result = STATE_OK;
+	offset_result = STATE_OK;
 
 
 	/* Parse extra opts if any */
 	/* Parse extra opts if any */
 	argv=np_extra_opts (&argc, argv, progname);
 	argv=np_extra_opts (&argc, argv, progname);

+ 0 - 5
plugins/check_nwstat.c

@@ -513,10 +513,6 @@ main(int argc, char **argv) {
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
 		if (result!=STATE_OK)
 			return result;
 			return result;
-		if (atoi(recv_buffer)==1)
-			result=STATE_OK;
-		else
-			result=STATE_WARNING;
 
 
 		close(sd);
 		close(sd);
 		my_tcp_connect (server_address, server_port, &sd);
 		my_tcp_connect (server_address, server_port, &sd);
@@ -796,7 +792,6 @@ main(int argc, char **argv) {
 				result=STATE_CRITICAL;
 				result=STATE_CRITICAL;
 			else if (check_warning_value==TRUE && percent_non_purgeable_space >= warning_value)
 			else if (check_warning_value==TRUE && percent_non_purgeable_space >= warning_value)
 				result=STATE_WARNING;
 				result=STATE_WARNING;
-			purgeable_disk_space/=1024;
 			xasprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name);
 			xasprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name);
 		}
 		}
 
 

+ 16 - 15
plugins/check_real.c

@@ -95,22 +95,24 @@ main (int argc, char **argv)
 
 
 	/* send the OPTIONS request */
 	/* send the OPTIONS request */
 	sprintf (buffer, "OPTIONS rtsp://%s:%d RTSP/1.0\r\n", host_name, server_port);
 	sprintf (buffer, "OPTIONS rtsp://%s:%d RTSP/1.0\r\n", host_name, server_port);
-	result = send (sd, buffer, strlen (buffer), 0);
+	if (send (sd, buffer, strlen (buffer), 0) == -1)
+		die (STATE_CRITICAL, _("Can not send data to %s\n"), host_name);
 
 
 	/* send the header sync */
 	/* send the header sync */
 	sprintf (buffer, "CSeq: 1\r\n");
 	sprintf (buffer, "CSeq: 1\r\n");
-	result = send (sd, buffer, strlen (buffer), 0);
+	if (send (sd, buffer, strlen (buffer), 0) == -1)
+		die (STATE_CRITICAL, _("Can not send data to %s\n"), host_name);
 
 
 	/* send a newline so the server knows we're done with the request */
 	/* send a newline so the server knows we're done with the request */
 	sprintf (buffer, "\r\n");
 	sprintf (buffer, "\r\n");
-	result = send (sd, buffer, strlen (buffer), 0);
+	if (send (sd, buffer, strlen (buffer), 0) == -1)
+		die (STATE_CRITICAL, _("Can not send data to %s\n"), host_name);
 
 
 	/* watch for the REAL connection string */
 	/* watch for the REAL connection string */
-	result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
-
-	/* return a CRITICAL status if we couldn't read any data */
-	if (result == -1)
+	if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) {
+		/* return a CRITICAL status if we couldn't read any data */
 		die (STATE_CRITICAL, _("No data received from %s\n"), host_name);
 		die (STATE_CRITICAL, _("No data received from %s\n"), host_name);
+	}
 
 
 	/* make sure we find the response we are looking for */
 	/* make sure we find the response we are looking for */
 	if (!strstr (buffer, server_expect)) {
 	if (!strstr (buffer, server_expect)) {
@@ -125,8 +127,6 @@ main (int argc, char **argv)
 
 
 		time (&end_time);
 		time (&end_time);
 
 
-		result = STATE_OK;
-
 		status_line = (char *) strtok (buffer, "\n");
 		status_line = (char *) strtok (buffer, "\n");
 
 
 		if (strstr (status_line, "200"))
 		if (strstr (status_line, "200"))
@@ -159,22 +159,25 @@ main (int argc, char **argv)
 	}
 	}
 
 
 	/* Part II - Check stream exists and is ok */
 	/* Part II - Check stream exists and is ok */
-	if ((result == STATE_OK )&& (server_url != NULL) ) {
+	if ((result == STATE_OK ) && (server_url != NULL) ) {
 
 
 		/* Part I - Server Check */
 		/* Part I - Server Check */
 
 
 		/* send the DESCRIBE request */
 		/* send the DESCRIBE request */
 		sprintf (buffer, "DESCRIBE rtsp://%s:%d%s RTSP/1.0\r\n", host_name,
 		sprintf (buffer, "DESCRIBE rtsp://%s:%d%s RTSP/1.0\r\n", host_name,
 						 server_port, server_url);
 						 server_port, server_url);
-		result = send (sd, buffer, strlen (buffer), 0);
+		if (send (sd, buffer, strlen (buffer), 0) == -1)
+			die (STATE_CRITICAL, _("Can not send data to %s\n"), host_name);
 
 
 		/* send the header sync */
 		/* send the header sync */
 		sprintf (buffer, "CSeq: 2\r\n");
 		sprintf (buffer, "CSeq: 2\r\n");
-		result = send (sd, buffer, strlen (buffer), 0);
+		if (send (sd, buffer, strlen (buffer), 0) == -1)
+			die (STATE_CRITICAL, _("Can not send data to %s\n"), host_name);
 
 
 		/* send a newline so the server knows we're done with the request */
 		/* send a newline so the server knows we're done with the request */
 		sprintf (buffer, "\r\n");
 		sprintf (buffer, "\r\n");
-		result = send (sd, buffer, strlen (buffer), 0);
+		if (send (sd, buffer, strlen (buffer), 0) == -1)
+			die (STATE_CRITICAL, _("Can not send data to %s\n"), host_name);
 
 
 		/* watch for the REAL connection string */
 		/* watch for the REAL connection string */
 		result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
 		result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
@@ -200,8 +203,6 @@ main (int argc, char **argv)
 
 
 				time (&end_time);
 				time (&end_time);
 
 
-				result = STATE_OK;
-
 				status_line = (char *) strtok (buffer, "\n");
 				status_line = (char *) strtok (buffer, "\n");
 
 
 				if (strstr (status_line, "200"))
 				if (strstr (status_line, "200"))

+ 19 - 7
plugins/check_smtp.c

@@ -55,6 +55,7 @@ enum {
 #define SMTP_EXPECT "220"
 #define SMTP_EXPECT "220"
 #define SMTP_HELO "HELO "
 #define SMTP_HELO "HELO "
 #define SMTP_EHLO "EHLO "
 #define SMTP_EHLO "EHLO "
+#define SMTP_LHLO "LHLO "
 #define SMTP_QUIT "QUIT\r\n"
 #define SMTP_QUIT "QUIT\r\n"
 #define SMTP_STARTTLS "STARTTLS\r\n"
 #define SMTP_STARTTLS "STARTTLS\r\n"
 #define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
 #define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
@@ -106,6 +107,7 @@ int check_critical_time = FALSE;
 int verbose = 0;
 int verbose = 0;
 int use_ssl = FALSE;
 int use_ssl = FALSE;
 short use_ehlo = FALSE;
 short use_ehlo = FALSE;
+short use_lhlo = FALSE;
 short ssl_established = 0;
 short ssl_established = 0;
 char *localhostname = NULL;
 char *localhostname = NULL;
 int sd;
 int sd;
@@ -165,7 +167,9 @@ main (int argc, char **argv)
 			return STATE_CRITICAL;
 			return STATE_CRITICAL;
 		}
 		}
 	}
 	}
-	if(use_ehlo)
+	if(use_lhlo)
+		xasprintf (&helocmd, "%s%s%s", SMTP_LHLO, localhostname, "\r\n");
+	else if(use_ehlo)
 		xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
 		xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
 	else
 	else
 		xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
 		xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
@@ -222,7 +226,7 @@ main (int argc, char **argv)
 		if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
 		if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
 			printf (_("recv() failed\n"));
 			printf (_("recv() failed\n"));
 			return STATE_WARNING;
 			return STATE_WARNING;
-		} else if(use_ehlo){
+		} else if(use_ehlo || use_lhlo){
 			if(strstr(buffer, "250 STARTTLS") != NULL ||
 			if(strstr(buffer, "250 STARTTLS") != NULL ||
 			   strstr(buffer, "250-STARTTLS") != NULL){
 			   strstr(buffer, "250-STARTTLS") != NULL){
 				supports_tls=TRUE;
 				supports_tls=TRUE;
@@ -249,8 +253,8 @@ main (int argc, char **argv)
 		  result = np_net_ssl_init(sd);
 		  result = np_net_ssl_init(sd);
 		  if(result != STATE_OK) {
 		  if(result != STATE_OK) {
 		    printf (_("CRITICAL - Cannot create SSL context.\n"));
 		    printf (_("CRITICAL - Cannot create SSL context.\n"));
-		    np_net_ssl_cleanup();
 		    close(sd);
 		    close(sd);
+		    np_net_ssl_cleanup();
 		    return STATE_CRITICAL;
 		    return STATE_CRITICAL;
 		  } else {
 		  } else {
 			ssl_established = 1;
 			ssl_established = 1;
@@ -476,6 +480,7 @@ process_arguments (int argc, char **argv)
 		{"use-ipv4", no_argument, 0, '4'},
 		{"use-ipv4", no_argument, 0, '4'},
 		{"use-ipv6", no_argument, 0, '6'},
 		{"use-ipv6", no_argument, 0, '6'},
 		{"help", no_argument, 0, 'h'},
 		{"help", no_argument, 0, 'h'},
+		{"lmtp", no_argument, 0, 'L'},
 		{"starttls",no_argument,0,'S'},
 		{"starttls",no_argument,0,'S'},
 		{"certificate",required_argument,0,'D'},
 		{"certificate",required_argument,0,'D'},
 		{"ignore-quit-failure",no_argument,0,'q'},
 		{"ignore-quit-failure",no_argument,0,'q'},
@@ -495,7 +500,7 @@ process_arguments (int argc, char **argv)
 	}
 	}
 
 
 	while (1) {
 	while (1) {
-		c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:q",
+		c = getopt_long (argc, argv, "+hVv46Lt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q",
 		                 longopts, &option);
 		                 longopts, &option);
 
 
 		if (c == -1 || c == EOF)
 		if (c == -1 || c == EOF)
@@ -617,6 +622,9 @@ process_arguments (int argc, char **argv)
 			use_ssl = TRUE;
 			use_ssl = TRUE;
 			use_ehlo = TRUE;
 			use_ehlo = TRUE;
 			break;
 			break;
+		case 'L':
+			use_lhlo = TRUE;
+			break;
 		case '4':
 		case '4':
 			address_family = AF_INET;
 			address_family = AF_INET;
 			break;
 			break;
@@ -769,10 +777,12 @@ recvlines(char *buf, size_t bufsize)
 int
 int
 my_close (void)
 my_close (void)
 {
 {
+	int result;
+	result = close(sd);
 #ifdef HAVE_SSL
 #ifdef HAVE_SSL
-  np_net_ssl_cleanup();
+	np_net_ssl_cleanup();
 #endif
 #endif
-  return close(sd);
+	return result;
 }
 }
 
 
 
 
@@ -823,6 +833,8 @@ print_help (void)
   printf ("    %s\n", _("SMTP AUTH username"));
   printf ("    %s\n", _("SMTP AUTH username"));
   printf (" %s\n", "-P, --authpass=STRING");
   printf (" %s\n", "-P, --authpass=STRING");
   printf ("    %s\n", _("SMTP AUTH password"));
   printf ("    %s\n", _("SMTP AUTH password"));
+  printf (" %s\n", "-L, --lmtp");
+  printf ("    %s\n", _("Send LHLO instead of HELO/EHLO"));
   printf (" %s\n", "-q, --ignore-quit-failure");
   printf (" %s\n", "-q, --ignore-quit-failure");
   printf ("    %s\n", _("Ignore failure when sending QUIT command to server"));
   printf ("    %s\n", _("Ignore failure when sending QUIT command to server"));
    
    
@@ -849,6 +861,6 @@ print_usage (void)
   printf ("%s\n", _("Usage:"));
   printf ("%s\n", _("Usage:"));
   printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
   printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
   printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
   printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
-  printf ("[-F fqdn] [-S] [-D warn days cert expire[,crit days cert expire]] [-v] \n");
+  printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-v] \n");
 }
 }
 
 

+ 0 - 11
plugins/check_snmp.c

@@ -599,17 +599,6 @@ main (int argc, char **argv)
 				strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
 				strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
 				}
 				}
 
 
-			if (warning_thresholds) {
-				strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
-				strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
-			}
-
-			if (critical_thresholds) {
-				if (!warning_thresholds) strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
-				strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
-				strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
-			}
-
 			if (type)
 			if (type)
 				strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
 				strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
 
 

+ 2 - 2
plugins/check_tcp.c

@@ -248,8 +248,8 @@ main (int argc, char **argv)
 		}
 		}
 	}
 	}
 	if(result != STATE_OK){
 	if(result != STATE_OK){
-		np_net_ssl_cleanup();
 		if(sd) close(sd);
 		if(sd) close(sd);
+		np_net_ssl_cleanup();
 		return result;
 		return result;
 	}
 	}
 #endif /* HAVE_SSL */
 #endif /* HAVE_SSL */
@@ -322,10 +322,10 @@ main (int argc, char **argv)
 	if (server_quit != NULL) {
 	if (server_quit != NULL) {
 		my_send(server_quit, strlen(server_quit));
 		my_send(server_quit, strlen(server_quit));
 	}
 	}
+	if (sd) close (sd);
 #ifdef HAVE_SSL
 #ifdef HAVE_SSL
 	np_net_ssl_cleanup();
 	np_net_ssl_cleanup();
 #endif
 #endif
-	if (sd) close (sd);
 
 
 	microsec = deltime (tv);
 	microsec = deltime (tv);
 	elapsed_time = (double)microsec / 1.0e6;
 	elapsed_time = (double)microsec / 1.0e6;

+ 0 - 1
plugins/check_uptime.c

@@ -180,7 +180,6 @@ static int process_arguments (int argc, char **argv) {
 			} // end case
 			} // end case
 		} // end while
 		} // end while
 
 
-	c = optind;
 	set_thresholds(&my_thresholds, warning, critical);
 	set_thresholds(&my_thresholds, warning, critical);
 	return validate_arguments ();
 	return validate_arguments ();
 
 

+ 7 - 0
plugins/common.h

@@ -161,6 +161,13 @@
 #  endif
 #  endif
 #endif
 #endif
 
 
+/* openssl 1.1 does not set OPENSSL_NO_SSL2 by default but ships without ssl2 */
+#ifdef OPENSSL_VERSION_NUMBER
+#  if OPENSSL_VERSION_NUMBER >= 0x10100000
+#   define OPENSSL_NO_SSL2
+#  endif
+#endif
+
 /*
 /*
  *
  *
  * Standard Values
  * Standard Values

+ 0 - 2
plugins/netutils.c

@@ -160,8 +160,6 @@ process_request (const char *server_address, int server_port, int proto,
 	int result;
 	int result;
 	int sd;
 	int sd;
 
 
-	result = STATE_OK;
-
 	result = np_net_connect (server_address, server_port, &sd, proto);
 	result = np_net_connect (server_address, server_port, &sd, proto);
 	if (result != STATE_OK)
 	if (result != STATE_OK)
 		return STATE_CRITICAL;
 		return STATE_CRITICAL;

+ 5 - 1
po/de.po

@@ -7,7 +7,7 @@
 #
 #
 msgid ""
 msgid ""
 msgstr ""
 msgstr ""
-"Project-Id-Version: nagiosplug\n"
+"Project-Id-Version: de\n"
 "Report-Msgid-Bugs-To: devel@nagios-plugins.org\n"
 "Report-Msgid-Bugs-To: devel@nagios-plugins.org\n"
 "POT-Creation-Date: 2010-07-09 19:30-0400\n"
 "POT-Creation-Date: 2010-07-09 19:30-0400\n"
 "PO-Revision-Date: 2004-12-23 17:46+0100\n"
 "PO-Revision-Date: 2004-12-23 17:46+0100\n"
@@ -1484,6 +1484,10 @@ msgstr ""
 msgid "(fully qualified domain name) as the [host_name] argument."
 msgid "(fully qualified domain name) as the [host_name] argument."
 msgstr ""
 msgstr ""
 
 
+#: plugins/check_http.c:1408
+msgid "You may also need to give a FQDN or IP address using -I (or --IP-Address)."
+msgstr ""
+
 #: plugins/check_http.c:1411
 #: plugins/check_http.c:1411
 msgid "This plugin can also check whether an SSL enabled web server is able to"
 msgid "This plugin can also check whether an SSL enabled web server is able to"
 msgstr ""
 msgstr ""

+ 4 - 0
po/fr.po

@@ -1525,6 +1525,10 @@ msgstr ""
 msgid "(fully qualified domain name) as the [host_name] argument."
 msgid "(fully qualified domain name) as the [host_name] argument."
 msgstr ""
 msgstr ""
 
 
+#: plugins/check_http.c:1408
+msgid "You may also need to give a FQDN or IP address using -I (or --IP-Address)."
+msgstr ""
+
 #: plugins/check_http.c:1411
 #: plugins/check_http.c:1411
 msgid "This plugin can also check whether an SSL enabled web server is able to"
 msgid "This plugin can also check whether an SSL enabled web server is able to"
 msgstr ""
 msgstr ""