Просмотр исходного кода

Merge branch 'master' of git://github.com/nagios-plugins/nagios-plugins

abrist 12 лет назад
Родитель
Сommit
4eed6ad60a
77 измененных файлов с 684 добавлено и 277 удалено
  1. 2 0
      NEWS
  2. 21 12
      NPTest.pm
  3. 3 0
      THANKS.in
  4. 7 3
      configure.ac
  5. 2 2
      doc/developer-guidelines.sgml
  6. 1 1
      lib/extra_opts.c
  7. 1 1
      lib/parse_ini.c
  8. 65 3
      lib/tests/test_utils.c
  9. 28 5
      lib/utils_base.c
  10. 11 1
      lib/utils_base.h
  11. 1 1
      lib/utils_cmd.c
  12. 1 1
      lib/utils_disk.c
  13. 1 1
      lib/utils_tcp.c
  14. 1 1
      m4/np_mysqlclient.m4
  15. 2 3
      plugins/Makefile.am
  16. 2 2
      plugins/check_apt.c
  17. 2 2
      plugins/check_by_ssh.c
  18. 2 2
      plugins/check_cluster.c
  19. 2 2
      plugins/check_dbi.c
  20. 2 2
      plugins/check_disk.c
  21. 151 37
      plugins/check_dns.c
  22. 2 2
      plugins/check_dummy.c
  23. 2 2
      plugins/check_fping.c
  24. 2 2
      plugins/check_game.c
  25. 2 2
      plugins/check_hpjd.c
  26. 2 2
      plugins/check_http.c
  27. 2 2
      plugins/check_ide_smart.c
  28. 2 2
      plugins/check_ldap.c
  29. 2 2
      plugins/check_load.c
  30. 2 2
      plugins/check_mrtg.c
  31. 2 2
      plugins/check_mrtgtraf.c
  32. 22 4
      plugins/check_mysql.c
  33. 2 2
      plugins/check_mysql_query.c
  34. 2 2
      plugins/check_nagios.c
  35. 2 2
      plugins/check_nt.c
  36. 2 2
      plugins/check_ntp.c
  37. 39 14
      plugins/check_ntp_peer.c
  38. 14 5
      plugins/check_ntp_time.c
  39. 2 2
      plugins/check_nwstat.c
  40. 2 2
      plugins/check_overcr.c
  41. 2 2
      plugins/check_pgsql.c
  42. 2 2
      plugins/check_ping.c
  43. 2 2
      plugins/check_procs.c
  44. 2 2
      plugins/check_radius.c
  45. 2 2
      plugins/check_real.c
  46. 2 2
      plugins/check_smtp.c
  47. 3 3
      plugins/check_snmp.c
  48. 22 8
      plugins/check_ssh.c
  49. 7 6
      plugins/check_swap.c
  50. 9 4
      plugins/check_tcp.c
  51. 2 2
      plugins/check_time.c
  52. 2 2
      plugins/check_ups.c
  53. 2 2
      plugins/check_users.c
  54. 1 1
      plugins/common.h
  55. 2 21
      plugins/negate.c
  56. 1 1
      plugins/netutils.c
  57. 1 1
      plugins/netutils.h
  58. 1 1
      plugins/popen.c
  59. 1 1
      plugins/runcmd.c
  60. 1 1
      plugins/runcmd.h
  61. 5 6
      plugins/sslutils.c
  62. 5 5
      plugins/t/check_dig.t
  63. 49 6
      plugins/t/check_dns.t
  64. 3 3
      plugins/t/check_jabber.t
  65. 2 2
      plugins/t/check_ntp.t
  66. 30 7
      plugins/t/check_pop.t
  67. 32 24
      plugins/tests/check_procs.t
  68. 30 2
      plugins/tests/check_snmp.t
  69. 7 7
      plugins/tests/check_snmp_agent.pl
  70. 2 2
      plugins/urlize.c
  71. 21 1
      plugins/utils.c
  72. 4 0
      plugins/utils.h
  73. 1 1
      po/de.po
  74. 1 1
      po/fr.po
  75. 8 5
      test.pl.in
  76. 1 1
      tools/generate-change-log
  77. 1 1
      tools/git-notify

+ 2 - 0
NEWS

@@ -10,6 +10,7 @@ This file documents the major additions and syntax changes between releases.
 	New check_mysql_query -f/-g options for reading for mysql options file (awiddersheim)
 	check_mailq now supports nullmailer in the mailserver -M switch (Luca Corti)
 	New check_dig -r option for specifying number of retries (abrist)
+	check_ntp_peer - Added state output for each checked metric (abrist)
 
 	FIXES
 	Don't let e.g. check_http's -C option reset SSL version if e.g. -S 1 -C 5 is specified
@@ -25,6 +26,7 @@ This file documents the major additions and syntax changes between releases.
 	Fixed newlines in parse.ini output (dermoth)
 	check_dig: fix wrong IPv6 arguments order (Stéphane Bortzmeyer)
 	check_dig: now honors timeout value specified by switch -t (Jethro Carr) (abrist)
+	Configure option --enable-extra-opts is now enabled by default (dermoth)
 
 	WARNINGS
 	check_procs now ignores its parent process to avoid unexpected results when invoked via certain shells

+ 21 - 12
NPTest.pm

@@ -494,26 +494,35 @@ sub SetCacheFilename
 
 sub DetermineTestHarnessDirectory
 {
-  my( $userSupplied ) = @_;
+  my( @userSupplied ) = @_;
+  my @dirs;
 
   # User Supplied
-  if ( defined( $userSupplied ) && $userSupplied )
+  if ( @userSupplied > 0 )
   {
-    if ( -d $userSupplied )
+    for my $u ( @userSupplied )
     {
-      return $userSupplied;
-    }
-    else
-    {
-      return undef; # userSupplied is invalid -> FAIL
+      if ( -d $u )
+      {
+        push ( @dirs, $u );
+      }
     }
   }
 
-  # Simple Case : "t" is a subdirectory of the current directory
+  # Simple Cases: "t" and tests are subdirectories of the current directory
   if ( -d "./t" )
   {
-    return "./t";
+    push ( @dirs, "./t");
   }
+  if ( -d "./tests" )
+  {
+    push ( @dirs, "./tests");
+  }
+
+	if ( @dirs > 0 )
+	{
+		return @dirs;
+	}
 
   # To be honest I don't understand which case satisfies the
   # original code in test.pl : when $tstdir == `pwd` w.r.t.
@@ -526,7 +535,7 @@ sub DetermineTestHarnessDirectory
 
   if ( $pwd =~ m|/t$| )
   {
-    return $pwd;
+    push ( @dirs, $pwd );
 
     # The alternate that might work better is
     # chdir( ".." );
@@ -535,7 +544,7 @@ sub DetermineTestHarnessDirectory
     # to be tested is in the current directory (ie "./check_disk ....")
   }
 
-  return undef;
+  return @dirs;
 }
 
 sub TestsFrom

+ 3 - 0
THANKS.in

@@ -309,3 +309,6 @@ Tilmann Bubeck
 Stéphane Bortzmeyer
 Luca Corti
 Jethro Carr
+Neil Prockter
+Patrick McAndrew
+Julius Kriukas

+ 7 - 3
configure.in → configure.ac

@@ -6,6 +6,7 @@ AC_CONFIG_FILES([gl/Makefile
 	nagios-plugins.spec])
 AC_CONFIG_AUX_DIR(build-aux)
 AM_INIT_AUTOMAKE([1.8.3])
+AM_MAINTAINER_MODE([enable])
 AC_CONFIG_HEADERS([config.h])
 AC_CANONICAL_HOST
 
@@ -194,7 +195,7 @@ AC_ARG_ENABLE(extra-opts,
   AC_HELP_STRING([--enable-extra-opts],
 		[Enables parsing of plugins ini config files for extra options (default: no)]),
 	[enable_extra_opts=$enableval],
-	[enable_extra_opts=no])
+	[enable_extra_opts=yes])
 AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
 if test "$enable_extra_opts" = "yes" ; then
 	AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
@@ -1472,9 +1473,12 @@ else
 fi
 
 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
-if test -x "$PATH_TO_QMAIL_QSTAT"
+AC_ARG_WITH(qmail_qstat_command,
+            ACX_HELP_STRING([--with-qmail-qstat-command=PATH],
+                            [sets path to qmail-qstat]), PATH_TO_QMAIL_QSTAT=$withval)
+if test -n "$PATH_TO_QMAIL_QSTAT"
 then
-	AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
+	AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
 else
 	AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
 fi

+ 2 - 2
doc/developer-guidelines.sgml

@@ -22,7 +22,7 @@
     </revhistory>
 
 	<copyright>
-		<year>2000 - 2013</year>
+		<year>2000 - 2014</year>
 		<holder>Nagios Plugins Development Team</holder>
 	</copyright>
 
@@ -34,7 +34,7 @@
     the plugin developers and encourage the standarization of the
     different kind of plugins: C, shell, perl, python, etc.</para>
 
-        <para>Nagios Plugin Development Guidelines Copyright (C) 2000-2013
+        <para>Nagios Plugin Development Guidelines Copyright (C) 2000-2014
         (Nagios Plugins Team)</para>
 
         <para>Permission is granted to make and distribute verbatim

+ 1 - 1
lib/extra_opts.c

@@ -3,7 +3,7 @@
 * Nagios-plugins extra_opts library
 * 
 * License: GPL
-* Copyright (c) 2007 Nagios Plugins Development Team
+* Copyright (c) 2007-2014 Nagios Plugins Development Team
 * 
 * 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

+ 1 - 1
lib/parse_ini.c

@@ -3,7 +3,7 @@
 * Nagios-plugins parse_ini library
 * 
 * License: GPL
-* Copyright (c) 2007 Nagios Plugins Development Team
+* Copyright (c) 2007-2014 Nagios Plugins Development Team
 * 
 * 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

+ 65 - 3
lib/tests/test_utils.c

@@ -32,13 +32,13 @@ main (int argc, char **argv)
 	range	*range;
 	double	temp;
 	thresholds *thresholds = NULL;
-	int	rc;
+	int	i, rc;
 	char	*temp_string;
 	state_key *temp_state_key = NULL;
 	state_data *temp_state_data;
 	time_t	current_time;
 
-	plan_tests(150);
+	plan_tests(185);
 
 	ok( this_nagios_plugin==NULL, "nagios_plugin not initialised");
 
@@ -182,6 +182,21 @@ main (int argc, char **argv)
 	ok( get_status(30.0001, thresholds) == STATE_WARNING, "30.0001 - warning");
 	ok( get_status(69, thresholds) == STATE_CRITICAL, "69 - critical");
 
+	rc = _set_thresholds(&thresholds, "-10:-2", "-30:20");
+	ok( rc == 0, "Thresholds ('-30:20', '-10:-2') set");
+	ok( thresholds->warning->start == -10, "Warning start set correctly");
+	ok( thresholds->warning->end == -2, "Warning end set correctly");
+	ok( thresholds->critical->start == -30, "Critical start set correctly");
+	ok( thresholds->critical->end == 20, "Critical end set correctly");
+	ok( get_status(-31, thresholds) == STATE_CRITICAL, "-31 - critical");
+	ok( get_status(-29, thresholds) == STATE_WARNING, "-29 - warning");
+	ok( get_status(-11, thresholds) == STATE_WARNING, "-11 - warning");
+	ok( get_status(-10, thresholds) == STATE_OK, "-10 - ok");
+	ok( get_status(-2, thresholds) == STATE_OK, "-2 - ok");
+	ok( get_status(-1, thresholds) == STATE_WARNING, "-1 - warning");
+	ok( get_status(19, thresholds) == STATE_WARNING, "19 - warning");
+	ok( get_status(21, thresholds) == STATE_CRITICAL, "21 - critical");
+
 	char *test;
 	test = np_escaped_string("bob\\n");
 	ok( strcmp(test, "bob\n") == 0, "bob\\n ok");
@@ -438,7 +453,54 @@ main (int argc, char **argv)
 
 	np_cleanup();
 
-	ok( this_nagios_plugin==NULL, "Free'd this_nagios_plugin" );
+	ok(this_nagios_plugin==NULL, "Free'd this_nagios_plugin" );
+
+	ok(np_suid() == FALSE, "Tests aren't suid" );
+
+	/* base states with random case */
+	char *states[] = {
+		"Ok",
+		"wArnINg",
+		"cRiTIcaL",
+		"UnKNoWN",
+		NULL
+	};
+
+	for (i=0; states[i]!=NULL; i++) {
+		/* out of the random case states, create the lower and upper versions + numeric string one */
+		char *statelower = strdup(states[i]);
+		char *stateupper = strdup(states[i]);
+		char statenum[2];
+		char *temp_ptr;
+		for (temp_ptr = statelower; *temp_ptr; temp_ptr++) {
+			*temp_ptr = tolower(*temp_ptr);
+		}
+		for (temp_ptr = stateupper; *temp_ptr; temp_ptr++) {
+			*temp_ptr = toupper(*temp_ptr);
+		}
+		snprintf(statenum, 2, "%i", i);
+
+		/* Base test names, we'll append the state string */
+		char testname[64] = "Translate state string: ";
+		int tlen = strlen(testname);
+
+		strcpy(testname+tlen, states[i]);
+		ok(i==translate_state(states[i]), testname);
+
+		strcpy(testname+tlen, statelower);
+		ok(i==translate_state(statelower), testname);
+
+		strcpy(testname+tlen, stateupper);
+		ok(i==translate_state(stateupper), testname);
+
+		strcpy(testname+tlen, statenum);
+		ok(i==translate_state(statenum), testname);
+	}
+	ok(ERROR==translate_state("warningfewgw"), "Translate state string with garbage");
+	ok(ERROR==translate_state("00"), "Translate state string: bad numeric string 1");
+	ok(ERROR==translate_state("01"), "Translate state string: bad numeric string 2");
+	ok(ERROR==translate_state("10"), "Translate state string: bad numeric string 3");
+	ok(ERROR==translate_state(""), "Translate state string: empty string");
 
 	return exit_status();
 }

+ 28 - 5
lib/utils_base.c

@@ -3,7 +3,7 @@
 * utils_base.c
 *
 * License: GPL
-* Copyright (c) 2006 Nagios Plugins Development Team
+* Copyright (c) 2006-2014 Nagios Plugins Development Team
 *
 * Library of useful functions for plugins
 * 
@@ -30,6 +30,8 @@
 #include <ctype.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <unistd.h>
+#include <sys/types.h>
 
 #define np_free(ptr) { if(ptr) { free(ptr); ptr = NULL; } }
 
@@ -367,6 +369,22 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
 	return value;
 }
 
+/*
+ * Read a string representing a state (ok, warning... or numeric: 0, 1) and
+ * return the corresponding STATE_ value or ERROR)
+ */
+int translate_state (char *state_text) {
+       if (!strcasecmp(state_text,"OK") || !strcmp(state_text,"0"))
+               return STATE_OK;
+       if (!strcasecmp(state_text,"WARNING") || !strcmp(state_text,"1"))
+               return STATE_WARNING;
+       if (!strcasecmp(state_text,"CRITICAL") || !strcmp(state_text,"2"))
+               return STATE_CRITICAL;
+       if (!strcasecmp(state_text,"UNKNOWN") || !strcmp(state_text,"3"))
+               return STATE_UNKNOWN;
+       return ERROR;
+}
+
 /*
  * Returns a string to use as a keyname, based on an md5 hash of argv, thus
  * hopefully a unique key per service/plugin invocation. Use the extra-opts
@@ -415,10 +433,15 @@ void _cleanup_state_data() {
 char* _np_state_calculate_location_prefix(){
 	char *env_dir;
 
-	env_dir = getenv("NAGIOS_PLUGIN_STATE_DIRECTORY");
-	if(env_dir && env_dir[0] != '\0')
-		return env_dir;
-	return NP_STATE_DIR_PREFIX;
+	/* Do not allow passing NP_STATE_DIRECTORY in setuid plugins
+	 * for security reasons */
+
+	if (np_suid() == FALSE) {
+		env_dir = getenv("NAGIOS_PLUGIN_STATE_DIRECTORY");
+		if(env_dir && env_dir[0] != '\0')
+			return env_dir;
+		return NP_STATE_DIR_PREFIX;
+	}
 }
 
 /*

+ 11 - 1
lib/utils_base.h

@@ -62,7 +62,7 @@ int check_range(double, range *);
 int get_status(double, thresholds *);
 
 /* All possible characters in a threshold range */
-#define NP_THRESHOLDS_CHARS "0123456789.:@~"
+#define NP_THRESHOLDS_CHARS "-0123456789.:@~"
 
 char *np_escaped_string (const char *);
 
@@ -79,6 +79,12 @@ int np_check_if_root(void);
  * code from the above function, in case it's helpful for testing */
 int np_warn_if_not_root(void);
 
+/*
+ * Read a string representing a state (ok, warning... or numeric: 0, 1) and
+ * return the corresponding NP_STATE or ERROR)
+ */
+int translate_state (char *);
+
 /*
  * Extract the value from key/value pairs, or return NULL. The value returned
  * can be free()ed.
@@ -102,4 +108,8 @@ void np_init(char *, int argc, char **argv);
 void np_set_args(int argc, char **argv);
 void np_cleanup();
 
+/* np_suid() returns true if the real and effective uids differs, such as when
++ * running a suid plugin */
+#define np_suid() (getuid() != geteuid())
+
 #endif /* _UTILS_BASE_ */

+ 1 - 1
lib/utils_cmd.c

@@ -3,7 +3,7 @@
 * Nagios run command utilities
 *
 * License: GPL
-* Copyright (c) 2005-2006 Nagios Plugins Development Team
+* Copyright (c) 2005-2014 Nagios Plugins Development Team
 *
 * Description :
 *

+ 1 - 1
lib/utils_disk.c

@@ -3,7 +3,7 @@
 * Library for check_disk
 * 
 * License: GPL
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 

+ 1 - 1
lib/utils_tcp.c

@@ -3,7 +3,7 @@
 * Library for check_tcp
 * 
 * License: GPL
-* Copyright (c) 1999-2013 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 

+ 1 - 1
m4/np_mysqlclient.m4

@@ -1,5 +1,5 @@
 # np_mysqlclient.m4
-dnl Copyright (C) 2007 Nagios Plugins Team
+dnl Copyright (C) 2007-2014 Nagios Plugins Team
 dnl This file is free software; the Nagios Plugin Team
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.

+ 2 - 3
plugins/Makefile.am

@@ -11,7 +11,7 @@ endif
 
 AM_CFLAGS = -DNP_VERSION='"$(NP_VERSION)"'
 
-VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t 
+VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t
 
 INCLUDES = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl @LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@
 
@@ -130,11 +130,10 @@ install-exec-hook:
 	cd $(DESTDIR)$(libexecdir) && \
 	for i in $(check_tcp_programs) ; do rm -f $$i; ln -s check_tcp $$i ; done ;\
 	if [ -x check_ldap ] ; then rm -f check_ldaps ; ln -s check_ldap check_ldaps ; fi
-	
+
 clean-local:
 	rm -f $(check_tcp_programs)
 	rm -f NP-VERSION-FILE
 
 uninstall-local:
 	cd $(DESTDIR)$(libexecdir) && rm -f $(check_tcp_programs)
-

+ 2 - 2
plugins/check_apt.c

@@ -3,7 +3,7 @@
 * Nagios check_apt plugin
 * 
 * License: GPL
-* Copyright (c) 2006-2008 Nagios Plugins Development Team
+* Copyright (c) 2006-2014 Nagios Plugins Development Team
 * 
 * Original author: Sean Finney
 * 
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_apt";
-const char *copyright = "2006-2008";
+const char *copyright = "2006-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_by_ssh.c

@@ -3,7 +3,7 @@
 * Nagios check_by_ssh plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2008 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -27,7 +27,7 @@
 *****************************************************************************/
 
 const char *progname = "check_by_ssh";
-const char *copyright = "2000-2008";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_cluster.c

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)
-* Copyright (c) 2007 Nagios Plugins Development Team
+* Copyright (c) 2007-2014 Nagios Plugins Development Team
 * 
 * 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
@@ -23,7 +23,7 @@
 *****************************************************************************/
 
 const char *progname = "check_cluster";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_dbi.c

@@ -3,7 +3,7 @@
 * Nagios check_dbi plugin
 * 
 * License: GPL
-* Copyright (c) 2011 Nagios Plugins Development Team
+* Copyright (c) 2011-2014 Nagios Plugins Development Team
 * Author: Sebastian 'tokkee' Harl <sh@teamix.net>
 * 
 * Description:
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_dbi";
-const char *copyright = "2011";
+const char *copyright = "2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_disk.c

@@ -3,7 +3,7 @@
 * Nagios check_disk plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2008 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -28,7 +28,7 @@
 
 const char *progname = "check_disk";
 const char *program_name = "check_disk";  /* Required for coreutils libs */
-const char *copyright = "1999-2008";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 

+ 151 - 37
plugins/check_dns.c

@@ -45,15 +45,17 @@ int error_scan (char *);
 void print_help (void);
 void print_usage (void);
 
-#define ADDRESS_LENGTH 256
+#define ADDRESS_LENGTH 384 
 char query_address[ADDRESS_LENGTH] = "";
 char dns_server[ADDRESS_LENGTH] = "";
 char ptr_server[ADDRESS_LENGTH] = "";
+char query_type[16] = "";
 int verbose = FALSE;
 char **expected_address = NULL;
 int expected_address_cnt = 0;
 
 int expect_authority = FALSE;
+int accept_cname = FALSE;
 thresholds *time_thresholds = NULL;
 
 static int
@@ -65,6 +67,22 @@ qstrcmp(const void *p1, const void *p2)
 	return strcmp(* (char * const *) p1, * (char * const *) p2);
 }
 
+char *
+check_new_address(char *temp_buffer)
+{
+      temp_buffer++;
+      /* Strip leading spaces */
+      for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
+        /* NOOP */;
+
+      strip(temp_buffer);
+      if (temp_buffer==NULL || strlen(temp_buffer)==0) {
+        die (STATE_CRITICAL,
+             _("DNS CRITICAL - '%s' returned empty host name string\n"),
+             NSLOOKUP_COMMAND);
+      }
+      return temp_buffer;
+}
 
 int
 main (int argc, char **argv)
@@ -75,8 +93,9 @@ main (int argc, char **argv)
   char **addresses = NULL;
   int n_addresses = 0;
   char *msg = NULL;
+  char query_found[16] = "";
   char *temp_buffer = NULL;
-  int non_authoritative = FALSE;
+  int non_authoritative = TRUE;
   int result = STATE_UNKNOWN;
   double elapsed_time;
   long microsec;
@@ -103,7 +122,7 @@ main (int argc, char **argv)
   }
 
   /* get the command to run */
-  xasprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server);
+  xasprintf (&command_line, "%s %s %s %s", NSLOOKUP_COMMAND, query_type, query_address, dns_server);
 
   alarm (timeout_interval);
   gettimeofday (&tv, NULL);
@@ -127,40 +146,87 @@ main (int argc, char **argv)
     if (verbose)
       puts(chld_out.line[i]);
 
-    if (strstr (chld_out.line[i], ".in-addr.arpa")) {
-      if ((temp_buffer = strstr (chld_out.line[i], "name = ")))
-        addresses[n_addresses++] = strdup (temp_buffer + 7);
-      else {
-        msg = (char *)_("Warning plugin error");
-        result = STATE_WARNING;
-      }
+    if (strstr (chld_out.line[i], "Authoritative answers can be found from:")) {
+      non_authoritative = FALSE;
+      break;
     }
-
     /* the server is responding, we just got the host name... */
     if (strstr (chld_out.line[i], "Name:"))
       parse_address = TRUE;
-    else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") ||
-             strstr (chld_out.line[i], "Addresses:"))) {
+    /* begin handling types of records */
+    if (strstr (chld_out.line[i], "AAAA address")) {
+      if (verbose) printf("Found AAAA record\n");
+      temp_buffer = rindex (chld_out.line[i], ' ');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=AAAA", sizeof(query_found));
+    }
+    else if (strstr (chld_out.line[i], "exchanger =")) {
+      if (verbose) printf("Found MX record\n");
+      temp_buffer = index (chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=MX", sizeof(query_found));
+    }
+    else if (strstr (chld_out.line[i], "service =")) {
+      if (verbose) printf("Found SRV record\n");
+      temp_buffer = index (chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=SRV", sizeof(query_found));
+    }
+    else if (accept_cname && strstr (chld_out.line[i], "canonical name =")) {
+      if (verbose) printf("Found CNAME record\n");
+      temp_buffer = index (chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=CNAME", sizeof(query_found));
+    }
+    else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") || strstr (chld_out.line[i], "Addresses:"))) {
+      if (verbose) printf("Found A record\n");
       temp_buffer = index (chld_out.line[i], ':');
-      temp_buffer++;
-
-      /* Strip leading spaces */
-      for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
-        /* NOOP */;
-
-      strip(temp_buffer);
-      if (temp_buffer==NULL || strlen(temp_buffer)==0) {
-        die (STATE_CRITICAL,
-             _("DNS CRITICAL - '%s' returned empty host name string\n"),
-             NSLOOKUP_COMMAND);
-      }
-
-      addresses[n_addresses++] = strdup(temp_buffer);
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=A", sizeof(query_found));
     }
-    else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {
-      non_authoritative = TRUE;
+    else if (strstr (chld_out.line[i], "nameserver =")) {
+      if (verbose) printf("Found NS record\n");
+      temp_buffer = index (chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=NS", sizeof(query_found));
+    }
+    else if (strstr (chld_out.line[i], "dname =")) {
+      if (verbose) printf("Found DNAME record\n");
+      temp_buffer = index (chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=DNAME", sizeof(query_found));
+    }
+    /* must be after other records with "name" as an identifier, as ptr does not spefify */
+    else if (strstr (chld_out.line[i], "name =")) {
+      if (verbose) printf("Found PTR record\n");
+      temp_buffer = index (chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=PTR", sizeof(query_found));
+    }
+    else if (strstr (chld_out.line[i], "protocol =")) {
+      if (verbose) printf("Found WKS record\n");
+      temp_buffer = index (chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=WKS", sizeof(query_found));
+    }
+    /* TODO: needs to be changed to handle txt output and max size of txt recrods */
+    else if (strstr (chld_out.line[i], "text =")) {
+      if (verbose) printf("Found TXT record\n");
+      temp_buffer = index (chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=TXT", sizeof(query_found));
+    }
+    /* only matching for origin records, if requested other fields could be included at a later date */
+    else if (strstr (chld_out.line[i], "origin =")) {
+      if (verbose) printf("Found SOA record\n");
+      temp_buffer = index(chld_out.line[i], '=');
+      addresses[n_addresses++] = check_new_address(temp_buffer);
+      strncpy(query_found, "-querytype=SOA", sizeof(query_found));
     }
 
+    if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {
+      non_authoritative = TRUE;
+    }
 
     result = error_scan (chld_out.line[i]);
     if (result != STATE_OK) {
@@ -171,7 +237,7 @@ main (int argc, char **argv)
   }
 
   /* scan stderr */
-  for(i = 0; i < chld_err.lines; i++) {
+  for(i = 0; i < chld_err.lines; i++) { 
     if (verbose)
       puts(chld_err.line[i]);
 
@@ -218,9 +284,23 @@ main (int argc, char **argv)
   }
 
   /* check if authoritative */
-  if (result == STATE_OK && expect_authority && non_authoritative) {
+  if (result == STATE_OK && expect_authority && !non_authoritative) {
     result = STATE_CRITICAL;
-    xasprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address);
+
+    if (strncmp(dns_server, "", 1))
+      xasprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address);
+    else
+      xasprintf(&msg, _("there is no authoritative server for %s"), query_address);
+  }
+
+  /* compare query type to query found, if query type is ANY we can skip as any record is accepted*/
+  if (result == STATE_OK && strncmp(query_type, "", 1) && (strncmp(query_type, "-querytype=ANY", 15) != 0)) {
+    if (strncmp(query_type, query_found, 16) != 0) {
+      if (verbose)
+        printf( "Failed query for %s only found %s, or nothing\n", query_type, query_found);
+      result = STATE_CRITICAL;
+      xasprintf(&msg, _("query type of %s was not found for %s"), query_type, query_address);
+    }
   }
 
   microsec = deltime (tv);
@@ -242,7 +322,23 @@ main (int argc, char **argv)
     }
     printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
     printf (_(". %s returns %s"), query_address, address);
-    printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
+    if ((time_thresholds->warning != NULL) && (time_thresholds->critical != NULL)) {
+      printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
+                                  TRUE, time_thresholds->warning->end,
+                                  TRUE, time_thresholds->critical->end,
+                                  TRUE, 0, FALSE, 0));
+    } else if ((time_thresholds->warning == NULL) && (time_thresholds->critical != NULL)) {
+      printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
+                                  FALSE, 0,
+                                  TRUE, time_thresholds->critical->end,
+                                  TRUE, 0, FALSE, 0));
+    } else if ((time_thresholds->warning != NULL) && (time_thresholds->critical == NULL)) {
+      printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
+                                  TRUE, time_thresholds->warning->end,
+                                  FALSE, 0,
+                                  TRUE, 0, FALSE, 0));
+    } else
+      printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
   }
   else if (result == STATE_WARNING)
     printf (_("DNS WARNING - %s\n"),
@@ -274,7 +370,7 @@ error_scan (char *input_buffer)
     die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
 
   /* Host name is valid, but server doesn't have records... */
-  else if (strstr (input_buffer, "No records"))
+  else if (strstr (input_buffer, "No records") || strstr (input_buffer, "No answer"))
     die (STATE_CRITICAL, _("DNS %s has no records\n"), dns_server);
 
   /* Connection was refused */
@@ -316,7 +412,6 @@ error_scan (char *input_buffer)
 
 }
 
-
 /* process command-line arguments */
 int
 process_arguments (int argc, char **argv)
@@ -334,8 +429,10 @@ process_arguments (int argc, char **argv)
     {"hostname", required_argument, 0, 'H'},
     {"server", required_argument, 0, 's'},
     {"reverse-server", required_argument, 0, 'r'},
+    {"querytype", required_argument, 0, 'q'},
     {"expected-address", required_argument, 0, 'a'},
     {"expect-authority", no_argument, 0, 'A'},
+    {"accept-cname", no_argument, 0, 'n'},
     {"warning", required_argument, 0, 'w'},
     {"critical", required_argument, 0, 'c'},
     {0, 0, 0, 0}
@@ -349,7 +446,7 @@ process_arguments (int argc, char **argv)
       strcpy (argv[c], "-t");
 
   while (1) {
-    c = getopt_long (argc, argv, "hVvAt:H:s:r:a:w:c:", long_opts, &opt_index);
+    c = getopt_long (argc, argv, "hVvAnt:H:s:r:a:q:w:c:", long_opts, &opt_index);
 
     if (c == -1 || c == EOF)
       break;
@@ -394,9 +491,19 @@ process_arguments (int argc, char **argv)
       expected_address[expected_address_cnt] = strdup(optarg);
       expected_address_cnt++;
       break;
+    case 'q': /* querytype -- A or AAAA or ANY or SRV or TXT, etc. */
+      if (strlen (optarg) < 1 || strlen (optarg) > 5)
+	die (STATE_UNKNOWN, _("Missing valid querytype parameter.  Try using 'A' or 'AAAA' or 'SRV'\n"));
+      strntoupper(optarg, sizeof(optarg));
+      strcpy(query_type, "-querytype=");
+      strcat(query_type, optarg);
+      break;
     case 'A': /* expect authority */
       expect_authority = TRUE;
       break;
+    case 'n': /* accept cname responses as a result */
+      accept_cname = TRUE;
+      break;
     case 'w':
       warning = optarg;
       break;
@@ -462,13 +569,20 @@ print_help (void)
   printf ("    %s\n", _("The name or address you want to query"));
   printf (" -s, --server=HOST\n");
   printf ("    %s\n", _("Optional DNS server you want to use for the lookup"));
+  printf (" -q, --querytype=TYPE\n");
+  printf ("    %s\n", _("Optional DNS record query type where TYPE =(A, AAAA, SRV, TXT, MX, ANY)"));
+  printf ("    %s\n", _("The default query type is 'A' (IPv4 host entry)"));
   printf (" -a, --expected-address=IP-ADDRESS|HOST\n");
   printf ("    %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with"));
   printf ("    %s\n", _("a dot (.). This option can be repeated multiple times (Returns OK if any"));
   printf ("    %s\n", _("value match). If multiple addresses are returned at once, you have to match"));
   printf ("    %s\n", _("the whole string of addresses separated with commas (sorted alphabetically)."));
+  printf ("    %s\n", _("If you would like to test for the presence of a cname, combine with -n param."));
   printf (" -A, --expect-authority\n");
   printf ("    %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
+  printf (" -n, --accept-cname\n");
+  printf ("    %s\n", _("Optionally accept cname responses as a valid result to a query"));
+  printf ("    %s\n", _("The default is to ignore cname responses as part of the result"));
   printf (" -w, --warning=seconds\n");
   printf ("    %s\n", _("Return warning if elapsed time exceeds value. Default off"));
   printf (" -c, --critical=seconds\n");
@@ -484,5 +598,5 @@ void
 print_usage (void)
 {
   printf ("%s\n", _("Usage:"));
-  printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit]\n", progname);
+  printf ("%s -H host [-s server] [-q type ] [-a expected-address] [-A] [-n] [-t timeout] [-w warn] [-c crit]\n", progname);
 }

+ 2 - 2
plugins/check_dummy.c

@@ -3,7 +3,7 @@
 * Nagios check_dummy plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_dummy";
-const char *copyright = "1999-2007";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_fping.c

@@ -3,7 +3,7 @@
 * Nagios check_fping plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_fping";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_game.c

@@ -3,7 +3,7 @@
 * Nagios check_game plugin
 * 
 * License: GPL
-* Copyright (c) 2002-2007 Nagios Plugins Development Team
+* Copyright (c) 2002-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_game";
-const char *copyright = "2002-2007";
+const char *copyright = "2002-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_hpjd.c

@@ -3,7 +3,7 @@
 * Nagios check_hpjd plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_hpjd";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_http.c

@@ -3,7 +3,7 @@
 * Nagios check_http plugin
 *
 * License: GPL
-* Copyright (c) 1999-2013 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 *
 * Description:
 *
@@ -34,7 +34,7 @@
 /* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */
 
 const char *progname = "check_http";
-const char *copyright = "1999-2013";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_ide_smart.c

@@ -7,7 +7,7 @@
 * Copyright (C) 1998-1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>
 *               1998      Gadi Oxman <gadio@netvision.net.il>
 * Copyright (c) 2000 Robert Dale <rdale@digital-mission.com>
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -34,7 +34,7 @@
 *****************************************************************************/
 
 const char *progname = "check_ide_smart";
-const char *copyright = "1998-2007";
+const char *copyright = "1998-2014";
 const char *email = "devel@nagios-plugins.org";
 	
 #include "common.h"

+ 2 - 2
plugins/check_ldap.c

@@ -3,7 +3,7 @@
 * Nagios check_ldap plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2008 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -28,7 +28,7 @@
 
 /* progname may be check_ldaps */
 char *progname = "check_ldap";
-const char *copyright = "2000-2008";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_load.c

@@ -3,7 +3,7 @@
 * Nagios check_load plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_load";
-const char *copyright = "1999-2007";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_mrtg.c

@@ -3,7 +3,7 @@
 * Nagios check_mrtg plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_mrtg";
-const char *copyright = "1999-2007";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_mrtgtraf.c

@@ -3,7 +3,7 @@
 * Nagios check_mrtgtraf plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -33,7 +33,7 @@
 #include "utils.h"
 
 const char *progname = "check_mrtgtraf";
-const char *copyright = "1999-2007";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 int process_arguments (int, char **);

+ 22 - 4
plugins/check_mysql.c

@@ -5,7 +5,7 @@
 * License: GPL
 * Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)
 * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
-* Copyright (c) 1999-2011 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -31,7 +31,7 @@
 *****************************************************************************/
 
 const char *progname = "check_mysql";
-const char *copyright = "1999-2011";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #define SLAVERESULTSIZE 70
@@ -42,6 +42,7 @@ const char *email = "devel@nagios-plugins.org";
 #include "netutils.h"
 
 #include <mysql.h>
+#include <mysqld_error.h>
 #include <errmsg.h>
 
 char *db_user = NULL;
@@ -59,6 +60,7 @@ char *opt_file = NULL;
 char *opt_group = NULL;
 unsigned int db_port = MYSQL_PORT;
 int check_slave = 0, warn_sec = 0, crit_sec = 0;
+int ignore_auth = 0;
 int verbose = 0;
 
 static double warning_time = 0;
@@ -136,7 +138,16 @@ main (int argc, char **argv)
 		mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers);
 	/* establish a connection to the server and error checking */
 	if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
-		if (mysql_errno (&mysql) == CR_UNKNOWN_HOST)
+		if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR)
+		{
+			printf("MySQL OK - Version: %s (protocol %d)\n",
+				mysql_get_server_info(&mysql),
+				mysql_get_proto_info(&mysql)
+			);
+			mysql_close (&mysql);
+			return STATE_OK;
+		}
+		else if (mysql_errno (&mysql) == CR_UNKNOWN_HOST)
 			die (STATE_WARNING, "%s\n", mysql_error (&mysql));
 		else if (mysql_errno (&mysql) == CR_VERSION_ERROR)
 			die (STATE_WARNING, "%s\n", mysql_error (&mysql));
@@ -341,6 +352,7 @@ process_arguments (int argc, char **argv)
 		{"critical", required_argument, 0, 'c'},
 		{"warning", required_argument, 0, 'w'},
 		{"check-slave", no_argument, 0, 'S'},
+		{"ignore-auth", no_argument, 0, 'n'},
 		{"verbose", no_argument, 0, 'v'},
 		{"version", no_argument, 0, 'V'},
 		{"help", no_argument, 0, 'h'},
@@ -357,7 +369,7 @@ process_arguments (int argc, char **argv)
 		return ERROR;
 
 	while (1) {
-		c = getopt_long (argc, argv, "hlvVSP:p:u:d:H:s:c:w:a:k:C:D:L:f:g:", longopts, &option);
+		c = getopt_long (argc, argv, "hlvVnSP:p:u:d:H:s:c:w:a:k:C:D:L:f:g:", longopts, &option);
 
 		if (c == -1 || c == EOF)
 			break;
@@ -419,6 +431,9 @@ process_arguments (int argc, char **argv)
 		case 'S':
 			check_slave = 1;							/* check-slave */
 			break;
+		case 'n':
+			ignore_auth = 1;							/* ignore-auth */
+			break;
 		case 'w':
 			warning = optarg;
 			warning_time = strtod (warning, NULL);
@@ -512,6 +527,9 @@ print_help (void)
 	printf (UT_EXTRA_OPTS);
 
   printf (UT_HOST_PORT, 'P', myport);
+  printf (" %s\n", "-n, --ignore-auth");
+  printf ("    %s\n", _("Ignore authentication failure and check for mysql connectivity only"));
+
   printf (" %s\n", "-s, --socket=STRING");
   printf ("    %s\n", _("Use the specified socket (has no effect if -H is used)"));
 

+ 2 - 2
plugins/check_mysql_query.c

@@ -3,7 +3,7 @@
 * Nagios check_mysql_query plugin
 * 
 * License: GPL
-* Copyright (c) 2006-2009 Nagios Plugins Development Team
+* Copyright (c) 2006-2014 Nagios Plugins Development Team
 * Original code from check_mysql, copyright 1999 Didi Rieder
 * 
 * Description:
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_mysql_query";
-const char *copyright = "1999-2007";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_nagios.c

@@ -3,7 +3,7 @@
 * Nagios check_nagios plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -33,7 +33,7 @@
 *****************************************************************************/
 
 const char *progname = "check_nagios";
-const char *copyright = "1999-2007";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_nt.c

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 2000-2002 Yves Rubin (rubiyz@yahoo.com)
-* Copyright (c) 2003-2007 Nagios Plugins Development Team
+* Copyright (c) 2003-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -33,7 +33,7 @@
 *****************************************************************************/
 
 const char *progname = "check_nt";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_ntp.c

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 2006 Sean Finney <seanius@seanius.net>
-* Copyright (c) 2006-2008 Nagios Plugins Development Team
+* Copyright (c) 2006-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -31,7 +31,7 @@
 *****************************************************************************/
 
 const char *progname = "check_ntp";
-const char *copyright = "2006-2008";
+const char *copyright = "2006-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 39 - 14
plugins/check_ntp_peer.c

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 2006 Sean Finney <seanius@seanius.net>
-* Copyright (c) 2006-2008 Nagios Plugins Development Team
+* Copyright (c) 2006-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -36,7 +36,7 @@
 *****************************************************************************/
 
 const char *progname = "check_ntp_peer";
-const char *copyright = "2006-2008";
+const char *copyright = "2006-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"
@@ -560,7 +560,7 @@ char *perfd_truechimers (int num_truechimers)
 }
 
 int main(int argc, char *argv[]){
-	int result, offset_result, stratum, num_truechimers;
+	int result, offset_result, stratum, num_truechimers, oresult, jresult, sresult, tresult;
 	double offset=0, jitter=0;
 	char *result_line, *perfdata_line;
 
@@ -597,15 +597,19 @@ int main(int argc, char *argv[]){
 			result = STATE_UNKNOWN;
 		result = max_state_alt(result, get_status(fabs(offset), offset_thresholds));
 	}
-
+	oresult = result;
+	
 	if(do_truechimers)
-		result = max_state_alt(result, get_status(num_truechimers, truechimer_thresholds));
+		tresult = get_status(num_truechimers, truechimer_thresholds);
+		result = max_state_alt(result, tresult);
 
 	if(do_stratum)
-		result = max_state_alt(result, get_status(stratum, stratum_thresholds));
+		sresult = get_status(stratum, stratum_thresholds);
+		result = max_state_alt(result, sresult);
 
 	if(do_jitter)
-		result = max_state_alt(result, get_status(jitter, jitter_thresholds));
+		jresult = get_status(jitter, jitter_thresholds);
+		result = max_state_alt(result, jresult);
 
 	switch (result) {
 		case STATE_CRITICAL :
@@ -629,20 +633,43 @@ int main(int argc, char *argv[]){
 	if(offset_result == STATE_UNKNOWN){
 		xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
 		xasprintf(&perfdata_line, "");
+	} else if (oresult == STATE_WARNING) {
+		xasprintf(&result_line, "%s %s %.10g secs (WARNING)", result_line, _("Offset"), offset);
+	} else if (oresult == STATE_CRITICAL) {
+		xasprintf(&result_line, "%s %s %.10g secs (CRITICAL)", result_line, _("Offset"), offset);
 	} else {
 		xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
-		xasprintf(&perfdata_line, "%s", perfd_offset(offset));
-	}
+	}	
+	xasprintf(&perfdata_line, "%s", perfd_offset(offset));
+	
 	if (do_jitter) {
-		xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
+		if (jresult == STATE_WARNING) {
+			xasprintf(&result_line, "%s, jitter=%f (WARNING)", result_line, jitter);
+		} else if (jresult == STATE_CRITICAL) {
+			xasprintf(&result_line, "%s, jitter=%f (CRITICAL)", result_line, jitter);
+		} else {
+			xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
+		}
 		xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
 	}
 	if (do_stratum) {
-		xasprintf(&result_line, "%s, stratum=%i", result_line, stratum);
+		if (sresult == STATE_WARNING) {
+			xasprintf(&result_line, "%s, stratum=%i (WARNING)", result_line, stratum);
+		} else if (sresult == STATE_CRITICAL) {
+			xasprintf(&result_line, "%s, stratum=%i (CRITICAL)", result_line, stratum);
+		} else {
+			xasprintf(&result_line, "%s, stratum=%i", result_line, stratum);
+		}
 		xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
 	}
 	if (do_truechimers) {
-		xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
+		if (tresult == STATE_WARNING) {
+			xasprintf(&result_line, "%s, truechimers=%i (WARNING)", result_line, num_truechimers);
+		} else if (tresult == STATE_CRITICAL) {
+			xasprintf(&result_line, "%s, truechimers=%i (CRITICAL)", result_line, num_truechimers);
+		} else {
+			xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
+		}
 		xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers));
 	}
 	printf("%s|%s\n", result_line, perfdata_line);
@@ -651,8 +678,6 @@ int main(int argc, char *argv[]){
 	return result;
 }
 
-
-
 void print_help(void){
 	print_revision(progname, NP_VERSION);
 

+ 14 - 5
plugins/check_ntp_time.c

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 2006 Sean Finney <seanius@seanius.net>
-* Copyright (c) 2006-2008 Nagios Plugins Development Team
+* Copyright (c) 2006-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -35,7 +35,7 @@
 *****************************************************************************/
 
 const char *progname = "check_ntp_time";
-const char *copyright = "2006-2008";
+const char *copyright = "2006-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"
@@ -48,6 +48,7 @@ static int verbose=0;
 static int quiet=0;
 static char *owarn="60";
 static char *ocrit="120";
+static int time_offset=0;
 
 int process_arguments (int, char **);
 thresholds *offset_thresholds = NULL;
@@ -399,7 +400,7 @@ double offset_request(const char *host, int *status){
 				gettimeofday(&recv_time, NULL);
 				DBG(print_ntp_message(&req[i]));
 				respnum=servers[i].num_responses++;
-				servers[i].offset[respnum]=calc_offset(&req[i], &recv_time);
+				servers[i].offset[respnum]=calc_offset(&req[i], &recv_time)+time_offset;
 				if(verbose) {
 					printf("offset %.10g\n", servers[i].offset[respnum]);
 				}
@@ -454,6 +455,7 @@ int process_arguments(int argc, char **argv){
 		{"use-ipv4", no_argument, 0, '4'},
 		{"use-ipv6", no_argument, 0, '6'},
 		{"quiet", no_argument, 0, 'q'},
+		{"time-offset", optional_argument, 0, 'o'},
 		{"warning", required_argument, 0, 'w'},
 		{"critical", required_argument, 0, 'c'},
 		{"timeout", required_argument, 0, 't'},
@@ -467,7 +469,7 @@ int process_arguments(int argc, char **argv){
 		usage ("\n");
 
 	while (1) {
-		c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:", longopts, &option);
+		c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:o:", longopts, &option);
 		if (c == -1 || c == EOF || c == 1)
 			break;
 
@@ -503,6 +505,9 @@ int process_arguments(int argc, char **argv){
 		case 't':
 			socket_timeout=atoi(optarg);
 			break;
+		case 'o':
+			time_offset=atoi(optarg);
+                        break;
 		case '4':
 			address_family = AF_INET;
 			break;
@@ -615,6 +620,8 @@ void print_help(void){
 	printf ("    %s\n", _("Offset to result in warning status (seconds)"));
 	printf (" %s\n", "-c, --critical=THRESHOLD");
 	printf ("    %s\n", _("Offset to result in critical status (seconds)"));
+	printf (" %s\n", "-o, --time_offset=INTEGER");
+	printf ("    %s\n", _("Expected offset of the ntp server relative to local server (seconds)"));
 	printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
 	printf (UT_VERBOSE);
 
@@ -627,6 +634,8 @@ void print_help(void){
 	printf("%s\n", _("Notes:"));
 	printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use"));
 	printf(" %s\n", _("check_ntp_peer."));
+	printf(" %s\n", _("--time-offset is usefull for compensating for servers with known"));
+	printf(" %s\n", _("and expected clock skew."));
 	printf("\n");
 	printf(UT_THRESHOLDS_NOTES);
 
@@ -641,6 +650,6 @@ void
 print_usage(void)
 {
 	printf ("%s\n", _("Usage:"));
-	printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose]\n", progname);
+	printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose] [-o <time offset>]\n", progname);
 }
 

+ 2 - 2
plugins/check_nwstat.c

@@ -3,7 +3,7 @@
 * Nagios check_nwstat plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_nwstat";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_overcr.c

@@ -3,7 +3,7 @@
 * Nagios check_overcr plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "check_overcr";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_pgsql.c

@@ -3,7 +3,7 @@
 * Nagios check_pgsql plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2011 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_pgsql";
-const char *copyright = "1999-2011";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_ping.c

@@ -3,7 +3,7 @@
 * Nagios check_ping plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_ping";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_procs.c

@@ -3,7 +3,7 @@
 * Nagios check_procs plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2008 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -33,7 +33,7 @@
 
 const char *progname = "check_procs";
 const char *program_name = "check_procs";  /* Required for coreutils libs */
-const char *copyright = "2000-2008";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_radius.c

@@ -3,7 +3,7 @@
 * Nagios check_radius plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2008 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_radius";
-const char *copyright = "2000-2008";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_real.c

@@ -3,7 +3,7 @@
 * Nagios check_real plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_real";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_smtp.c

@@ -3,7 +3,7 @@
 * Nagios check_smtp plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_smtp";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 3 - 3
plugins/check_snmp.c

@@ -3,7 +3,7 @@
 * Nagios check_snmp plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_snmp";
-const char *copyright = "1999-2007";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"
@@ -463,7 +463,7 @@ main (int argc, char **argv)
 		/* Process this block for numeric comparisons */
 		/* Make some special values,like Timeticks numeric only if a threshold is defined */
 		if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
-			ptr = strpbrk (show, "0123456789");
+			ptr = strpbrk (show, "-0123456789");
 			if (ptr == NULL)
 				die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
 			while (i >= response_size) {

+ 22 - 8
plugins/check_ssh.c

@@ -3,7 +3,7 @@
 * Nagios check_ssh plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_ssh";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"
@@ -46,6 +46,7 @@ const char *email = "devel@nagios-plugins.org";
 int port = -1;
 char *server_name = NULL;
 char *remote_version = NULL;
+char *remote_protocol = NULL;
 int verbose = FALSE;
 
 int process_arguments (int, char **);
@@ -53,7 +54,7 @@ int validate_arguments (void);
 void print_help (void);
 void print_usage (void);
 
-int ssh_connect (char *haddr, int hport, char *remote_version);
+int ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol);
 
 
 
@@ -78,7 +79,7 @@ main (int argc, char **argv)
 	alarm (socket_timeout);
 
 	/* ssh_connect exits if error is found */
-	result = ssh_connect (server_name, port, remote_version);
+	result = ssh_connect (server_name, port, remote_version, remote_protocol);
 
 	alarm (0);
 
@@ -105,6 +106,7 @@ process_arguments (int argc, char **argv)
 		{"timeout", required_argument, 0, 't'},
 		{"verbose", no_argument, 0, 'v'},
 		{"remote-version", required_argument, 0, 'r'},
+		{"remote-protcol", required_argument, 0, 'P'},
 		{0, 0, 0, 0}
 	};
 
@@ -116,7 +118,7 @@ process_arguments (int argc, char **argv)
 			strcpy (argv[c], "-t");
 
 	while (1) {
-		c = getopt_long (argc, argv, "+Vhv46t:r:H:p:", longopts, &option);
+		c = getopt_long (argc, argv, "+Vhv46t:r:H:p:P:", longopts, &option);
 
 		if (c == -1 || c == EOF)
 			break;
@@ -152,6 +154,9 @@ process_arguments (int argc, char **argv)
 		case 'r':									/* remote version */
 			remote_version = optarg;
 			break;
+		case 'P':									/* remote version */
+			remote_protocol = optarg;
+			break;
 		case 'H':									/* host */
 			if (is_host (optarg) == FALSE)
 				usage2 (_("Invalid hostname/address"), optarg);
@@ -206,7 +211,7 @@ validate_arguments (void)
 
 
 int
-ssh_connect (char *haddr, int hport, char *remote_version)
+ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol)
 {
 	int sd;
 	int result;
@@ -250,7 +255,14 @@ ssh_connect (char *haddr, int hport, char *remote_version)
 			printf
 				(_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"),
 				 ssh_server, ssh_proto, remote_version);
-			recv (sd, output, BUFF_SZ, 0);
+			close(sd);
+			exit (STATE_WARNING);
+		}
+
+		if (remote_protocol && strcmp(remote_protocol, ssh_proto)) {
+			printf
+				(_("SSH WARNING - %s (protocol %s) protocol version mismatch, expected '%s'\n"),
+				 ssh_server, ssh_proto, remote_protocol);
 			close(sd);
 			exit (STATE_WARNING);
 		}
@@ -261,7 +273,6 @@ ssh_connect (char *haddr, int hport, char *remote_version)
 			(_("SSH OK - %s (protocol %s) | %s\n"),
 			 ssh_server, ssh_proto, fperfdata("time", elapsed_time, "s",
 			 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, (int)socket_timeout));
-		recv (sd, output, BUFF_SZ, 0);
 		close(sd);
 		exit (STATE_OK);
 	}
@@ -298,6 +309,9 @@ print_help (void)
 	printf (" %s\n", "-r, --remote-version=STRING");
   printf ("    %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
 
+	printf (" %s\n", "-P, --remote-protocol=STRING");
+  printf ("    %s\n", _("Warn if protocol doesn't match expected protocol version (ex: 2.0)"));
+
 	printf (UT_VERBOSE);
 
 	printf (UT_SUPPORT);

+ 7 - 6
plugins/check_swap.c

@@ -4,11 +4,11 @@
 * 
 * License: GPL
 * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
-* This file contains the check_disk plugin
+* This file contains the check_swap plugin
 * 
 * 
 * This program is free software: you can redistribute it and/or modify
@@ -28,7 +28,7 @@
 *****************************************************************************/
 
 const char *progname = "check_swap";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"
@@ -541,13 +541,14 @@ print_help (void)
   printf (" %s\n", "-c, --critical=INTEGER");
   printf ("    %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free"));
   printf (" %s\n", "-c, --critical=PERCENT%%");
-  printf ("    %s\n", _("Exit with CRITCAL status if less than PERCENT of swap space is free"));
+  printf ("    %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free"));
   printf (" %s\n", "-a, --allswaps");
   printf ("    %s\n", _("Conduct comparisons for all swap partitions, one by one"));
 	printf (UT_VERBOSE);
 
 	printf ("\n");
   printf ("%s\n", _("Notes:"));
+  printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked."));
   printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."));
 
 	printf (UT_SUPPORT);
@@ -559,6 +560,6 @@ void
 print_usage (void)
 {
 	printf ("%s\n", _("Usage:"));
-  printf ("%s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
-  printf ("%s [-av] -w <bytes_free> -c <bytes_free>\n", progname);
+  printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
+  printf ("  -w <bytes_free> -c <bytes_free> [-n <state>}\n");
 }

+ 9 - 4
plugins/check_tcp.c

@@ -3,7 +3,7 @@
 * Nagios check_tcp plugin
 *
 * License: GPL
-* Copyright (c) 1999-2013 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 *
 * Description:
 *
@@ -29,7 +29,7 @@
 
 /* progname "check_tcp" changes depending on symlink called */
 char *progname;
-const char *copyright = "1999-2008";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include <ctype.h>
@@ -354,8 +354,13 @@ main (int argc, char **argv)
 			printf("Unexpected response from host/socket on ");
 		else
 			printf("%.3f second response time on ", elapsed_time);
-		if(server_address[0] != '/')
-			printf("port %d", server_port);
+		if(server_address[0] != '/') {
+			if (host_specified)
+				printf("%s port %d",
+				       server_address, server_port);
+			else
+				printf("port %d", server_port);
+		}
 		else
 			printf("socket %s", server_address);
 	}

+ 2 - 2
plugins/check_time.c

@@ -3,7 +3,7 @@
 * Nagios check_time plugin
 * 
 * License: GPL
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -29,7 +29,7 @@
 *****************************************************************************/
 
 const char *progname = "check_time";
-const char *copyright = "1999-2007";
+const char *copyright = "1999-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_ups.c

@@ -6,7 +6,7 @@
 * Copyright (c) 2000 Tom Shields
 *               2004 Alain Richard <alain.richard@equation.fr>
 *               2004 Arnaud Quette <arnaud.quette@mgeups.com>
-* Copyright (c) 2002-2007 Nagios Plugins Development Team
+* Copyright (c) 2002-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -33,7 +33,7 @@
 *****************************************************************************/
 
 const char *progname = "check_ups";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 2 - 2
plugins/check_users.c

@@ -3,7 +3,7 @@
 * Nagios check_users plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2012 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -31,7 +31,7 @@
 *****************************************************************************/
 
 const char *progname = "check_users";
-const char *copyright = "2000-2007";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 1 - 1
plugins/common.h

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
-* Copyright (c) 2003-2007 Nagios Plugins Development Team
+* Copyright (c) 2003-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 

+ 2 - 21
plugins/negate.c

@@ -3,7 +3,7 @@
 * Nagios negate plugin
 * 
 * License: GPL
-* Copyright (c) 2002-2008 Nagios Plugins Development Team
+* Copyright (c) 2002-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -30,7 +30,7 @@
 *****************************************************************************/
 
 const char *progname = "negate";
-const char *copyright = "2002-2008";
+const char *copyright = "2002-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #define DEFAULT_TIMEOUT 11
@@ -45,7 +45,6 @@ const char *email = "devel@nagios-plugins.org";
 
 static const char **process_arguments (int, char **);
 int validate_arguments (char **);
-int translate_state (char *);
 void print_help (void);
 void print_usage (void);
 int subst_text = FALSE;
@@ -218,24 +217,6 @@ validate_arguments (char **command_line)
 }
 
 
-int
-translate_state (char *state_text)
-{
-	char *temp_ptr;
-	for (temp_ptr = state_text; *temp_ptr; temp_ptr++) {
-		*temp_ptr = toupper(*temp_ptr);
-	}
-	if (!strcmp(state_text,"OK") || !strcmp(state_text,"0"))
-		return STATE_OK;
-	if (!strcmp(state_text,"WARNING") || !strcmp(state_text,"1"))
-		return STATE_WARNING;
-	if (!strcmp(state_text,"CRITICAL") || !strcmp(state_text,"2"))
-		return STATE_CRITICAL;
-	if (!strcmp(state_text,"UNKNOWN") || !strcmp(state_text,"3"))
-		return STATE_UNKNOWN;
-	return ERROR;
-}
-
 void
 print_help (void)
 {

+ 1 - 1
plugins/netutils.c

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
-* Copyright (c) 2003-2008 Nagios Plugins Development Team
+* Copyright (c) 2003-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 

+ 1 - 1
plugins/netutils.h

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
-* Copyright (c) 2003-2007 Nagios Plugins Development Team
+* Copyright (c) 2003-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 

+ 1 - 1
plugins/popen.c

@@ -3,7 +3,7 @@
 * Nagios plugins popen
 * 
 * License: GPL
-* Copyright (c) 2005-2007 Nagios Plugins Development Team
+* Copyright (c) 2005-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 

+ 1 - 1
plugins/runcmd.c

@@ -3,7 +3,7 @@
 * Nagios run command utilities
 * 
 * License: GPL
-* Copyright (c) 2005-2006 Nagios Plugins Development Team
+* Copyright (c) 2005-2014 Nagios Plugins Development Team
 * 
 * Description :
 * 

+ 1 - 1
plugins/runcmd.h

@@ -1,7 +1,7 @@
 /****************************************************************************
 * 
 * License: GPL
-* Copyright (c) 2005 Nagios Plugins Development Team
+* Copyright (c) 2005-2014 Nagios Plugins Development Team
 * Author: Andreas Ericsson <ae@op5.se>
 * 
 * 

+ 5 - 6
plugins/sslutils.c

@@ -3,7 +3,7 @@
 * Nagios plugins SSL utilities
 * 
 * License: GPL
-* Copyright (c) 2005-2010 Nagios Plugins Development Team
+* Copyright (c) 2005-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -151,7 +151,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
 	struct tm stamp;
 	float time_left;
 	int days_left;
-	char timestamp[17] = "";
+	char timestamp[50] = "";
+	time_t tm_t;
 
 	certificate=SSL_get_peer_certificate(s);
 	if (!certificate) {
@@ -209,10 +210,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
 
 	time_left = difftime(timegm(&stamp), time(NULL));
 	days_left = time_left / 86400;
-	snprintf
-		(timestamp, 17, "%02d/%02d/%04d %02d:%02d",
-		 stamp.tm_mon + 1,
-		 stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
+	tm_t = mktime (&stamp);
+	strftime(timestamp, 50, "%c", localtime(&tm_t));
 
 	if (days_left > 0 && days_left <= days_till_exp_warn) {
 		printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp);

+ 5 - 5
plugins/t/check_dig.t

@@ -22,25 +22,25 @@ my $successOutput = '/DNS OK - [\.0-9]+ seconds? response time/';
 my $hostname_valid = getTestParameter(
 			"NP_HOSTNAME_VALID",
 			"A valid (known to DNS) hostname",
-			"orwell.monitoring-plugins.org"
+			"nagios-plugins.org"
 			);
 
 my $hostname_valid_ip = getTestParameter(
 			"NP_HOSTNAME_VALID_IP",
 			"The IP address of the valid hostname $hostname_valid",
-			"130.133.8.40",
+			"72.14.186.43",
 			);
 
 my $hostname_valid_reverse = getTestParameter(
 			"NP_HOSTNAME_VALID_REVERSE",
 			"The hostname of $hostname_valid_ip",
-			"orwell.monitoring-plugins.org.",
+			"nagios-plugins.org",
 			);
 
 my $hostname_invalid = getTestParameter(
 			"NP_HOSTNAME_INVALID",
 			"An invalid (not known to DNS) hostname",
-			"nosuchhost.monitoring-plugins.org",
+			"nosuchhost.nagios-plugins.org",
 			);
 
 my $dns_server       = getTestParameter(
@@ -61,7 +61,7 @@ SKIP: {
 	$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -w 0.000001 -c 0.00001");
 	cmp_ok( $res->return_code, '==', 2, "Critical threshold passed");
 
-	$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -w 0.000001 -c 5");
+	$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -w 0.000001");
 	cmp_ok( $res->return_code, '==', 1, "Warning threshold passed");
 
 	$res = NPTest->testCmd("./check_dig -H $dns_server -t 1");

+ 49 - 6
plugins/t/check_dns.t

@@ -10,39 +10,59 @@ use NPTest;
 
 plan skip_all => "check_dns not compiled" unless (-x "check_dns");
 
-plan tests => 13;
+plan tests => 19;
 
 my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
 
 my $hostname_valid = getTestParameter( 
 			"NP_HOSTNAME_VALID",
 			"A valid (known to DNS) hostname",
-			"nagios.com"
+			"nagios-plugins.org"
 			);
 
 my $hostname_valid_ip = getTestParameter(
 			"NP_HOSTNAME_VALID_IP",
 			"The IP address of the valid hostname $hostname_valid",
-			"66.118.156.50",
+			"72.14.186.43",
 			);
 
 my $hostname_valid_reverse = getTestParameter(
 			"NP_HOSTNAME_VALID_REVERSE",
 			"The hostname of $hostname_valid_ip",
-			"66-118-156-50.static.sagonet.net.",
+			"nagios-plugins.org.",
 			);
 
 my $hostname_invalid = getTestParameter( 
 			"NP_HOSTNAME_INVALID", 
 			"An invalid (not known to DNS) hostname",
-			"nosuchhost.altinity.com",
+			"nosuchhost.nagios-plugins.org",
 			);
 
-my $dns_server       = getTestParameter(
+my $dns_server = getTestParameter(
 			"NP_DNS_SERVER",
 			"A non default (remote) DNS server",
 			);
 
+my $hostname_valid_aaaa = getTestParameter( 
+			"NP_HOSTNAME_VALID_AAAA", 
+			"A valid hostname for AAAA records"
+			);
+
+my $hostname_valid_mx = getTestParameter( 
+			"NP_HOSTNAME_VALID_MX", 
+			"A valid hostname for MX records",
+			"nagios-plugins.org",
+			);
+
+my $hostname_valid_srv = getTestParameter( 
+			"NP_HOSTNAME_VALID_SRV", 
+			"A valid hostname for SRV records"
+			); 
+
+my $hostname_valid_txt = getTestParameter( 
+			"NP_HOSTNAME_VALID_TXT", 
+			"A valid hostname for TXT records"
+			); 
 my $res;
 
 $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5");
@@ -76,3 +96,26 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev
 cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
 like  ( $res->output, $successOutput, "Output OK");
 
+SKIP: {
+        skip "No server specified for checking TXT records", 2 unless $hostname_valid_txt;
+
+	$res = NPTest->testCmd("./check_dns -H $hostname_valid_txt -s $dns_server -q TXT");
+	cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid_txt");
+	like  ( $res->output, $successOutput, "TXT Output OK" );
+}
+
+SKIP: {
+        skip "No server specified for checking SRV records", 2 unless $hostname_valid_srv;
+
+	$res = NPTest->testCmd("./check_dns -H $hostname_valid_srv -s $dns_server -q SRV");
+	cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid_srv");
+	like  ( $res->output, $successOutput, "SRV Output OK" );
+}
+
+SKIP: {
+        skip "No server specified for checking AAAA records", 2 unless $hostname_valid_aaaa;
+
+	$res = NPTest->testCmd("./check_dns -H $hostname_valid_aaaa -s $dns_server -q AAAA");
+	cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid_aaaa");
+	like  ( $res->output, $successOutput, "TXT Output OK" );
+}

+ 3 - 3
plugins/t/check_jabber.t

@@ -29,7 +29,7 @@ my $hostname_invalid   = getTestParameter(
 			);
 
 
-my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on port 5222/';
+my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/';
 
 my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/';
 
@@ -40,7 +40,7 @@ my $r;
 SKIP: {
 	skip "No jabber server defined", 6 unless $host_tcp_jabber;
 
-	$r = NPTest->testCmd( "./check_jabber $host_tcp_jabber" );
+	$r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber" );
 	is( $r->return_code, 0, "Connected okay");
 	like( $r->output, $jabberOK, "Output as expected" );
 
@@ -48,7 +48,7 @@ SKIP: {
 	is( $r->return_code, 0, "Connected okay, within limits" );
 	like( $r->output, $jabberOK, "Output as expected" );
 	
-	$r = NPTest->testCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10" );
+	$r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber -wt 9 -ct 9 -to 10" );
 	is( $r->return_code, 0, "Old syntax okay" );
 	like( $r->output, $jabberOK, "Output as expected" );
 

+ 2 - 2
plugins/t/check_ntp.t

@@ -35,8 +35,8 @@ my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'
 my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
 my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
 my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
-my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
-my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
+my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}\s\(WARNING\),\struechimers=[0-9]+/';
+my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+\s\(CRITICAL\),\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
 my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/';
 my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/';
 

+ 30 - 7
plugins/t/check_pop.t

@@ -8,7 +8,7 @@ use strict;
 use Test::More;
 use NPTest;
 
-plan tests => 5;
+plan tests => 11;
 
 my $host_tcp_smtp = getTestParameter( 
 			"NP_HOST_TCP_SMTP",
@@ -22,6 +22,12 @@ my $host_tcp_pop = getTestParameter(
 			$host_tcp_smtp
 			);
 
+my $host_tcp_pop_ssl = getTestParameter(
+			"NP_HOST_TCP_POP_SSL",
+			"Enable SSL for the host providing a POP Service (a mail server)",
+			"disabled"
+			);
+
 my $host_nonresponsive = getTestParameter(
 			"NP_HOST_NONRESPONSIVE", 
 			"The hostname of system not responsive to network requests",
@@ -39,14 +45,31 @@ my %exceptions = ( 2 => "No POP Server present?" );
 my $t;
 my $res;
 
-$res = NPTest->testCmd( "./check_pop $host_tcp_pop" );
-cmp_ok( $res->return_code, '==', 0, "POP server ok");
+SKIP: {
+        skip "SSL Disabled", 6 unless ($host_tcp_pop_ssl ne "disabled");
+
+	$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -S -p 995" );
+	cmp_ok( $res->return_code, '==', 0, "SSL POP server ok");
+
+	$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -p 995 -w 9 -c 9 -t 10 -S -e '+OK'");
+	cmp_ok( $res->return_code, '==', 0, "SSL POP server returned +OK");
+
+	$res = NPTest->testCmd( "./check_pop $host_tcp_pop -p 995 -wt 9 -ct 9 -to 10 -S -e '+OK'");
+	cmp_ok( $res->return_code, '==', 0, "SSL Old syntax");
+}
+
+SKIP: {
+        skip "SSL Enabled", 6 unless ($host_tcp_pop_ssl eq "disabled");
+	
+	$res = NPTest->testCmd( "./check_pop $host_tcp_pop" );
+	cmp_ok( $res->return_code, '==', 0, "POP server ok");
 
-$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -p 110 -w 9 -c 9 -t 10 -e '+OK'");
-cmp_ok( $res->return_code, '==', 0, "POP server returned +OK");
+	$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -p 110 -w 9 -c 9 -t 10 -e '+OK'");
+	cmp_ok( $res->return_code, '==', 0, "POP server returned +OK");
 
-$res = NPTest->testCmd( "./check_pop $host_tcp_pop -p 110 -wt 9 -ct 9 -to 10 -e '+OK'");
-cmp_ok( $res->return_code, '==', 0, "Old syntax");
+	$res = NPTest->testCmd( "./check_pop $host_tcp_pop -p 110 -wt 9 -ct 9 -to 10 -e '+OK'");
+	cmp_ok( $res->return_code, '==', 0, "Old syntax");
+}
 
 $res = NPTest->testCmd( "./check_pop $host_nonresponsive" );
 cmp_ok( $res->return_code, '==', 2, "Non responsive host");

+ 32 - 24
plugins/tests/check_procs.t

@@ -18,31 +18,35 @@ my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin";
 
 $result = NPTest->testCmd( "$command" );
 is( $result->return_code, 0, "Run with no options" );
-like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" );
+is( $result->output, "PROCS OK: 95 processes | procs=95;;;0;", "Output correct" );
 
 $result = NPTest->testCmd( "$command -w 5" );
 is( $result->return_code, 1, "Checking > 5 processes" );
-like( $result->output, '/^PROCS WARNING: 95 processes$/', "Output correct" );
+is( $result->output, "PROCS WARNING: 95 processes | procs=95;5;;0;", "Output correct" );
 
 $result = NPTest->testCmd( "$command -w 4 -c 44" );
 is( $result->return_code, 2, "Checking critical" );
-like( $result->output, '/^PROCS CRITICAL: 95 processes$/', "Output correct" );
+is( $result->output, "PROCS CRITICAL: 95 processes | procs=95;4;44;0;", "Output correct" );
 
 $result = NPTest->testCmd( "$command -w 100 -c 200" );
 is( $result->return_code, 0, "Checking no threshold breeched" );
-like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" );
+is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" );
 
 $result = NPTest->testCmd( "$command -C launchd -c 5" );
 is( $result->return_code, 2, "Checking processes filtered by command name" );
-like( $result->output, '/^PROCS CRITICAL: 6 processes with command name \'launchd\'$/', "Output correct" );
+is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" );
 
-$result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" );
-is( $result->return_code, 1, "Checking processes filtered by userid" );
-like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" );
+SKIP: {
+    skip 'user with uid 501 required', 4 unless getpwuid(501);
 
-$result = NPTest->testCmd( "$command -C launchd -u 501" );
-is( $result->return_code, 0, "Checking processes filtered by command name and userid" );
-like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
+    $result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" );
+    is( $result->return_code, 1, "Checking processes filtered by userid" );
+    like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" );
+
+    $result = NPTest->testCmd( "$command -C launchd -u 501" );
+    is( $result->return_code, 0, "Checking processes filtered by command name and userid" );
+    like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
+}
 
 $result = NPTest->testCmd( "$command -u -2 -w 2:2" );
 is( $result->return_code, 1, "Checking processes with userid=-2" );
@@ -62,15 +66,15 @@ like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \
 
 $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
 is( $result->return_code, 0, "Checking regexp search of arguments" );
-is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501'", "Output correct" );
+is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
 
 $result = NPTest->testCmd( "$command --vsz 1000000" );
 is( $result->return_code, 0, "Checking filter by VSZ" );
-like( $result->output, '/^PROCS OK: 24 processes with VSZ >= 1000000$/', "Output correct" );
+is( $result->output, 'PROCS OK: 24 processes with VSZ >= 1000000 | procs=24;;;0;', "Output correct" );
 
 $result = NPTest->testCmd( "$command --rss 100000" );
 is( $result->return_code, 0, "Checking filter by RSS" );
-like( $result->output, '/^PROCS OK: 3 processes with RSS >= 100000$/', "Output correct" );
+is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;', "Output correct" );
 
 $result = NPTest->testCmd( "$command -s S" );
 is( $result->return_code, 0, "Checking filter for sleeping processes" );
@@ -86,34 +90,38 @@ like( $result->output, '/^PROCS CRITICAL: 39 processes with PPID = 1/', "Output
 
 $result = NPTest->testCmd( "$command -P 0.71" );
 is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" );
-is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71', "Output correct" );
+is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71 | procs=7;;;0;', "Output correct" );
 
 $result = NPTest->testCmd( "$command -P 0.70" );
 is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" );
-is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70', "Output correct" );
+is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70 | procs=8;;;0;', "Output correct" );
 
 $result = NPTest->testCmd( "$command --metric=CPU -w 8" );
 is( $result->return_code, 1, "Checking against metric of CPU > 8" );
-is( $result->output, 'CPU WARNING: 1 warn out of 95 processes', "Output correct" );
+is( $result->output, 'CPU WARNING: 1 warn out of 95 processes | procs=95;;;0; procs_warn=1;;;0; procs_crit=0;;;0;', "Output correct" );
 
 # TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will.
-$result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" );
-is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" );
-is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" );
+SKIP: {
+    skip 'user with uid 501 required', 2 unless getpwuid(501);
+
+    $result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" );
+    is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" );
+    is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" );
+};
 
 $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
 is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );
-is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" );
+is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" );
 
 $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
 is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );
-is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" );
+is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" );
 
 $result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" );
 is( $result->return_code, 2, "Checking against RSS > 70MB" );
-is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari]', "Output correct" );
+is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari] | procs=95;;;0; procs_warn=0;;;0; procs_crit=5;;;0;', "Output correct" );
 
 $result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
 is( $result->return_code, 0, "Checking no pipe symbol in output" );
-is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)'", "Output correct" );
+is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" );
 

+ 30 - 2
plugins/tests/check_snmp.t

@@ -8,7 +8,7 @@ use Test::More;
 use NPTest;
 use FindBin qw($Bin);
 
-my $tests = 53;
+my $tests = 67;
 # Check that all dependent modules are available
 eval {
 	require NetSNMP::OID;
@@ -79,7 +79,7 @@ Copyright (c) 1986-2004 by cisco Systems, Inc.
 $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1");
 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" );
 like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
-like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software Alice Kisco Outernetwork Oserating Gystem Totware | 
+like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software "Alice" Kisco Outernetwork Oserating Gystem Totware | 
 .1.3.6.1.4.1.8072.3.2.67.0:
 "Cisco Internetwork Operating System Software
 IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version
@@ -214,3 +214,31 @@ $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1
 is($res->return_code, 0, "String check should check whole string, not a parsed number" );
 is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string");
 
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
+is($res->return_code, 0, "Negative integer check OK" );
+is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2 ', "Negative integer check OK output" );
+
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
+is($res->return_code, 1, "Negative integer check WARNING" );
+is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3 ', "Negative integer check WARNING output" );
+
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
+is($res->return_code, 2, "Negative integer check CRITICAL" );
+is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4 ', "Negative integer check CRITICAL output" );
+
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -3: -c -6:" );
+is($res->return_code, 1, "Negative integer as string, WARNING" );
+is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, WARNING output" );
+
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -2: -c -3:" );
+is($res->return_code, 2, "Negative integer as string, CRITICAL" );
+is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, CRITICAL output" );
+
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c ~:-6.5" );
+is($res->return_code, 0, "Negative float OK" );
+is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float OK output" );
+
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w ~:-6.65 -c ~:-6.55" );
+is($res->return_code, 1, "Negative float WARNING" );
+is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float WARNING output" );
+

+ 7 - 7
plugins/tests/check_snmp_agent.pl

@@ -7,7 +7,7 @@
 use NetSNMP::OID qw(:all);
 use NetSNMP::agent;
 use NetSNMP::ASN qw(ASN_OCTET_STR ASN_COUNTER ASN_COUNTER64 ASN_INTEGER ASN_INTEGER64 ASN_UNSIGNED ASN_UNSIGNED64);
-#use Math::Int64 qw(uint64); # Skip that module whie we don't need it
+#use Math::Int64 qw(uint64); # Skip that module while we don't need it
 sub uint64 { return $_ }
 
 if (!$agent) {
@@ -16,8 +16,6 @@ if (!$agent) {
 }
 
 my $baseoid = '.1.3.6.1.4.1.8072.3.2.67';
-# Next are arrays of indexes (Type, initial value and increments)
-# Undef miltipliers are randomized
 my $multiline = 'Cisco Internetwork Operating System Software
 IOS (tm) Catalyst 4000 "L3" Switch Software (cat4000-I9K91S-M), Version
 12.2(20)EWA, RELEASE SOFTWARE (fc1)
@@ -33,10 +31,12 @@ ends with with this: C:\\';
 my $multilin5 = 'And now have fun with with this: "C:\\"
 because we\'re not done yet!';
 
-# 0..15 <---- please update comment when adding/removing fields
-my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR );
-my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345' );
-my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef );
+# Next are arrays of indexes (Type, initial value and increments)
+# 0..16 <---- please update comment when adding/removing fields
+my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR );
+my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' );
+# undef increments are randomized
+my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef );
 
 # Number of elements in our OID
 my $oidelts;

+ 2 - 2
plugins/urlize.c

@@ -3,7 +3,7 @@
 * Nagios urlize plugin
 * 
 * License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2014 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -31,7 +31,7 @@
 *****************************************************************************/
 
 const char *progname = "urlize";
-const char *copyright = "2000-2006";
+const char *copyright = "2000-2014";
 const char *email = "devel@nagios-plugins.org";
 
 #include "common.h"

+ 21 - 1
plugins/utils.c

@@ -4,7 +4,7 @@
 * 
 * License: GPL
 * Copyright (c) 2000 Karl DeBisschop (karl@debisschop.net)
-* Copyright (c) 2002-2007 Nagios Plugin Development Team
+* Copyright (c) 2002-2014 Nagios Plugin Development Team
 * 
 * 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
@@ -630,3 +630,23 @@ char *fperfdata (const char *label,
 
 	return data;
 }
+
+// set entire string to lower, no need to return as it works on string in place
+void strntolower (char * test_char, int size) {
+
+        char * ptr = test_char;
+
+        for (; ptr < test_char+size; ++ptr)
+                *ptr = tolower(*ptr);
+
+}
+
+// set entire string to lower, no need to return as it works on string in place
+void strntoupper (char * test_char, int size) {
+
+        char * ptr = test_char;
+
+        for (; ptr < test_char+size; ++ptr)
+                *ptr = toupper(*ptr);
+
+}

+ 4 - 0
plugins/utils.h

@@ -118,6 +118,10 @@ char *fperfdata (const char *,
  int,
  double);
 
+/* string case changes */
+void strntoupper (char * test_char, int size);
+void strntolower (char * test_char, int size);
+
 /* The idea here is that, although not every plugin will use all of these, 
    most will or should.  Therefore, for consistency, these very common 
    options should have only these meanings throughout the overall suite */

+ 1 - 1
po/de.po

@@ -1,7 +1,7 @@
 # translation of de.po to 
 # German Language Translation File.
 # This file is distributed under the same license as the nagios-plugins package.
-# Copyright (C) 2004 Nagios Plugin Development Group.
+# Copyright (C) 2004-2014 Nagios Plugin Development Group.
 # Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003, 2004.
 #
 #

+ 1 - 1
po/fr.po

@@ -1,6 +1,6 @@
 # translation of fr.po to
 # Messages français pour Nagios Plugins
-# Copyright (C) 2003-2004 Nagios Plugin Development Group
+# Copyright (C) 2003-2014 Nagios Plugin Development Group
 # This file is distributed under the same license as the nagiosplug package.
 #
 # Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003.

+ 8 - 5
test.pl.in

@@ -9,9 +9,9 @@ use Getopt::Long;
 
 use NPTest qw(DetermineTestHarnessDirectory TestsFrom);
 
-my $tstdir;
+my @tstdir;
 
-if ( ! GetOptions( "testdir:s" => \$tstdir ) )
+if ( ! GetOptions( "testdir:s" => \@tstdir ) )
 {
   print "Usage: ${0} [--testdir=<directory>] [<test_harness.t> ...]\n";
   exit 1;
@@ -25,15 +25,18 @@ if ( scalar( @ARGV ) )
 }
 else
 {
-  my $directory = DetermineTestHarnessDirectory( $tstdir );
+  my @directory = DetermineTestHarnessDirectory( @tstdir );
 
-  if ( !defined( $directory ) )
+  if ( @directory == 0 )
   {
     print STDERR "$0: Unable to determine the test harness directory - ABORTING\n";
     exit 2;
   }
 
-  @tests = TestsFrom( $directory, 1 );
+  for my $d ( @directory )
+  {
+    push (@tests, TestsFrom( $d, 1 ));
+  }
 }
 
 if ( ! scalar( @tests ) )

+ 1 - 1
tools/generate-change-log

@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 #
-# Copyright (c) 2013 Nagios Plugins Development Team
+# Copyright (c) 2013-2014 Nagios Plugins Development Team
 #
 # Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
 #

+ 1 - 1
tools/git-notify

@@ -3,7 +3,7 @@
 # Tool to send git commit notifications
 #
 # Copyright 2005 Alexandre Julliard
-# Copyright 2009 Nagios Plugins Development Team
+# Copyright 2009-2014 Nagios Plugins Development Team
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as