Browse Source

CODING merge

abrist 11 năm trước cách đây
mục cha
commit
bd6ae93f6a

+ 1 - 0
.gitignore

@@ -187,6 +187,7 @@ NP-VERSION-FILE
 /plugins/check_time
 /plugins/check_udp
 /plugins/check_ups
+/plugins/check_uptime
 /plugins/check_users
 /plugins/check_vsz
 /plugins/config.h

+ 1 - 1
ACKNOWLEDGEMENTS

@@ -1,6 +1,6 @@
 This file contains the origin of code copied verbatim into some or all of the Nagios plugins.
 
-The NagiosPlugin team thanks the original authors.
+The NagiosPlugin team would like to thank the Ethan Galstad and all the other original authors.
 
 Copied code is cited in the source by indented comments of the form
 

+ 2 - 0
AUTHORS

@@ -2,6 +2,7 @@ The Nagios Plugins are brought to you by the Nagios Plugins Development Team.
 
 Jeremy T. Bouse
 Peter Bray
+Andy Brist
 Gavin Carr
 Karl DeBisschop
 Matthias Eble
@@ -14,6 +15,7 @@ Matthew Kent
 Harper Mann
 Benoit Mortier
 Sven Nierlein
+Spenser Reinhardt
 Eric Stanley
 Nathan Vonnahme
 Ton Voon

+ 29 - 0
CODING

@@ -39,6 +39,7 @@ and type prior to further use. One such example would be using strncpy()
 instead of strcpy() to validate that the copied object does not overflow the
 bounds of the object being copied to.
 
+
 2. Perl Language Programming
 
 Taken from the O'Reilly book "Programming Perl" (3rd edition, pages 604-606)
@@ -118,3 +119,31 @@ s) Use underscore to split words in long identifiers. That is, use
 $service_port instead of $ServicePort as the former is much more readable.
 
 *) Always check the return code of system calls.
+
+
+3. Reserved and Semi-Reserved Plugin Options:
+
+-h, --help (REQUIRED!!!!!)
+-V, --version (REQUIRED!!!!!)
+-v, --verbose
+-q, --quiet
+-t, --timeout = INTEGER (senonds)
+-c, --critical = (INT|FLOAT|RANGE|LIST) 
+-w, --warning = (INT|FLOAT|RANGE|LIST)
+-H, --hostname = STRING
+-F, --file = STRING (usually input) 
+-O, --output = STRING (output file) 
+
+Recommended, but not reserverd: 
+
+-I, --ipaddress = STRING
+-C, --community = STRING
+-a, --auth(info) = STRING (authentication or password) 
+-l, --logname = STRING
+-p, --password = STRING
+-P, --port = INT
+-u, --url = STRING (also --username if --url is not needed)
+
+Port really should alway be '-P' (uppercase) -- but the plugins
+are currently inconsistent in that regard and may be hard to change
+as we do not want to break compatibility with earlier syntax.

+ 23 - 6
FAQ

@@ -8,6 +8,11 @@ A: All plugins that comply with minimal development guideline for
    can be read executing plugin with the -h or --help option. If 
    the '-h' option does not work, that is a bug.
 
+   Additionally, the man pages for the plugins are available on the
+   nagios-plugins website at:
+
+   http://nagios-plugins.org/doc/man/index.html
+
 
 Q: What version of <insert name> plugin am I running?
 
@@ -15,7 +20,7 @@ A: All plugins that comply with minimal development guideline for
    this project include detailed version information.  When executed
    with the '-V' option, a version string will be printed:
 
-   check_radius v1.4.16 (nagios-plugins 1.4.16)
+   check_radius v2.0 (nagios-plugins 2.0)
 
    All bug reports and help requests should reference this
    information.
@@ -67,7 +72,8 @@ A: Beginning with the 1.2.9-1 release, you may run
 
 Q: I get an error like
 
-   Warning: Return code of 127 for check of service 'PING' on host 'anyhost' was out of bounds.
+   Warning: Return code of 127 for check of service 'PING' on host 
+   'anyhost' was out of bounds.
 
    when I run Nagios. (Often check_ping runs just fine on the
    command line).
@@ -84,8 +90,19 @@ A: Commonly, system administrators will make security as tight as
 
 Q: I have a plugin to offer. What can I do?
 
-A: You can make it available on NagiosExchange (http://nagiosexchange.org)
-   where other people can find it for use.
+A: Contact a nagios-plugins team member in one of the following ways:
+
+   a) Forums:  
+	http://support.nagios.com/forum/viewforum.php?f=35
+
+   b) Mailing-list: 
+	http://lists.nagios.com/mailman/listinfo/nagiosplugin-devel 
+
+   c) Github:
+	https://github.com/nagios-plugins/nagios-plugins
+
+   d) If all else fails, post it to the Nagios Exchange:
+	http://exchange.nagios.org/
 
-   You can also get feedback on improving the plugin via the 
-   devel@nagios-plugins.org mailing list.
+   You can also get feedback on improving the plugin via any of the 
+   methods above.

+ 3 - 3
LEGAL

@@ -4,7 +4,7 @@ in this distribution are provided AS IS with NO WARRANTY OF ANY KIND,
 INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR
 A PARTICULAR PURPOSE.
 
-Nagios and the Nagios logo are trademarks of Ethan Galstad. All 
-other trademarks, servicemarks, registered trademarks, and 
-registered servicemarks are the property of their respective owner(s).
+Nagios, Nagios-Plugins, and the Nagios logo are trademarks of 
+Ethan Galstad. All other trademarks, servicemarks, registered trademarks, 
+and registered servicemarks are the property of their respective owner(s).
 

+ 76 - 24
NEWS

@@ -1,37 +1,89 @@
 This file documents the major additions and syntax changes between releases.
 
-1.6 ...
+2.0.1 15th April 2014
+	ENHANCMENTS
+	check_snmp.c - Added thresholds to performance data (jccomputing)
+	check_http.c - Added */* MIME support (Alex Gottschalk)
+	check_mailq.pl - Added autodetection for mailq implementation (evgeni)
+	check_mailq.pl - Added autodetected version to output (evgeni)
+
+	FIXES
+	check_dns.c - Record type corrections for default check (sreinhardt)
+	utils.c - Changed comment type - now supported by AIX and should no longer fail compile (hkpatv)
+	check_uptime.c - Fixed timeout option (abrist)
+	check_uptime.c - Fixed help output and updated verbose usage (abrist)
+	check_uptime.c - Removed executable permissions on check_uptime.c (abrist)
+	check_uptime.c - Removed old code (Davide Madrisan)
+	check_pgsql.c - Fixed help output (weiss)
+	lib/Makefile.am - Avoid deprecated includes (Davide Madrisan)
+	lib/tests/Makefile.am - Avoid deprecated includes (Davide Madrisan)
+	plugins/Makefile.am - Avoid deprecated includes (Davide Madrisan)
+	check_apt.c - Removed the verbose flag suggestion (skottler)
+	check_oracle.c - Changed regex to compensate for tns string match edge cases (waja)
+	check_snmp.c - Always privides the security name when noAuthPriv is specified (catharsis)
+
+2.0 4th March 2014
+	ADDITIONS
+	check_uptime - New plugin (only supports linux due to dependency on clock.gettime().  More supported platforms to follow.	
+
 	ENHANCEMENTS
-	Added performance data to check_mysql_query (sreinhardt)
-	New check_file_age option -i/--ignore-missing which returns OK if file is missing (waja)
-	Added performance data to check_nt UPTIME -l seconds|minutes|hours|days (abrist)
-	New check_hpjd -p option for port specification (abrist)
-	New check_disk -n option for multi-line output (tmcnag)
-	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_mysql_query - Added performance data (sreinhardt)
+	check_file_age - New option -i/--ignore-missing which returns OK if file is missing (waja)
+	check_nt - Added performance data to UPTIME -l seconds|minutes|hours|days (abrist)
+	check_hpjd - New -p option for port specification (abrist)
+	check_disk - new -n option for multi-line output (tmcnag)
+	check_mysql_query - New -f/-g options for reading for mysql options file (awiddersheim)
+	check_mailq - New -M option for nullmailer support in the mailserver (Luca Corti)
+	check_dig - New -r option for specifying number of retries (abrist)
 	check_ntp_peer - Added state output for each checked metric (abrist)
+	check_dns - Warning and critical thresholds added to perfdata (jccomputing) (abrist)
+	check_dns - New -q options for several query types (AAAA,TXT,SRV,MX) (sreinhardt)
+	check_tcp - Status output now includes hostname when host_specified is set (madrisan)
+	check_mysql - New -n/--ignore_auth option to ignore authentication failure (Julius Kriukas)
+	check_ssh - New -P/--remote-protocol option to monitor the ssh protocol version (monitoring-user)
+	check_ntp - New -o/--time-offset option to compensate for the ntp server's offset relative to the local server (monitoring-user)
+	configure.ac - Added support for --disable-maintainer-mode (weiss)
 
 	FIXES
-	Don't let e.g. check_http's -C option reset SSL version if e.g. -S 1 -C 5 is specified
-	check_ide_smart now defaults to nagios-compatible output (sreinhardt)
+	check_http - The -C option no longer resets SSL version if e.g. -S 1 -C 5 is specified
+	check_ide_smart - Now defaults to nagios-compatible output (sreinhardt)
 	Fixed misleading timeout message for non-network plugins (sreinhardt)
-	check_swap now fails with 100% usage and a new status output when swap is disabled or missing (abrist)
-	Removed commas from check_ifstatus perfdata - should now output valid perfdata in nagios format (waja)
-	check_ping should now gracefully handle the "time of day goes back" error.  This issue is rare, most will not notice the change (waja)
-	check_disk help output was clarified that it supports mount paths or partitions instead of just paths and partitions (waja)
-	Fixed check_ide_smart attribute comparison (waja)
-	Fixed bug in check_ntp_time average time calculation (larsi)
-	Fixed empty NPTest.cache file blocking writing to the file (dermoth)
-	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)
+	check_swap - Now fails with 100% usage and a new status output when swap is disabled or missing (abrist)
+	check_ifstatus - Removed commas from perfdata - should now output valid perfdata in nagios format (waja)
+	check_ping - Now gracefully handle the "time of day goes back" error.  This issue is rare, most will not notice the change (waja)
+	check_disk - Help output was clarified that it supports mount paths or partitions instead of just paths and partitions (waja)
+	check_ide_smart - Fixed attribute comparison (waja)
+	check_ntp_time - Fixed average time calculation (larsi)
+	NPTest.cache - Empty or Missing file no longer blocks writing to the file (dermoth)
+	parse.ini - Fixed newlines in output (dermoth)
+	check_dig - Fixed wrong IPv6 arguments order (Stéphane Bortzmeyer)
+	check_dig - Now honors timeout value specified by switch -t (Jethro Carr) (abrist)
+	configure.in - Renamed to configure.ac to avoid deprecation warning (abrist)
+	configure.ac - The option --enable-extra-opts is now enabled by default (dermoth)
+	check_snmp - Now handles negative values properly (Stephane Lapie)
 
 	WARNINGS
-	check_procs now ignores its parent process to avoid unexpected results when invoked via certain shells
-	utils.sh no longer defines ECHO (weiss)
+	check_procs - Now ignores its parent process to avoid unexpected results when invoked via certain shells
+	utils.sh - No longer defines ECHO (weiss)
 	check_ide_smart now default to nagios output, -n kept for legacy support (sreinhardt)
+	check_ntp_peer - Status output changed, now includes individual state for offset, truechimers, stratum, and jitter (abrist)
+	check_tcp - Status output has changed, now includes hostname (madrisan)
+
+	TESTS
+	check_procs - Performance data tests added (dermoth)
+	check_snmp - Added tests for negative thresholds (dermoth)
+	check_hpjd - Added tests for port options (abrist)
+	check_dns - Added new tests for query types (abrist)
+	check_pop - Added option to enable ssl for the test (abrist)
+	check_jabber - Fixed status output tests to account for hostname (abrist)
+	check_procs - Tests no longer fail if uid 501 is not present (sni)
+	check_mysql - Test prompts clarified (dermoth)
+	check_file_age - Added tests for --ignore-missing (waja)
+
+	OTHER
+	Numerous small typos fixed.
+	Help output has been changed in many places for clarity and verbosity.
+	
 
 1.5 2nd October 2013
 	ENHANCEMENTS

+ 15 - 13
NP-VERSION-GEN

@@ -6,7 +6,7 @@
 SRC_ROOT=`dirname $0`
 
 NPVF=NP-VERSION-FILE
-DEF_VER=1.5.git
+DEF_VER=2.0.1.git
 
 LF='
 '
@@ -19,21 +19,22 @@ if test -d $SRC_ROOT/.git -o -f $SRC_ROOT/.git &&
 	release-[0-9]*)
 		git update-index -q --refresh
 		test -z "`git diff-index --name-only HEAD --`" ||
-		VN="$VN-dirty" ;;
+		VN="$VN-dirty" 
+		echo $VN;;
 	esac
 then
 	VN=`echo "$VN" | sed -e 's/^release-//' | sed -e 's/-/./g'`;
-elif test -d $SRC_ROOT/.svn -o -f $SRC_ROOT/.svn &&
-	VN=`cd $SRC_ROOT; svn info 2>/dev/null | grep '^Revision'` &&
-	case "$VN" in
-	*$LF*) (exit 1) ;;
-	Revision:*)
-		VN=`echo $VN | awk '{print $NF}'`
-		test "`svn status 2>/dev/null | grep '^[AMD]' | wc -l | tr -d ' '`" = 0 ||
-		VN="$VN-dirty" ;;
-	esac
-then
-	VN=`echo "trunk.$VN" | sed -e 's/-/./g'`;
+#elif test -d $SRC_ROOT/.svn -o -f $SRC_ROOT/.svn &&
+#	VN=`cd $SRC_ROOT; svn info 2>/dev/null | grep '^Revision'` &&
+#	case "$VN" in
+#	*$LF*) (exit 1) ;;
+#	Revision:*)
+#		VN=`echo $VN | awk '{print $NF}'`
+#		test "`svn status 2>/dev/null | grep '^[AMD]' | wc -l | tr -d ' '`" = 0 ||
+#		VN="$VN-dirty" ;;
+#	esac
+#then
+#	VN=`echo "trunk.$VN" | sed -e 's/-/./g'`;
 else
 	VN="$DEF_VER"
 fi
@@ -46,6 +47,7 @@ then
 else
 	VC=unset
 fi
+echo "$VN"
 test "$VN" = "$VC" || {
 	echo >&2 "NP_VERSION = $VN"
 	echo "NP_VERSION = $VN" >$NPVF

+ 29 - 0
README

@@ -81,6 +81,35 @@ That's it!  If you have any problems or questions, feel free to send an
 email to <help@nagios-plugins.org>.
 
 
+Testing With libtap
+-------------------
+
+1.  The nagios-plugins source includes a perl testing suite.  the libtap 
+    library and headers are included with the source.  Configure with:
+
+	./configure --enable-libtap
+
+    Note: "--enable-extra-opts" used to be required as well, but is no 
+    longer required as it is a default configure option.
+
+2.  Make and then make test:
+
+	make
+	make test
+
+3.  Testing is pseudo intelligent and will try to autodetect which plugins
+    to test.  You may need to look at the REQUIREMENTS doc as to what
+    dependencies are required to satisfy the test.
+
+    Additionally, default and user supplied (at runtime) testing parameters
+    are saved in the file:
+
+	/var/tmp/NPTest.cache
+
+    If you need to change any testing parameters, edit them in this file
+    or just remove the line to force the test to re-prompt you for input.
+
+
 License Notice
 --------------
 

+ 4 - 0
REQUIREMENTS

@@ -82,6 +82,10 @@ check_ups:
 check_ide_smart:
 	- Uses the Linux specific SMART interface [http://smartlinux.sourceforge.net/smart/index.php]. 
 
+check_uptime:
+	- Currently only supports linux due to a dependency on clock.gettime. 
+	  We will be expanding supported platforms in the future.
+
 OS Specific Issues
 ------------------
 

+ 28 - 4
SUPPORT

@@ -1,4 +1,24 @@
-SUPPORT
+FORUMS SUPPORT
+--------------
+
+Even though the mailing list are still used for support, the forums are
+by far the fastest and best way to receive support these days.
+
+General plugin usage and Nagios integration questions can be posted at:
+
+    http://support.nagios.com/forum/viewforum.php?f=7
+
+Bug reports and development queries should be posted to the development
+forums:
+
+    http://support.nagios.com/forum/viewforum.php?f=35
+
+The mailing lists are still alive and you are welcome to post your
+questions to the list if you are inclined to do so:
+
+
+MAILING LIST SUPPORT
+--------------------
 
 Using the mailing lists and tracker databases at SourceForge are the
 best ways to obtain direct support for the Nagios Plugins. There may
@@ -19,16 +39,18 @@ you interest to do a modest amount of legwork before posting to either
 of these lists.
 
 Plugins that are in the contrib directories are provided as-is. We will 
-try to help, but sometimes the plugins have dependencies that the nagios-plugin
-developers do not have access to. You may be able to try the authors
-directly.
+try to help, but sometimes the plugins have dependencies that the
+nagios-plugin developers do not have access to. You may be able to try
+the authors directly.
 
 In brief, always provide the version of the software that you are
 using, and when requesting features or reporting bugs, first check to
 see that the issue has not already been addressed in the current Git
 code.
 
+
 GETTING HELP
+------------
 
 Requests to 'help' require posting the version number of the
 plugin. The best place to include the version information is in the
@@ -44,7 +66,9 @@ plugins) will provide a description of their use when invoked with the
 '--help' option. Please read the help carefully and in it's entirety
 before asking for support.
 
+
 REPORTING BUGS AND SUBMITTING PATCHES
+-------------------------------------
 
 Bug reports, investigations of possible bugs, feature requests, and
 patch submissions should be submitted to the development list at

+ 7 - 0
THANKS.in

@@ -312,3 +312,10 @@ Jethro Carr
 Neil Prockter
 Patrick McAndrew
 Julius Kriukas
+Andy Brist
+Spenser Reinhardt
+Sam Kottler
+Frederic Krueger
+Anton Lofgren
+Evgeni Golov
+Davide Madrisan

+ 61 - 25
configure.ac

@@ -1,6 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.59)
-AC_INIT(nagios-plugins,2.0)
+AC_INIT(nagios-plugins,2.0.1)
 AC_CONFIG_SRCDIR(NPTest.pm)
 AC_CONFIG_FILES([gl/Makefile 
 	nagios-plugins.spec])
@@ -91,6 +91,7 @@ ac_cv_uname_m=`uname -m`
 ac_cv_uname_s=`uname -s`
 ac_cv_uname_r=`uname -r`
 ac_cv_uname_v=`uname -v`
+ac_cv_uname_o=`uname -o`
 
 PKG_ARCH=`uname -p`
 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
@@ -242,7 +243,7 @@ if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
     else
       AC_SUBST(PGLIBS)
       AC_SUBST(PGINCLUDE)
-      EXTRAS="$EXTRAS check_pgsql"
+      EXTRAS="$EXTRAS check_pgsql\$(EXEEXT)"
     fi
   else
     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
@@ -262,7 +263,7 @@ AS_IF([test "x$with_dbi" != "xno"], [
   _SAVEDLIBS="$LIBS"
   AC_CHECK_LIB(dbi,dbi_initialize)
   if test "$ac_cv_lib_dbi_dbi_initialize" = "yes"; then
-    EXTRAS="$EXTRAS check_dbi"
+    EXTRAS="$EXTRAS check_dbi\$(EXEEXT)"
   	DBILIBS="-ldbi"
     AC_SUBST(DBILIBS)
   else
@@ -279,13 +280,13 @@ AS_IF([test "x$with_radius" != "xno"], [
   _SAVEDLIBS="$LIBS"
   AC_CHECK_LIB(radiusclient,rc_read_config)
   if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
-    EXTRAS="$EXTRAS check_radius"
+    EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
   	RADIUSLIBS="-lradiusclient"
     AC_SUBST(RADIUSLIBS)
   else
     AC_CHECK_LIB(radiusclient-ng,rc_read_config)
     if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
-      EXTRAS="$EXTRAS check_radius"
+      EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
     	  RADIUSLIBS="-lradiusclient-ng"
       AC_SUBST(RADIUSLIBS)
     else
@@ -308,7 +309,7 @@ AS_IF([test "x$with_ldap" != "xno"], [
     AC_SUBST(LDAPLIBS)
     AC_SUBST(LDAPINCLUDE)
     AC_CHECK_FUNCS(ldap_set_option)
-    EXTRAS="$EXTRAS check_ldap"
+    EXTRAS="$EXTRAS check_ldap\$(EXEEXT)"
   	AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
   else
     AC_MSG_WARN([Skipping LDAP plugin])
@@ -345,16 +346,32 @@ case $host in
 esac
 
 if test "$FOUNDINCLUDE" = "yes" ; then
-	EXTRAS="$EXTRAS check_ide_smart"
+	EXTRAS="$EXTRAS check_ide_smart\$(EXEEXT)"
 fi
 
+dnl Check for headers used by check_uptime
+case $host in
+  *linux*)
+    AC_CHECK_HEADER(sys/time.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
+    if test "$FOUNDINCLUDE" = "no" ; then
+	AC_MSG_WARN([Skipping check_uptime plugin.])
+	AC_MSG_WARN([check_uptime requires sys/time.h])
+    else
+        EXTRAS="$EXTRAS check_uptime"
+    fi
+  ;;
+  *)
+    AC_MSG_WARN([Skipping check_uptime plugin.])
+    AC_MSG_WARN([check_uptime works only on Linux])
+esac
+
 dnl Check for mysql libraries
 np_mysqlclient
 if test $with_mysql = "no" ; then
   AC_MSG_WARN([Skipping mysql plugin])
   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
 else
-  EXTRAS="$EXTRAS check_mysql check_mysql_query"
+  EXTRAS="$EXTRAS check_mysql\$(EXEEXT) check_mysql_query\$(EXEEXT)"
   MYSQLINCLUDE="$np_mysql_include"
   MYSQLLIBS="$np_mysql_libs"
   MYSQLCFLAGS="$np_mysql_cflags"
@@ -367,8 +384,16 @@ dnl Check for headers used by check_users
 AC_CHECK_HEADERS(utmpx.h)
 AM_CONDITIONAL([HAVE_UTMPX], [test "$ac_cv_header_utmpx_h" = "yes"])
 
+AC_CHECK_HEADERS(wtsapi32.h, [], [], [#include <windows.h>])
+AM_CONDITIONAL([HAVE_WTS32API], [test "$ac_cv_header_wtsapi32_h" = "yes"])
+
+if test "$ac_cv_header_wtsapi32_h" = "yes"; then
+  WTSAPI32LIBS="-lwtsapi32"
+  AC_SUBST(WTSAPI32LIBS)
+fi
+
 dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface
-if test "$ac_cv_header_utmpx_h" = "no"
+if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no"
 then
 	AC_PATH_PROG(PATH_TO_WHO,who)
 
@@ -656,7 +681,7 @@ elif test "$ac_cv_uname_s" = "SunOS"; then
 	else
 		AC_MSG_NOTICE([using 32bit pst3])
 	fi
-        EXTRAS_ROOT="$EXTRAS_ROOT pst3"
+        EXTRAS_ROOT="$EXTRAS_ROOT pst3\$(EXEEXT)"
 
 	if test "$pst3_use_64bit" = 1; then
 		dnl Test if we can actually compile code in 64bit
@@ -981,7 +1006,7 @@ if test -n "$ac_cv_ps_varlist" ; then
 		[Format string for scanning ps output in check_procs])
 	AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
 		[Number of columns in ps command])
-	EXTRAS="$EXTRAS check_procs check_nagios"
+	EXTRAS="$EXTRAS check_procs check_nagios\$(EXEEXT)"
 	if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
 		AC_DEFINE(PS_USES_PROCETIME,"yes",
 		          [Whether the ps utility uses the "procetime" field])
@@ -1015,6 +1040,13 @@ then
 		ac_cv_ping_packets_first=yes
 	fi
 
+elif [[ "z$ac_cv_uname_o" = "zCygwin" ]]
+then
+	with_ping_command="$PATH_TO_PING -n %d -w %d000 %s"
+	ac_cv_ping_packets_first=yes
+	ac_cv_ping_has_timeout=yes
+	AC_MSG_RESULT([$with_ping_command])
+
 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
 	$PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
 	egrep -i "^round-trip|^rtt" >/dev/null
@@ -1028,7 +1060,7 @@ elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
 then
 	with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
 	ac_cv_ping_packets_first=yes
-  ac_cv_ping_has_timeout=yes
+	ac_cv_ping_has_timeout=yes
 	AC_MSG_RESULT([$with_ping_command])
 
 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
@@ -1125,7 +1157,11 @@ then
 	then
 		ac_cv_ping6_packets_first=yes
 	fi
-
+elif [[ "z$ac_cv_uname_o" = "zCygwin" -a "x$PATH_TO_PING" != "x" ]]; then
+	with_ping6_command="$PATH_TO_PING -6 -n %d -w %d000 %s"
+	ac_cv_ping6_packets_first=yes
+	ac_cv_ping_has_timeout=yes
+	AC_MSG_RESULT([$with_ping6_command])
 elif test "x$PATH_TO_PING6" != "x"; then
 	if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
 		$PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
@@ -1303,7 +1339,7 @@ else
 fi
 
 if test -n "$ac_cv_nslookup_command"; then
-	EXTRAS="$EXTRAS check_dns"
+	EXTRAS="$EXTRAS check_dns\$(EXEEXT)"
 	AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
 fi
 
@@ -1363,7 +1399,7 @@ AC_ARG_WITH(snmpget_command,
 if test -n "$PATH_TO_SNMPGET"
 then
 	AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
-	EXTRAS="$EXTRAS check_hpjd check_snmp"
+	EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)"
 else
 	AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
 fi
@@ -1395,12 +1431,12 @@ AC_ARG_WITH(qstat_command,
 if test -x "$PATH_TO_QUAKESTAT"
 then
 	ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
-	EXTRAS="$EXTRAS check_game"
+	EXTRAS="$EXTRAS check_game\$(EXEEXT)"
 
 elif test -n "$PATH_TO_QSTAT"
 then
 	ac_cv_path_to_qstat="$PATH_TO_QSTAT"
-	EXTRAS="$EXTRAS check_game"
+	EXTRAS="$EXTRAS check_game\$(EXEEXT)"
 else
 	AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
 fi
@@ -1424,7 +1460,7 @@ AC_ARG_WITH(fping6_command,
 if test -n "$PATH_TO_FPING"
 then
 	AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
-	EXTRAS="$EXTRAS check_fping"
+	EXTRAS="$EXTRAS check_fping\$(EXEEXT)"
 	if test x"$with_ipv6" != xno && test -n "$PATH_TO_FPING6"; then
 		AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6])
 	fi
@@ -1439,7 +1475,7 @@ AC_ARG_WITH(ssh_command,
 if test -n "$PATH_TO_SSH"
 then
 	AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
-	EXTRAS="$EXTRAS check_by_ssh"
+	EXTRAS="$EXTRAS check_by_ssh\$(EXEEXT)"
 else
 	AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
 fi
@@ -1578,7 +1614,7 @@ AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
 
 if test "$ac_cv_have_decl_swapctl" = "yes";
 then
-	EXTRAS="$EXTRAS check_swap"
+	EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
 	AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
 	if test "$ac_cv_type_swaptbl_t" = "yes" -a \
 	        "$ac_cv_type_swapent_t" = "yes";
@@ -1634,7 +1670,7 @@ dnl
 if test "x$ac_cv_have_swap" != "x"
 then
 	AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
-	EXTRAS="$EXTRAS check_swap"
+	EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
 fi
 if test "x$ac_cv_swap_command" != "x"
 then
@@ -1666,7 +1702,7 @@ fi
 if test -n "$ac_cv_proc_meminfo"; then
 	AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
 	AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
-	EXTRAS="$EXTRAS check_swap"
+	EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
 fi
 
 AC_PATH_PROG(PATH_TO_DIG,dig)
@@ -1674,7 +1710,7 @@ AC_ARG_WITH(dig_command,
             ACX_HELP_STRING([--with-dig-command=PATH],
                             [Path to dig command]), PATH_TO_DIG=$withval)
 if test -n "$PATH_TO_DIG"; then
-	EXTRAS="$EXTRAS check_dig"
+	EXTRAS="$EXTRAS check_dig\$(EXEEXT)"
 	AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
 fi
 
@@ -1686,12 +1722,12 @@ AC_ARG_WITH(apt-get_command,
                             with_apt_get_command=$PATH_TO_APTGET)
 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
 if test -n "$PATH_TO_APTGET" ; then
-	EXTRAS="$EXTRAS check_apt"
+	EXTRAS="$EXTRAS check_apt\$(EXEEXT)"
 fi
 
 
 if test -f $srcdir/plugins/check_nt.c ; then
-  EXTRAS="$EXTRAS check_nt"
+  EXTRAS="$EXTRAS check_nt\$(EXEEXT)"
 fi
 
 

+ 2 - 3
lib/Makefile.am

@@ -4,7 +4,8 @@ SUBDIRS = . tests
 
 noinst_LIBRARIES = libnagiosplug.a
 
-AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\"
+AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\" \
+	-I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
 
 libnagiosplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c
 EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h parse_ini.h extra_opts.h
@@ -13,8 +14,6 @@ if USE_PARSE_INI
 libnagiosplug_a_SOURCES += parse_ini.c extra_opts.c
 endif USE_PARSE_INI
 
-INCLUDES = -I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
-
 test test-debug:
 	cd tests && make $@
 

+ 2 - 3
lib/tests/Makefile.am

@@ -5,9 +5,8 @@ noinst_PROGRAMS = @EXTRA_TEST@
 TESTS = @EXTRA_TEST@
 check_PROGRAMS = @EXTRA_TEST@
 
-AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\"
-
-INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
+AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\" \
+	-I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
 
 EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini1 test_ini3 test_opts1 test_opts2 test_opts3
 

+ 44 - 19
plugins-scripts/check_mailq.pl

@@ -199,20 +199,20 @@ if ($mailq eq "sendmail") {
 	## now check the queue length(s)
 
 	if ($msg_q == 0) {
-		$msg = "OK: mailq is empty";
+		$msg = "OK: $mailq mailq is empty";
 		$state = $ERRORS{'OK'};
 	} else {
 		print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose;
 	
 		# overall queue length
 		if ($msg_q < $opt_w) {
-			$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+			$msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
 			$state = $ERRORS{'OK'};
 		}elsif ($msg_q >= $opt_w  && $msg_q < $opt_c) {
-			$msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+			$msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
 			$state = $ERRORS{'WARNING'};
 		}else {
-			$msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+			$msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
 			$state = $ERRORS{'CRITICAL'};
 		}
 
@@ -344,20 +344,20 @@ elsif ( $mailq eq "postfix" ) {
 
         # check queue length(s)
         if ($msg_q == 0){
-                $msg = "OK: mailq reports queue is empty";
+                $msg = "OK: $mailq mailq reports queue is empty";
                 $state = $ERRORS{'OK'};
         } else {
                 print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose;
 
                 # overall queue length
                 if ($msg_q < $opt_w) {
-                        $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+                        $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
                         $state = $ERRORS{'OK'};
                 }elsif  ($msg_q >= $opt_w  && $msg_q < $opt_c) {
-                        $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+                        $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
                         $state = $ERRORS{'WARNING'};
                 }else {
-                        $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+                        $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
                         $state = $ERRORS{'CRITICAL'};
                 }
 
@@ -431,13 +431,13 @@ elsif ( $mailq eq "qmail" ) {
 		
 		# overall queue length
 		if ($msg_q < $opt_w) {
-			$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+			$msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
 			$state = $ERRORS{'OK'};
 		}elsif ($msg_q >= $opt_w  && $msg_q < $opt_c) {
-			$msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+			$msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
 			$state = $ERRORS{'WARNING'};
 		}else {
-			$msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+			$msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
 			$state = $ERRORS{'CRITICAL'};
 		}
 
@@ -489,13 +489,13 @@ elsif ( $mailq eq "exim" ) {
 		exit $ERRORS{CRITICAL};
 	}
 	if ($msg_q < $opt_w) {
-		$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+		$msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
 		$state = $ERRORS{'OK'};
 	}elsif ($msg_q >= $opt_w  && $msg_q < $opt_c) {
-		$msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+		$msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
 		$state = $ERRORS{'WARNING'};
 	}else {
-		$msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+		$msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
 		$state = $ERRORS{'CRITICAL'};
 	}
 } # end of ($mailq eq "exim")
@@ -526,13 +526,13 @@ elsif ( $mailq eq "nullmailer" ) {
 	}
 	close(MAILQ) ;
 	if ($msg_q < $opt_w) {
-		$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+		$msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
 		$state = $ERRORS{'OK'};
 	}elsif ($msg_q >= $opt_w  && $msg_q < $opt_c) {
-		$msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+		$msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
 		$state = $ERRORS{'WARNING'};
 	}else {
-		$msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+		$msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
 		$state = $ERRORS{'CRITICAL'};
 	}
 } # end of ($mailq eq "nullmailer")
@@ -605,7 +605,30 @@ sub process_arguments(){
 			exit $ERRORS{'UNKNOWN'};
 		}
 	}else{
-		$mailq = 'sendmail' ;
+		if (defined $utils::PATH_TO_QMAIL_QSTAT
+		    && -x $utils::PATH_TO_QMAIL_QSTAT)
+		{
+			$mailq = 'qmail';
+		}
+		elsif (-d '/var/lib/postfix' || -d '/var/local/lib/postfix'
+		       || -e '/usr/sbin/postfix' || -e '/usr/local/sbin/postfix')
+		{
+			$mailq = 'postfix';
+		}
+		elsif (-d '/usr/lib/exim4' || -d '/usr/local/lib/exim4'
+		       || -e '/usr/sbin/exim' || -e '/usr/local/sbin/exim')
+		{
+			$mailq = 'exim';
+		}
+		elsif (-d '/usr/lib/nullmailer' || -d '/usr/local/lib/nullmailer'
+		       || -e '/usr/sbin/nullmailer-send'
+		       || -e '/usr/local/sbin/nullmailer-send')
+		{
+			$mailq = 'nullmailer';
+		}
+		else {
+			$mailq = 'sendmail';
+		}
 	}
 		
 	return $ERRORS{'OK'};
@@ -628,7 +651,7 @@ sub print_help () {
 	print "-W (--Warning)   = Min. number of messages for same domain in queue to generate warning\n";
 	print "-C (--Critical)  = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
 	print "-t (--timeout)   = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
-	print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = sendmail)\n";
+	print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n";
 	print "-h (--help)\n";
 	print "-V (--version)\n";
 	print "-v (--verbose)   = debugging output\n";
@@ -636,6 +659,8 @@ sub print_help () {
 	print "Note: -w and -c are required arguments.  -W and -C are optional.\n";
 	print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n";
 	print " -W and -C are applied message not yet preproccessed. (qmail)\n";
+	print " This plugin tries to autodetect which mailserver you are running,\n";
+	print " you can override the autodetection with -M.\n";
 	print " This plugin uses the system mailq command (sendmail) or qmail-stat (qmail)\n";
 	print " to look at the queues. Mailq can usually only be accessed by root or \n";
 	print " a TrustedUser. You will have to set appropriate permissions for the plugin to work.\n";

+ 1 - 1
plugins-scripts/check_oracle.sh

@@ -136,7 +136,7 @@ case "$cmd" in
     tnschk=` tnsping $2`
     tnschk2=` echo  $tnschk | grep -c OK`
     if [ ${tnschk2} -eq 1 ] ; then 
-	tnschk3=` echo $tnschk | sed -e 's/.*(//' -e 's/).*//'`
+	tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*}
 	echo "OK - reply time ${tnschk3} from $2"
 	exit $STATE_OK
     else

+ 9 - 7
plugins/Makefile.am

@@ -13,7 +13,8 @@ AM_CFLAGS = -DNP_VERSION='"$(NP_VERSION)"'
 
 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@
+AM_CPPFLAGS = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl \
+	@LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@
 
 localedir = $(datadir)/locale
 # gettext docs say to use AM_CPPFLAGS, but per module_CPPFLAGS override this
@@ -37,7 +38,7 @@ check_tcp_programs = check_ftp check_imap check_nntp check_pop \
 EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
 	check_swap check_fping check_ldap check_game check_dig \
 	check_nagios check_by_ssh check_dns check_nt check_ide_smart	\
-	check_procs check_mysql_query check_apt check_dbi
+	check_procs check_mysql_query check_apt check_dbi check_uptime
 
 EXTRA_DIST = t tests
 
@@ -81,11 +82,11 @@ check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS)
 check_load_LDADD = $(BASEOBJS)
 check_mrtg_LDADD = $(BASEOBJS)
 check_mrtgtraf_LDADD = $(BASEOBJS)
-check_mysql_CFLAGS = $(MYSQLCFLAGS) -DNP_VERSION='"$(NP_VERSION)"'
-check_mysql_CPPFLAGS = $(MYSQLINCLUDE)
+check_mysql_CFLAGS = $(AM_CFLAGS) $(MYSQLCFLAGS)
+check_mysql_CPPFLAGS = $(AM_CPPFLAGS) $(MYSQLINCLUDE)
 check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS)
-check_mysql_query_CFLAGS = $(MYSQLCFLAGS) -DNP_VERSION='"$(NP_VERSION)"'
-check_mysql_query_CPPFLAGS = $(MYSQLINCLUDE)
+check_mysql_query_CFLAGS = $(AM_CFLAGS) $(MYSQLCFLAGS)
+check_mysql_query_CPPFLAGS = $(AM_CPPFLAGS) $(MYSQLINCLUDE)
 check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS)
 check_nagios_LDADD = $(BASEOBJS)
 check_nt_LDADD = $(NETLIBS) 
@@ -106,7 +107,8 @@ check_tcp_LDADD = $(SSLOBJS)
 check_time_LDADD = $(NETLIBS)
 check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS)
 check_ups_LDADD = $(NETLIBS)
-check_users_LDADD = $(BASEOBJS)
+check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS)
+check_uptime_LDADD = $(BASEOBJS) -lrt
 check_by_ssh_LDADD = $(NETLIBS)
 check_ide_smart_LDADD = $(BASEOBJS)
 negate_LDADD = $(BASEOBJS)

+ 1 - 1
plugins/check_apt.c

@@ -124,7 +124,7 @@ int main (int argc, char **argv) {
 	       (stderr_warning)?" warnings detected":"",
 	       (stderr_warning && exec_warning)?",":"",
 	       (exec_warning)?" errors detected":"",
-	       (stderr_warning||exec_warning)?". run with -v for information.":"",
+	       (stderr_warning||exec_warning)?".":"",
 	        packages_available,
 		   sec_count
 	       );

+ 20 - 1
plugins/check_disk.c

@@ -52,6 +52,11 @@ const char *email = "devel@nagios-plugins.org";
 #endif
 #include "regex.h"
 
+#ifdef __CYGWIN__
+# include <windows.h>
+# undef ERROR
+# define ERROR -1
+#endif
 
 /* If nonzero, show inode information. */
 static int inode_format = 1;
@@ -176,6 +181,10 @@ main (int argc, char **argv)
   struct fs_usage fsp, tmpfsp;
   struct parameter_list *temp_list, *path;
 
+#ifdef __CYGWIN__
+  char mountdir[32];
+#endif
+
   preamble = strdup (" - free space:");
   output = strdup ("");
   details = strdup ("");
@@ -222,7 +231,6 @@ main (int argc, char **argv)
 
   /* Process for every path in list */
   for (path = path_select_list; path; path=path->name_next) {
-
     if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL)
       printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end,
                                                          path->freespace_percent->critical->end);
@@ -235,6 +243,13 @@ main (int argc, char **argv)
 
     me = path->best_match;
 
+#ifdef __CYGWIN__
+    if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11)
+	    continue;
+    snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10);
+    if (GetDriveType(mountdir) != DRIVE_FIXED)
+	    me->me_remote = 1;
+#endif
     /* Filters */
 
     /* Remove filesystems already seen */
@@ -989,6 +1004,10 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
   } else {
     /* find all group members */
     for (p_list = path_select_list; p_list; p_list=p_list->name_next) {
+#ifdef __CYGWIN__
+      if (strncmp(p_list->name, "/cygdrive/", 10) != 0)
+        continue;
+#endif
       if (p_list->group && ! (strcmp(p_list->group, p->group))) {
         stat_path(p_list);
         get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp);

+ 13 - 11
plugins/check_dns.c

@@ -94,6 +94,7 @@ main (int argc, char **argv)
   int n_addresses = 0;
   char *msg = NULL;
   char query_found[16] = "";
+  int query_size = 16;
   char *temp_buffer = NULL;
   int non_authoritative = TRUE;
   int result = STATE_UNKNOWN;
@@ -150,74 +151,75 @@ main (int argc, char **argv)
       non_authoritative = FALSE;
       break;
     }
-    /* the server is responding, we just got the host name... */
+    /* the server is responding, we just got the host name...*/
     if (strstr (chld_out.line[i], "Name:"))
       parse_address = TRUE;
     /* begin handling types of records */
-    if (strstr (chld_out.line[i], "AAAA address")) {
+    if (strstr (chld_out.line[i], "AAAA address") && (strncmp(query_type, "-querytype=AAAA", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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 =")) {
+    else if (strstr (chld_out.line[i], "exchanger =") && (strncmp(query_type, "-querytype=MX", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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 =")) {
+    else if (strstr (chld_out.line[i], "service =") && (strncmp(query_type, "-querytype=SRV", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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 =")) {
+    else if (accept_cname && strstr (chld_out.line[i], "canonical name =") && (strncmp(query_type, "-querytype=CNAME", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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));
     }
+    /* does not need strncmp as we want A at all times unless another record match */
     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], ':');
       addresses[n_addresses++] = check_new_address(temp_buffer);
       strncpy(query_found, "-querytype=A", sizeof(query_found));
     }
-    else if (strstr (chld_out.line[i], "nameserver =")) {
+    else if (strstr (chld_out.line[i], "nameserver =") && (strncmp(query_type, "-querytype=NS", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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 =")) {
+    else if (strstr (chld_out.line[i], "dname =") && (strncmp(query_type, "-querytype=DNAME", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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 =")) {
+    else if (strstr (chld_out.line[i], "name =") && (strncmp(query_type, "-querytype=PTR", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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 =")) {
+    else if (strstr (chld_out.line[i], "protocol =") && (strncmp(query_type, "-querytype=WKS", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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 =")) {
+    else if (strstr (chld_out.line[i], "text =") && (strncmp(query_type, "-querytype=TXT", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       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 =")) {
+    else if (strstr (chld_out.line[i], "origin =") && (strncmp(query_type, "-querytype=SOA", query_size) == 0 || strncmp(query_type, "-querytype=ALL", query_size) == 0)) {
       if (verbose) printf("Found SOA record\n");
       temp_buffer = index(chld_out.line[i], '=');
       addresses[n_addresses++] = check_new_address(temp_buffer);

+ 6 - 0
plugins/check_http.c

@@ -912,6 +912,12 @@ check_http (void)
       xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
   }
 
+  /* Inform server we accept any MIME type response
+   * TODO: Take an arguement to determine what type(s) to accept,
+   * so that we can alert if a response is of an invalid type.
+  */
+  xasprintf(&buf, "%sAccept: */*\r\n", buf);
+
   /* optionally send any other header tag */
   if (http_opt_headers_count) {
     for (i = 0; i < http_opt_headers_count ; i++) {

+ 2 - 2
plugins/check_nt.c

@@ -314,10 +314,10 @@ int main(int argc, char **argv){
 
 		/* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
 		which equals RAM + Pagefiles. */
-		xasprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
+		xasprintf(&output_message,_("Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"),
 		  mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
 		  (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
-		xasprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
+		xasprintf(&perfdata,_("'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
 		  warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
 
 		return_code=STATE_OK;

+ 1 - 1
plugins/check_pgsql.c

@@ -514,7 +514,7 @@ print_help (void)
 
 	printf (" %s\n", "-d, --database=STRING");
 	printf ("    %s", _("Database to check "));
-	printf (_("(default: %s)"), DEFAULT_DB);
+	printf (_("(default: %s)\n"), DEFAULT_DB);
 	printf (" %s\n", "-l, --logname = STRING");
 	printf ("    %s\n", _("Login name of user"));
 	printf (" %s\n", "-p, --password = STRING");

+ 5 - 2
plugins/check_ping.c

@@ -458,7 +458,8 @@ run_ping (const char *cmd, const char *addr)
 			 (sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time%n",&pl,&match) && match) ||
 			 (sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time%n",&pl,&match) && match) ||
 			 (sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
-			 (sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match)
+			 (sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
+			 (sscanf(buf,"%*[^(](%d%% %*[^)])%n",&pl,&match) && match)
 			 )
 			continue;
 
@@ -471,7 +472,9 @@ run_ping (const char *cmd, const char *addr)
 				 (sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
 				 (sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f%n",&rta,&match) && match) ||
 				 (sscanf(buf,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
-				 (sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms%n",&rta,&match) && match))
+				 (sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms%n",&rta,&match) && match) ||
+				 (sscanf(buf, "%*[^=] = %*fms, %*[^=] = %*fms, %*[^=] = %fms%n", &rta, &match) && match)
+				 )
 			continue;
 	}
 

+ 25 - 4
plugins/check_snmp.c

@@ -573,6 +573,25 @@ main (int argc, char **argv)
 
 			if (type)
 				strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
+			if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL) {
+				xasprintf (&temp_string, "%s", unitv[i]);
+				strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
+				}
+
+
+			if (thlds[i]->warning || thlds[i]->critical) {
+				strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
+				if (thlds[i]->warning) {
+					xasprintf (&temp_string, "%.0f", thlds[i]->warning->end);
+					strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
+				}
+				strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
+				if (thlds[i]->critical) {
+					xasprintf (&temp_string, "%.0f", thlds[i]->critical->end);
+					strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
+				}
+				strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
+			}
 			strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
 		}
 	}
@@ -967,11 +986,16 @@ validate_arguments ()
 		if (seclevel == NULL)
 			xasprintf(&seclevel, "noAuthNoPriv");
 
+		if (secname == NULL)
+			die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname");
+
 		if (strcmp(seclevel, "noAuthNoPriv") == 0) {
-			numauthpriv = 2;
+			numauthpriv = 4;
 			authpriv = calloc (numauthpriv, sizeof (char *));
 			authpriv[0] = strdup ("-l");
 			authpriv[1] = strdup ("noAuthNoPriv");
+			authpriv[2] = strdup ("-u");
+			authpriv[3] = strdup (secname);
 		} else {
 			if (! ( (strcmp(seclevel, "authNoPriv")==0) || (strcmp(seclevel, "authPriv")==0) ) ) {
 				usage2 (_("Invalid seclevel"), seclevel);
@@ -980,9 +1004,6 @@ validate_arguments ()
 			if (authproto == NULL )
 				xasprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
 
-			if (secname == NULL)
-				die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname");
-
 			if (authpasswd == NULL)
 				die(STATE_UNKNOWN, _("Required parameter: %s\n"), "authpasswd");
 

+ 1 - 1
plugins/check_swap.c

@@ -1,6 +1,6 @@
 /*****************************************************************************
 * 
-* Nagios check_disk plugin
+* Nagios check_swap plugin
 * 
 * License: GPL
 * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)

+ 243 - 0
plugins/check_uptime.c

@@ -0,0 +1,243 @@
+/*********************************************************************************
+*
+* Nagios check_uptime plugin
+*
+* License: GPL
+* Copyright (c) 2013-2014 Nagios Plugin Development Team
+*
+* Description:
+*
+* This file contains the check_uptime plugin
+*
+*
+* 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
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*
+*********************************************************************************/
+
+#include "common.h"
+#include "utils.h"
+#include "utils_base.h"
+#include <time.h>
+
+char *progname = "check_uptime";
+char *version = "1.0";
+char *email = "devel@nagios-plugins.org";
+char *copyright = "2014";
+char *developer = "Andy Brist";
+
+static int process_arguments (int, char **);
+void print_help (void);
+void print_usage (void);
+int verbose = 0;
+
+char *warning, *critical, *timeunit;
+thresholds *my_thresholds = NULL;
+
+int main (int argc, char **argv) {
+
+	// base values
+	int status, intvalue;
+	int upminutes, uphours, updays;
+	double value, uptime;
+	char* perf;
+	char* output_message;
+
+	/* Parse extra opts if any */
+	argv = np_extra_opts (&argc, argv, progname);
+
+	if (process_arguments (argc, argv) == ERROR)
+		usage4 (_("Could not parse arguments"));
+
+	/* Set signal handling and alarm timeout */
+	if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) {
+		die (STATE_UNKNOWN, _("Cannot catch SIGALRM"));
+	}
+	
+	alarm (timeout_interval);
+	
+	value = getuptime();
+	
+	if (verbose >= 3) {
+		printf("Uptime in seconds returned from timespec struct: %f\n", value);
+	}
+	intvalue = (int)value;
+	
+	updays = intvalue / 86400;
+	uphours = (intvalue % 86400) / 3600;
+	upminutes = ((intvalue % 86400) % 3600) / 60;
+
+	if (!strncmp(timeunit, "minutes", strlen("minutes"))) {
+		uptime = intvalue / 60;
+	} else if (!strncmp(timeunit, "hours", strlen("hours"))) {
+		uptime = intvalue / 3600;
+	} else if (!strncmp(timeunit, "days", strlen("days"))) {
+		uptime = intvalue / 86400;
+	} else {
+		uptime = intvalue;
+	}	
+	
+	xasprintf(&output_message,_("%u day(s) %u hour(s) %u minute(s)"), updays, uphours, upminutes);
+	
+	xasprintf(&perf,_("%s"), 
+	 fperfdata("uptime", uptime, "",
+	 my_thresholds->warning?TRUE:FALSE, my_thresholds->warning?my_thresholds->warning->end:0,
+	 my_thresholds->critical?TRUE:FALSE, my_thresholds->critical?my_thresholds->critical->end:0,
+	 FALSE, 0,
+	 FALSE, 0)
+	);
+	
+	status = get_status(uptime, my_thresholds);
+	
+	if (status == STATE_OK) {
+		printf("Uptime %s: %s | %s\n", _("OK"), output_message, perf);
+	} else if (status == STATE_WARNING) {
+		printf("Uptime %s: %s | %s\n", _("WARNING"), output_message, perf);
+	} else if (status == STATE_CRITICAL) {
+		printf("Uptime %s: %s | %s\n", _("CRITICAL"), output_message, perf);
+	}
+
+	return status;
+
+} // end main
+
+int getuptime () {
+
+	struct timespec t;
+	clock_gettime(CLOCK_MONOTONIC, &t);
+	if (t.tv_sec > 0) {
+		return t.tv_sec;
+	} else {
+		printf("Uptime UNKNOWN: Timespec struct failed to retrieve uptime\n");
+		exit (STATE_UNKNOWN); 
+	}
+
+} // end getuptime
+
+static int process_arguments (int argc, char **argv) {
+
+	int c;
+        int escape = 0;
+        char *temp;
+	
+        int option = 0;
+        static struct option longopts[] = {
+                {"critical", required_argument, 0, 'c'},
+                {"warning", required_argument, 0, 'w'},
+    		{"timeout", required_argument, 0, 't'},
+                {"timeunit", required_argument, 0, 'u'},
+                {"verbose", no_argument, 0, 'v'},
+                {"version", no_argument, 0, 'V'},
+                {"help", no_argument, 0, 'h'},
+                {0, 0, 0, 0}
+        };
+
+	while ( 1 ) {
+
+		c = getopt_long ( argc, argv, "+hvVu:c:w:t:", longopts, &option );
+
+		if ( c == -1 || c == EOF || c == 1 ) break;
+	
+		switch ( c ) {
+			case '?':
+				usage5 ();
+			case 'h':
+				print_help ();
+				exit ( STATE_OK );
+			case 'v':
+				verbose++;
+				if (verbose >= 3) {
+					printf("Verbose mode enabled\n");
+				}
+				break;
+    			case 'V':
+      				print_revision (progname, NP_VERSION);
+      				exit (STATE_OK);
+			case 'u':
+				timeunit = optarg;
+				break;
+			case 'c':
+				critical = optarg;
+				break;
+			case 'w':
+				warning = optarg;
+				break;
+			case 't': /* timeout period */
+				if (!is_intpos (optarg))
+					usage2 (_("Timeout interval must be a positive integer"), optarg);
+				else
+					timeout_interval = atoi (optarg);
+				break;
+			} // end case
+		} // end while
+
+	c = optind;
+	set_thresholds(&my_thresholds, warning, critical);
+	return validate_arguments ();
+
+} // end process_arguments
+
+int validate_arguments (void) {
+
+	if (timeunit == NULL) {
+		timeunit = "minutes";
+		if (verbose >= 3) {
+			printf("No unit of time measurement specified. Using default: \"minutes\"\n");
+		}
+	} else if (strncmp(timeunit, "seconds", strlen("seconds") + 1 ) && 
+		strncmp(timeunit, "minutes", strlen("minutes") + 1) && 
+		strncmp(timeunit, "hours", strlen("hours") + 1) && 
+		strncmp(timeunit, "days", strlen("days") + 1)) {
+		
+		if (verbose >= 3) {
+			printf("Invalid unit of time measurement specified: \"%s\"\n", timeunit);
+		}
+		usage4(_("Wrong -u argument, expected: seconds, minutes, hours, or days"));
+	} else if (verbose >= 3) {
+		printf("Specified unit of time measurement accepted: \"%s\"\n", timeunit);
+	}
+	return OK;
+
+} //end validate
+
+void print_usage (void) {
+	
+	printf( "%s\n", _("Usage:") );
+	printf( "%s", _("check_uptime ") );
+	printf( "%s\n", _("[-u uom] [-w threshold] [-c threshold] [-t] [-h] [-vvv] [-V]") );
+
+} // end usage
+
+void print_help (void) {
+
+	print_revision ( progname, NP_VERSION );
+
+	printf ( COPYRIGHT, copyright, developer, email );
+	printf ( "%s\n", _("This plugin checks the system uptime and alerts if less than the threshold.") );
+	printf ( "%s\n", _("Threshold unit of measurement specified with \"-u\".") );
+	printf ( "%s\n", _("\"-u\" switch supports: seconds|minutes|hours|days.") );
+
+	print_usage ();
+	printf ( UT_HELP_VRSN );
+	printf ( UT_EXTRA_OPTS );
+
+        printf ( "%s\n", _("-t, Plugin timeout, default 10 seconds") );
+        printf ( "%s\n", _("-c, Critcal threshold") );
+	printf ( "%s\n", _("-w, Warning threshold") );
+	printf ( "%s\n", _("-u, Time unit of measurement (seconds|minutes|hours|days) (default: minutes)") );
+        printf ( "%s\n", _("-vvv, Enable verbose output") );
+        //printf ( "%s\n", _("-h, Print help and usage") );
+
+       printf ( UT_SUPPORT );
+
+} // end print_help

+ 41 - 3
plugins/check_users.c

@@ -37,7 +37,12 @@ const char *email = "devel@nagios-plugins.org";
 #include "common.h"
 #include "utils.h"
 
-#if HAVE_UTMPX_H
+#if HAVE_WTSAPI32_H
+# include <windows.h>
+# include <wtsapi32.h>
+# undef ERROR
+# define ERROR -1
+#elif HAVE_UTMPX_H
 # include <utmpx.h>
 #else
 # include "popen.h"
@@ -58,7 +63,11 @@ main (int argc, char **argv)
 	int users = -1;
 	int result = STATE_UNKNOWN;
 	char *perf;
-#if HAVE_UTMPX_H
+#if HAVE_WTSAPI32_H
+	WTS_SESSION_INFO *wtsinfo;
+	DWORD wtscount;
+	DWORD index;
+#elif HAVE_UTMPX_H
 	struct utmpx *putmpx;
 #else
 	char input_buffer[MAX_INPUT_BUFFER];
@@ -78,7 +87,36 @@ main (int argc, char **argv)
 
 	users = 0;
 
-#if HAVE_UTMPX_H
+#if HAVE_WTSAPI32_H
+	if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
+	  0, 1, &wtsinfo, &wtscount)) {
+		printf(_("Could not enumerate RD sessions: %d\n"), GetLastError());
+		return STATE_UNKNOWN;
+	}
+
+	for (index = 0; index < wtscount; index++) {
+		LPTSTR username;
+		DWORD size;
+		int len;
+
+		if (!WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,
+		  wtsinfo[index].SessionId, WTSUserName, &username, &size))
+			continue;
+
+		len = lstrlen(username);
+
+		WTSFreeMemory(username);
+
+		if (len == 0)
+			continue;
+
+		if (wtsinfo[index].State == WTSActive ||
+		  wtsinfo[index].State == WTSDisconnected)
+			users++;
+	}
+
+	WTSFreeMemory(wtsinfo);
+#elif HAVE_UTMPX_H
 	/* get currently logged users from utmpx */
 	setutxent ();
 

+ 12 - 3
plugins/netutils.c

@@ -167,11 +167,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
 	char port_str[6], host[MAX_HOST_ADDRESS_LENGTH];
 	size_t len;
 	int socktype, result;
+	short is_socket = (host_name[0] == '/');
 
 	socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
 
 	/* as long as it doesn't start with a '/', it's assumed a host or ip */
-	if(host_name[0] != '/'){
+	if (!is_socket){
 		memset (&hints, 0, sizeof (hints));
 		hints.ai_family = address_family;
 		hints.ai_protocol = proto;
@@ -253,7 +254,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
 			return econn_refuse_state;
 			break;
 		case STATE_CRITICAL: /* user did not set econn_refuse_state */
-			printf ("%s\n", strerror(errno));
+			if (is_socket)
+				printf("connect to file socket %s: %s\n", host_name, strerror(errno));
+			else
+				printf("connect to address %s and port %d: %s\n",
+				       host_name, port, strerror(errno));
 			return econn_refuse_state;
 			break;
 		default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
@@ -262,7 +267,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
 		}
 	}
 	else {
-		printf ("%s\n", strerror(errno));
+		if (is_socket)
+			printf("connect to file socket %s: %s\n", host_name, strerror(errno));
+		else
+			printf("connect to address %s and port %d: %s\n",
+			       host_name, port, strerror(errno));
 		return STATE_CRITICAL;
 	}
 }

+ 9 - 2
plugins/t/check_snmp.t

@@ -10,7 +10,7 @@ use NPTest;
 
 BEGIN {
     plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp";
-    plan tests => 60;
+    plan tests => 61;
 }
 
 my $res;
@@ -26,6 +26,7 @@ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRES
 
 my $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
                                            "An invalid (not known to DNS) hostname" );
+my $user_snmp = getTestParameter( "user_snmp",    "NP_SNMP_USER",    "auth_md5", "An SNMP user");
 
 $res = NPTest->testCmd( "./check_snmp -t 1" );
 is( $res->return_code, 3, "No host name" );
@@ -35,7 +36,7 @@ $res = NPTest->testCmd( "./check_snmp -H fakehostname" );
 is( $res->return_code, 3, "No OIDs specified" );
 is( $res->output, "No OIDs specified" );
 
-$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 --seclevel=rubbish" );
+$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 -U not_a_user --seclevel=rubbish" );
 is( $res->return_code, 3, "Invalid seclevel" );
 like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" );
 
@@ -154,6 +155,12 @@ SKIP: {
     like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed");
 }
 
+SKIP: {
+    skip "no SNMP user defined", 1 if ( ! $user_snmp );
+    $res = NPTest->testCmd( "./check_snmp -H $host_snmp -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv");
+    like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" );
+}
+
 # These checks need a complete command line. An invalid community is used so
 # the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway
 SKIP: {

+ 2 - 2
plugins/utils.c

@@ -631,7 +631,7 @@ char *fperfdata (const char *label,
 	return data;
 }
 
-// set entire string to lower, no need to return as it works on string in place
+/* 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;
@@ -641,7 +641,7 @@ void strntolower (char * test_char, int size) {
 
 }
 
-// set entire string to lower, no need to return as it works on string in place
+/* 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;