New upstream version 2.2

This commit is contained in:
Jan Wagner 2016-11-30 12:36:55 +01:00
parent ea115afa68
commit c845af032a
101 changed files with 4649 additions and 22969 deletions

View file

@ -21,3 +21,4 @@ Ton Voon
Jan Wagner
Holger Weiss
Michael Wirtgen
Oliver Skibbe

19887
ChangeLog

File diff suppressed because it is too large Load diff

10
LEGAL
View file

@ -1,10 +0,0 @@
All source code, binaries, documentation, and information contained
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).

View file

@ -3,7 +3,7 @@
SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
EXTRA_DIST = config.rpath \
ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ LEGAL NEWS \
ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ NEWS \
NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
NPTest.pm pkg \
config_test/Makefile config_test/run_tests config_test/child_test.c \

View file

@ -136,6 +136,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strcasestr.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
$(top_srcdir)/gl/m4/string_h.m4 \
$(top_srcdir)/gl/m4/strings_h.m4 \
@ -1038,6 +1039,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_APTGET = @PATH_TO_APTGET@
PATH_TO_DIG = @PATH_TO_DIG@
PATH_TO_ENV = @PATH_TO_ENV@
PATH_TO_FPING = @PATH_TO_FPING@
PATH_TO_FPING6 = @PATH_TO_FPING6@
PATH_TO_LMSTAT = @PATH_TO_LMSTAT@
@ -1055,6 +1057,7 @@ PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@
PATH_TO_SNMPGET = @PATH_TO_SNMPGET@
PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@
PATH_TO_SSH = @PATH_TO_SSH@
PATH_TO_SUDO = @PATH_TO_SUDO@
PATH_TO_SWAP = @PATH_TO_SWAP@
PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
PATH_TO_UPTIME = @PATH_TO_UPTIME@
@ -1353,7 +1356,7 @@ top_srcdir = @top_srcdir@
with_trusted_path = @with_trusted_path@
SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
EXTRA_DIST = config.rpath \
ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ LEGAL NEWS \
ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ NEWS \
NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
NPTest.pm pkg \
config_test/Makefile config_test/run_tests config_test/child_test.c \

175
NEWS
View file

@ -1,5 +1,47 @@
This file documents the major additions and syntax changes between releases.
2.2 29th November 2016
ENHANCEMENTS
The check_http -S/--ssl option now accepts the arguments "1.1" and "1.2"
to force TLSv1.1 and TLSv1.2 connections, respectively
The check_http -S/--ssl option now allows for specifying the desired
protocol with a "+" suffix to also accept newer versions
Let check_http check HTTPS web sites via proxies
check_http: add timeout to performance data as max value
check_http: report certificate expiry date in UTC
check_snmp: add IPv6 support
check_snmp's performance data now also includes warning/critical
thresholds
New check_snmp -N option to specify SNMPv3 context name
Let check_smtp's -D option imply -S
Let check_smtp's -e option match against the full SMTP response
check_dig: expected response is now case-insensitive
New check_mailq -s option which tells the plugin to use sudo(8)
New check_nt -l parameters: seconds|minutes|hours|days
New -W/-C option for check_ldap to check number of entries
check_users: add support for range thresholds
check_fping now auto-detects IPv6 addresses
check_radius now supports the radcli library
Support OpenSSL 1.1
FIXES
check_http: fix host header port handling
Let check_real terminate lines with CRLF when talking to the server, as
mandated by RFC 2326
Fix check_procs on HP-UX
check_smtp's -e/--expect option can now be combined with -S/--starttls
Fix incorrect performance data thresholds emitted by check_ups
Don't let check_procs miss some processes on busy Solaris systems
WARNINGS
The format of the performance data emitted by check_mrtgtraf has been
changed to comply with the development guidelines
check_ssh now returns CRITICAL for protocol/version errors
If a plugin is invoked with -h/--help or -V/--version, the exit status
is now UNKNOWN
The superseeded check_ntp.pl was removed, please use check_ntp_peer or
check_ntp_time instead
2.1.2 16th October 2015
FIXES
Fix incorrect performance data thresholds emitted by check_ups
@ -13,11 +55,10 @@ This file documents the major additions and syntax changes between releases.
Fix check_apt's handling of invalid regular expressions
Fix check_real's server response processing
Fix backslash escaping in check_tcp's --help output
Fix check_procs's unclosed filehandle in pst3 on Solaris
2.1 15th October 2014
ENHANCEMENTS
New check_hpjd -p option for port specification (abrist)
New check_hpjd -p option for port specification
New ./configure --with-qmail-qstat-command option to specify the path to
qmail-qstat(8)
New check_ifstatus -n option to ignore interfaces by name
@ -65,7 +106,7 @@ This file documents the major additions and syntax changes between releases.
Don't have check_http's -N option expect an argument
check_ide_smart could disable offline auto tests but could not re-enable them.
For this reason all SMART command modes have been disabled.
check_dig: fix wrong IPv6 arguments order (Stéphane Bortzmeyer)
check_dig: fix wrong IPv6 arguments order
check_dig: make sure not to give up too early when a timeout is specified with -t
check_log: don't stumble over log lines that include a "%" character
check_nt: add UPTIME to perfdata
@ -99,15 +140,15 @@ This file documents the major additions and syntax changes between releases.
Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page)
Add performance data to check_apt
Add performance data to check_procs
Added -4/-6 options to check_dig (Ville Mattila)
Added -4/-6 options to check_dig
New check_oracle --connect option to perform real login
New check_nagios -t option to override the default timeout
New check_disk -f/--freespace-ignore-reserved option to ignore space reserved for root
New check_disk -N/--include-type option to limit the filesystem types to check
Allow for building the plugins in parallel
Add --without-{dbi,ldap,radius} options to ./configure
Made Verbose output of check_sensors compliant (Gabriele Tozzi)
New switch -E/--extended-perfdata for check_http to print additional performance data (Sebastian Nohn)
Made Verbose output of check_sensors compliant
New switch -E/--extended-perfdata for check_http to print additional performance data
New check_http -d option to specify a string to expect within the response headers
New check_http -J/-K options for client certificate authentication support
Add support for executing queries to check_pgsql
@ -130,11 +171,11 @@ This file documents the major additions and syntax changes between releases.
Change the MAIL FROM command generated by check_smtp to be RFC compliant
Fix compilation of check_http without SSL support
Fix check_snmp reversed threshold ranges (backward-compatibility)
Fix check_snmp memory violation when using more than 8 oids (Robin Sonefors)
Fix check_apt security regular expression (Alex Bradley)
Fix check_http handling extra header (-k) containing semicolons (Richard Leitner)
Fix check_apt handling unknown exit codes from apt-get (Richard Leitner)
Fix deprecated imports of check_nmap.py (Fabio Rueda)
Fix check_snmp memory violation when using more than 8 oids
Fix check_apt security regular expression
Fix check_http handling extra header (-k) containing semicolons
Fix check_apt handling unknown exit codes from apt-get
Fix deprecated imports of check_nmap.py
WARNINGS
check_http behaviour of -k/--header changed since it does not seperate multiple headers by semicolons anymore. Use multiple -k switches instead.
@ -143,34 +184,34 @@ This file documents the major additions and syntax changes between releases.
1.4.16 27th June 2012
ENHANCEMENTS
check_nt UPTIME accepts warning/critical thresholds (Ryan Kelly)
check_nt UPTIME accepts warning/critical thresholds
check_disk_smb now allows spaces in share names (#990948, #1370031, Debian #601699)
check_http now uses standard threshold functions (enables floating point and ranges)
check_http now checks for and prints the certificate cn (hostname) in SSL certificate checks (Stéphane Urbanovski)
check_http now supports an optional -S/--ssl value to choose the SSL protocol version (#3066166 - Jason Lunn)
Add perfdata to check_ssh (#3244097 - Marco Beck)
New option to check_smtp to ignore failures when sending QUIT (#3358348 - Duncan Ferguson)
New check_by_ssh -F option which allows for specifying an alternative ssh_config(5) file (#2895334 - Sven Nierlein)
check_sensors now detects faulty sensors unless --ignore-fault is specified (Jan Wagner)
utils.sh now provides a check_range function (Alex Griffin)
Improved the performance of check_users (Marc Remy)
Add perfdata to check_disk_smb (Debian #654259 - Charles-Henri Larose)
check_http now checks for and prints the certificate cn (hostname) in SSL certificate checks
check_http now supports an optional -S/--ssl value to choose the SSL protocol version (#3066166)
Add perfdata to check_ssh (#3244097)
New option to check_smtp to ignore failures when sending QUIT (#3358348)
New check_by_ssh -F option which allows for specifying an alternative ssh_config(5) file (#2895334)
check_sensors now detects faulty sensors unless --ignore-fault is specified
utils.sh now provides a check_range function
Improved the performance of check_users
Add perfdata to check_disk_smb (Debian #654259)
Updated Nagios::Plugin perl module
Add warning threshold to certificate expiration checks of check_tcp/http/smtp (William Leibzon)
Add --perf-oids option for check_snmp (Jochen Bern)
Add warning threshold to certificate expiration checks of check_tcp/http/smtp
Add --perf-oids option for check_snmp
FIXES
Fix check_disk free space calculation if blocksizes differ within a disk group (Bekar - #2973603)
Fix check_disk free space calculation if blocksizes differ within a disk group (#2973603)
check_disk_smb now handles NT_STATUS_ACCESS_DENIED properly (Debian #601696)
Make check_snmp work more like v1.4.14 with regard to using special values (Timeticks, STRING) as numeric thresholds
Fix check_ldap overriding the port when --ssl was specified after -p
Fix check_procs where regex input of '|' would get displayed in output - now replaced with ','
Fix segfault in check_host when hostname returns multiple IP addresses (Sebastian Harl)
Fix segfault in check_host when hostname returns multiple IP addresses
Fix check_smtp and check_tcp where duplicate messages were displayed for certificate errors
Fix check_ping's parsing of ping6(1) output (#1894850, Debian #514588, Debian #662638 - Matej Vela)
Fix check_ping's parsing of ping6(1) output (#1894850, Debian #514588, Debian #662638)
Fix a check_dhcp bug which was triggered by checking Windows 2003 DHCP servers (#3503921)
Disable RFC4507 support, to work around SSL negotiation issues with (at least) some Tomcat versions
Fix performance data label containing spaces in check_snmp (Jochen Bern)
Fix performance data label containing spaces in check_snmp
1.4.15 27th July 2010
ENHANCEMENTS
@ -180,30 +221,30 @@ This file documents the major additions and syntax changes between releases.
New check_snmp --rate option to store differences between invocations. Saves state in PREFIX/var/{plugin}
check_snmp -l label option now also changes the perfdata label. See WARNINGS
check_snmp has an --invert-search option which reverses status of the string and regexp searches
check_http now displays the missing search string and the URL in the output when failed (Duncan Ferguson - #2999924)
check_http now displays the missing search string and the URL in the output when failed (#2999924)
Updated Nagios::Plugin perl module
Updated gnulib to June 2010
FIXES
Fix check_ircd binding to wrong interface (#668778)
Add proxy-authorization option to check_http (Marcel Kuiper - #1323230, Bryan Irvine - #2863925)
Add proxy-authorization option to check_http (#1323230, #2863925)
check_icmp now increment the sequence counter in each packet
Fix usage of repeated -o options in check_snmp
Try to detect arguments passed via --with-ping[6]-command and set options accordingly (#2908236)
Fix memory leak in check_http for large pages (Jimmy Bergman - #2957455)
Fix compilation with GCC 2.96 (Konstantin Khomoutov - #2977105)
Fix memory leak in check_http for large pages (#2957455)
Fix compilation with GCC 2.96 (#2977105)
Fix regression introduced in #1867716 where partially valid performance strings would not be printed anymore
Fix regression in check_http ssl checks on some servers - make SNI an option
Fix guest mode support in check_disk_smb
Fix check_disk_smb and check_ircd failures when run via ePN
check_ldap now allows for specifying an empty LDAP base
Fix compilation error of pst3 in Solaris 8
Fix check_radius returning OK on unexpected results (Craig Leres - #2911752)
Fix translations when extra-opts aren't enabled (Jan Wagner - #2832884)
Fix check_radius returning OK on unexpected results (#2911752)
Fix translations when extra-opts aren't enabled (#2832884)
Fix parsing of multi-line strings in check_snmp (broken in 1.4.14) and enhance output in such case (#2832451)
Fix detection of pst3 64-bit compile flags with Sun CC
Fix cmd_run overwriting the environment, which would break some commands that needed it
Allow check_ifstatus to accept version=2c - used to only allow version=2 (Brian Landers)
Allow check_ifstatus to accept version=2c - used to only allow version=2
Fix examples in check_disk, where it implied was possible to suffix unit values to warn/crit parameters
WARNINGS
@ -216,71 +257,71 @@ This file documents the major additions and syntax changes between releases.
check_http has options to specify the HTTP method (#2155152)
check_users thresholds were not working exactly as documented (>= rather than >)
Updated tinderbox_build script to point to new tinderbox server
check_ifoperstatus -n flag now works as expected (sf.net #1569488)
check_ifoperstatus -n flag now works as expected (#1569488)
check_ifoperstatus now supports ifType based lookup for ifIndex
check_ups now sends a LOGOUT string (debian bug #387001)
check_ups now sends a LOGOUT string (Debian #387001)
Extra-opts (C plugins) now allows both '#' and ';' for comments (like N::P)
Extra-opts (C plugins) does not allow trailing comments anymore (like N::P)
Fixed dependency issue on libtap when ./configure --enable-libtap used. Warning: will install libtap
Fixed segfault in extra-opts under some circumstance when reading multiple sections
Fix long options parsing in check_disk, check_dns, check_mrtg, check_mrtgtraf and check_tcp
Add missing long options for check_nt (for use with extra-opts)
check_icmp now reports min and max round trip time perfdata (Steve Rader)
Fixed check_http bug where additional headers with redirection caused a segfault (Dieter Van de Walle - 2089159)
check_disk: make autofs mount paths specified with -p before we determine the mount list (Erik Welch)
check_icmp now reports min and max round trip time perfdata
Fixed check_http bug where additional headers with redirection caused a segfault (2089159)
check_disk: make autofs mount paths specified with -p before we determine the mount list
Fixed buffer overflow in check_ntp/check_ntp_peer (#1999319, Ubuntu #291265)
Re-bundled libtap as a built-in library (--enable-libtap): detects system library as pre-1.4.13 and does not install the built-in library anymore
Fixed check_mrtg returning UNKNOWN instead of OK (bug #2378068)
Fixed check_http behaviour: all check are now performed as long as a valid response is returned (sf.net #1460312)
check_http --onredirect=sticky follows using the same IP address (sf.net #2550208)
Fixed check_mrtg returning UNKNOWN instead of OK (#2378068)
Fixed check_http behaviour: all check are now performed as long as a valid response is returned (#1460312)
check_http --onredirect=sticky follows using the same IP address (#2550208)
check_http --onredirect=stickyport also follows the same port
Fixed coredump from check_nt when invalid drive is specified (#2179754 - Olli Hauer)
Fixed crash from check_nt when -H unspecified or given multiple times (sf.net #2731755, debian #521097)
Fixed passing of quotes in OID for check_snmp (#1985230 - Jan Wagner, patch by John Barbuto)
Fixed coredump from check_nt when invalid drive is specified (#2179754)
Fixed crash from check_nt when -H unspecified or given multiple times (#2731755, Debian #521097)
Fixed passing of quotes in OID for check_snmp (#1985230)
Fixed check_http sending HTTP/1.0 with v1.1 headers (#2638765)
Fixed check_http not timing-out on redirects
Fixed negate not printing the real timeout in ALRM handler when left to default
negate timeout result is now configurable
Fixed segfault in check_mysql with old slaves (#2696823 - Oskar Ahner)
Fixed segfault in check_mysql with old slaves (#2696823)
check_nt can return UNKNOWN on timeouts (-u)
Fixed typos for check_disk (Chris Pepper)
Fixed check_mysql* not using password set in my.cnf (#2531905 - Ben Timby) - Specify an empty password explicitly if you need to override it.
Fixed awk subst.in/subst script path error (#2722832 - Martin Foster)
check_http: Add SSL/TLS hostname extension support (SNI) - (#1939022 - Joe Presbrey)
Fixed wrong perfdata label for output traffic in check_mrtgtraf (#2654308 - Gavin Williams)
Fixed typos for check_disk
Fixed check_mysql* not using password set in my.cnf (#2531905) - Specify an empty password explicitly if you need to override it.
Fixed awk subst.in/subst script path error (#2722832)
check_http: Add SSL/TLS hostname extension support (SNI) - (#1939022)
Fixed wrong perfdata label for output traffic in check_mrtgtraf (#2654308)
Fixed check_by_ssh interpretation of quotes in -C parameter (#1985246, #2268675)
check_snmp now supports standard threshold ranges and doubles (floating numbers) in thresholds
check_fping now supports passing target timeout and interval to fping (#2347686 - Martin Foster)
Fixed SNMPv3 behaviour of check_ifoperstatus and check_ifstatus. Added -P to define privprotocol (#2343438 - Robin Schroeder)
check_fping now supports passing target timeout and interval to fping (#2347686)
Fixed SNMPv3 behaviour of check_ifoperstatus and check_ifstatus. Added -P to define privprotocol (#2343438)
check_ifoperstatus and check_ifstatus are now more user-friendly in case of missing arguments
pst3 compile fix for Sun Studio Compiler (Grant Byers)
pst3 compile fix for Sun Studio Compiler
1.4.13 25th Sept 2008
Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen)
Optimised pst3 for systems with large number of processes (Duncan Ferguson)
Fix Debian bug #460097: check_http --max-age broken
Optimised pst3 for systems with large number of processes
Updated Nagios::Plugin to 0.27
Fix Debian bug #479013: check_dig's -l is mandatory now (sf.net #1986306)
Fix Debian bug #479013: check_dig's -l is mandatory now (#1986306)
check_dig now returns CRITICAL instead of WARNING when no answer section is found
check_procs now captures stderr in external command and adds to plugin output
check_snmp now only prints perfdata for non numeric values (#1867716)
check_icmp now supports packet size modification
check_http -e now accepts a comma-delimited list of expected status codes (Sven Nierlein)
check_http -e now accepts a comma-delimited list of expected status codes
libtap now included with this distribution for easier testing. Run ./configure with --enable-libtap
check_ntp_peer/check_ntp_time used to show port in --help but ignored the argument - now implemented
Fix possible segfault in check_ntp_peer with deliberately invalid packets
1.4.12 27th May 2008
Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren)
Added ./check_nt -v INSTANCES to count number of instances
New check_icmp -s option to specify the source IP address
check_dns now sorts addresses for testing results for more than one returned IP (Matthias Urlichs)
Fix segfault in check_ntp_time and (deprecated) check_ntp (Bug #1862300)
check_dns now sorts addresses for testing results for more than one returned IP
Fix segfault in check_ntp_time and (deprecated) check_ntp (#1862300)
check_disk should now work with large file systems (2TB+) on all archs that supports it
Fixed check_disk disk usage calculation when using --group=NAME (related to bug #1348746)
Fix help text of check_ntp* (Bug #1880095)
Fixed check_disk disk usage calculation when using --group=NAME (related to #1348746)
Fix help text of check_ntp* (#1880095)
Fix bugs and flaws in best offset server selection of check_ntp_time and (deprecated) check_ntp
check_ntp_peer now checks for the LI_ALARM flag
Sync to latest Gnulib (includes new floorf function)
check_pgsql now successfully builds with postgres lib v8.3 (Bug #1878972)
check_pgsql now successfully builds with postgres lib v8.3 (#1878972)
check_procs now accepts --ereg-argument-array for a regular expression match to the argument array
Reverted back to using pst3 for Solaris systems. Fixed issues re: -m64 needed to compile on 64bit systems
If applicable, Gettext linked dynamically instead of statically
@ -290,7 +331,7 @@ This file documents the major additions and syntax changes between releases.
check_mysql and check_radius now try clearing password in processlist just like check_mysql_query
check_mysql and check_mysql_query now support sockets explicitely (-s, --socket)
negate now has the ability to replace the status text as well (-s, --substitute)
Added performance data to check_ping (Christian Schneemann)
Added performance data to check_ping
Added support for --extra-opts in all C plugins (disabled by default, see configure --help)
Fixed passive option in check_by_ssh
On non-skipped stderr, check_by_ssh now returns UNKNOWN or worse (result from command) instead of always UNKNOWN.
@ -309,9 +350,9 @@ This file documents the major additions and syntax changes between releases.
is "-1" as the default range starts at 0. See Examples in --help output.
Fixed broken usage2 in check_snmp and check_cluster
check_cluster now accepts all valid characters in its thresholds ("-", "@", "~")
Fixed check_disk reporting OK if disk usage grows over 100% (bug #1348746).
Fixed check_disk reporting OK if disk usage grows over 100% (#1348746).
The problem happens to be in Gnulib but a workaround have been implemented in check_disk.c
Fixed check_load argument handling when not passing triplets (bug #1831890)
Fixed check_load argument handling when not passing triplets (#1831890)
Fixed buffer overflow in check_snmp (CVE-2007-5623)
Tinderbox builds now runs tests in a verbose mode
Updated Nagios::Plugin to 0.22

View file

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

View file

@ -50,16 +50,18 @@ check_dbi:
http://libdbi.sourceforge.net/
check_radius:
- Requires the FreeRADIUS Client library available from:
- Requires the radcli library available from:
http://radcli.github.io/radcli/
- As an alternative, the FreeRADIUS Client library may be used:
http://freeradius.org/freeradius-client/
- As an alternative, the radiusclient-ng library may be used:
- As another alternative, the radiusclient-ng library may be used:
http://sourceforge.net/projects/radiusclient-ng.berlios/
- This plugin also works with the original radiusclient library from
ftp://ftp.cityline.net/pub/radiusclient/
RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2
However, you probably want to use the FreeRADIUS Client library, as
both radiusclient and radiusclient-ng are unmaintained and have known
issues.
However, you probably want to use either radcli or the FreeRADIUS
Client library, as both radiusclient and radiusclient-ng are
unmaintained and have known issues.
check_snmp:
- Requires the NET-SNMP package available from

24
THANKS
View file

@ -2,10 +2,11 @@ This software is brought to you by the Monitoring Plugins Development Team. Howe
there have been many contributors to this project. Everyone below has helped in
raising bug reports, creating patches or contributing new plugins.
Jérémie Courrèges-Anglas
Diego Elio Pettenò
fabiodds
Elan Ruusamäe
dag rob?le
Matthias Hähnel
Randy O'Meara
Oskar Ahner
Lance Albertson
@ -16,6 +17,7 @@ Patrick Allen
Felipe Gustavo de Almeida
Michael Almond
Michael Anthon
Bernd Apfel
Paula Arnold
Kondoros Attila
Daniel Austin
@ -35,6 +37,7 @@ Jason Benguerel
Allan Bennett
Booker C. Bense
Guy Van Den Bergh
Andrew Berglund
Jimmy Bergman
Jochen Bern
Tom Bertelston
@ -61,6 +64,7 @@ Jim Carroll
Ian Cass
Arnold Cavazos
Alex Chaffee
Yannick Charton
Stephane Chazelas
Eric Chen
Alwyn Cherrington
@ -71,6 +75,7 @@ Garry Cook
Charlie Cook
Ollie Cook
Luca Corti
Greg Cox
Jason Crawford
David Croft
Robert Dale
@ -88,6 +93,7 @@ Edwin Eefting
Jason Ellison
Andrew Elwell
Mike Emigh
Johannes Engel
Hans Engelen
Matthew Ericson
Andreas Ericsson
@ -113,7 +119,9 @@ Martin Foster
Felix Frank
Dann Frazier
Rick Frey
John C. Frickson
Matt Garrett
Sven Geggus
Jonas Genannt
Robby Giffin
Flo Gleixner
@ -123,6 +131,7 @@ Joseph Gooch
Aravind Gottipati
Kev Green
Steve Greenland
Roberto Greiner
Olaf Greis
Alex Griffin
Chris Grim
@ -158,6 +167,7 @@ Jason Kau
Mark Keisler
Ryan Kelly
Matthew Kent
Matthieu Kermagoret
Bo Kersey
Konstantin Khomoutov
Serhan Kiymaz
@ -169,8 +179,10 @@ Julius Kriukas
Christoph Kron
Frederic Krueger
Marcel Kuiper
Christian Kujau
Alexander Kulak
Bill Kunkel
Thomas Kurschel
Brian Landers
Stephane Lapie
Pascal Larisch
@ -183,6 +195,7 @@ William Leibzon
Pedro Leite
Richard Leitner
Craig Leres
Laurent Licour
Oskar Liljeblad
Joerg Linge
Jan Lipphaus
@ -208,6 +221,7 @@ Patrick McCormick
Mike McHenry
Simon Meggle
Stefan Meier
Michael Melcher
Jan-Piet Mens
Sven Meyer
Emil Michles
@ -217,6 +231,7 @@ Russell Miller
Eric J. Mislivec
Janos Mohacsi
Gerd Mueller
Adrian Murphy
Michael Musikhin
Damian Myerscough
Jan-Frode Myklebust
@ -227,6 +242,7 @@ Thomas Nilsen
Sebastian Nohn
Geoff Oakham
Walbert Oberngruber
Christopher Odenbach
Craig Orsinger
Vaclav Ovsik
Remi Paulmier
@ -247,6 +263,7 @@ Joe Presbrey
Will Preston
Arnaud Quette
Darian Rackham
Peter Radcliffe
Steve Rader
Olivier 'Babar' Raginel
Phil Randal
@ -270,7 +287,6 @@ Sascha Runschke
Dietmar Ruzicka
Ralph Rye
Alen Salamun
Louis Sautier
Sven Schaffranneck
Christoph Schell
Thomas Schimpke
@ -281,8 +297,10 @@ Christian Schneemann
Cove Schneider
Enrico Scholz
Sebastian Schubert
Christopher Schultz
Russell Scibetti
Noel Sebastien
Andreas Seemueller
Lonny Selinger
Nathan Shafer
Tom Shields
@ -290,11 +308,11 @@ Sean Shore
Pall Sigurdsson
Antony Simmonds
John Sivak
Oliver Skibbe
Nik Soggia
Robin Sonefors
Erwan Ben Souiden
Lars Stavholm
Daniel Stirnimann
Nikolay Sturm
David Sullivan
Kjell Sundtjonn

1
aclocal.m4 vendored
View file

@ -1146,6 +1146,7 @@ m4_include([gl/m4/stdint_h.m4])
m4_include([gl/m4/stdio_h.m4])
m4_include([gl/m4/stdlib_h.m4])
m4_include([gl/m4/strcase.m4])
m4_include([gl/m4/strcasestr.m4])
m4_include([gl/m4/strerror.m4])
m4_include([gl/m4/string_h.m4])
m4_include([gl/m4/strings_h.m4])

View file

@ -137,6 +137,9 @@
/* Define to 1 when the gnulib module snprintf should be tested. */
#undef GNULIB_TEST_SNPRINTF
/* Define to 1 when the gnulib module strcasestr should be tested. */
#undef GNULIB_TEST_STRCASESTR
/* Define to 1 when the gnulib module strerror should be tested. */
#undef GNULIB_TEST_STRERROR
@ -483,6 +486,9 @@
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the `radcli' library (-lradcli). */
#undef HAVE_LIBRADCLI
/* Define to 1 if you have the `radiusclient' library (-lradiusclient). */
#undef HAVE_LIBRADIUSCLIENT
@ -1478,6 +1484,9 @@
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define to 1 if you have the `strcasestr' function. */
#undef HAVE_STRCASESTR
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
@ -1880,6 +1889,9 @@
/* path to snmpgetnext binary */
#undef PATH_TO_SNMPGETNEXT
/* path to sudo */
#undef PATH_TO_SUDO
/* path to uptime binary */
#undef PATH_TO_UPTIME

578
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for monitoring-plugins 2.1.2.
# Generated by GNU Autoconf 2.69 for monitoring-plugins 2.2.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@ -587,8 +587,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='monitoring-plugins'
PACKAGE_TARNAME='monitoring-plugins'
PACKAGE_VERSION='2.1.2'
PACKAGE_STRING='monitoring-plugins 2.1.2'
PACKAGE_VERSION='2.2'
PACKAGE_STRING='monitoring-plugins 2.2'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@ -1618,6 +1618,7 @@ PATH_TO_SWAPINFO
PATH_TO_SWAP
PATH_TO_QMAIL_QSTAT
PATH_TO_MAILQ
PATH_TO_SUDO
PATH_TO_SSH
PATH_TO_FPING6
PATH_TO_FPING
@ -1633,6 +1634,7 @@ PATH_TO_NSLOOKUP
PATH_TO_PING6
PATH_TO_PING
PST3CFLAGS
PATH_TO_ENV
PATH_TO_PS
SSLLIBS
check_tcp_ssl
@ -1837,6 +1839,7 @@ with_qstat_command
with_fping_command
with_fping6_command
with_ssh_command
with_sudo_command
with_mailq_command
with_qmail_qstat_command
with_proc_meminfo
@ -2400,7 +2403,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures monitoring-plugins 2.1.2 to adapt to many kinds of systems.
\`configure' configures monitoring-plugins 2.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -2471,7 +2474,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of monitoring-plugins 2.1.2:";;
short | recursive ) echo "Configuration of monitoring-plugins 2.2:";;
esac
cat <<\_ACEOF
@ -2544,6 +2547,7 @@ Optional Packages:
--with-fping-command=PATH Path to fping command
--with-fping6-command=PATH Path to fping6 command
--with-ssh-command=PATH sets path for ssh
--with-sudo-command=PATH sets path to sudo
--with-mailq-command=PATH sets path to mailq
--with-qmail-qstat-command=PATH sets path to qmail-qstat
--with-proc-meminfo=PATH path to /proc/meminfo or equivalent
@ -2637,7 +2641,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
monitoring-plugins configure 2.1.2
monitoring-plugins configure 2.2
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -3342,7 +3346,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by monitoring-plugins $as_me 2.1.2, which was
It was created by monitoring-plugins $as_me 2.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -4213,7 +4217,7 @@ fi
# Define the identity of the package.
PACKAGE='monitoring-plugins'
VERSION='2.1.2'
VERSION='2.2'
cat >>confdefs.h <<_ACEOF
@ -6581,6 +6585,8 @@ fi
# Code from module stdio:
# Code from module stdlib:
# Code from module strcase:
# Code from module strcasestr:
# Code from module strcasestr-simple:
# Code from module streq:
# Code from module strerror:
# Code from module strerror-override:
@ -14963,7 +14969,57 @@ fi
if test "x$with_radius" != "xno"; then :
_SAVEDLIBS="$LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lfreeradius-client" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradcli" >&5
$as_echo_n "checking for rc_read_config in -lradcli... " >&6; }
if ${ac_cv_lib_radcli_rc_read_config+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lradcli $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char rc_read_config ();
int
main ()
{
return rc_read_config ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_radcli_rc_read_config=yes
else
ac_cv_lib_radcli_rc_read_config=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_radcli_rc_read_config" >&5
$as_echo "$ac_cv_lib_radcli_rc_read_config" >&6; }
if test "x$ac_cv_lib_radcli_rc_read_config" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBRADCLI 1
_ACEOF
LIBS="-lradcli $LIBS"
fi
if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lradcli"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lfreeradius-client" >&5
$as_echo_n "checking for rc_read_config in -lfreeradius-client... " >&6; }
if ${ac_cv_lib_freeradius_client_rc_read_config+:} false; then :
$as_echo_n "(cached) " >&6
@ -15008,12 +15064,12 @@ _ACEOF
fi
if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lfreeradius-client"
if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lfreeradius-client"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient-ng" >&5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient-ng" >&5
$as_echo_n "checking for rc_read_config in -lradiusclient-ng... " >&6; }
if ${ac_cv_lib_radiusclient_ng_rc_read_config+:} false; then :
$as_echo_n "(cached) " >&6
@ -15058,12 +15114,12 @@ _ACEOF
fi
if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lradiusclient-ng"
if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lradiusclient-ng"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient" >&5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient" >&5
$as_echo_n "checking for rc_read_config in -lradiusclient... " >&6; }
if ${ac_cv_lib_radiusclient_rc_read_config+:} false; then :
$as_echo_n "(cached) " >&6
@ -15108,15 +15164,16 @@ _ACEOF
fi
if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lradiusclient"
if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lradiusclient"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Skipping radius plugin" >&5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Skipping radius plugin" >&5
$as_echo "$as_me: WARNING: Skipping radius plugin" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: install radius libs to compile this plugin (see REQUIREMENTS)." >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: install radius libs to compile this plugin (see REQUIREMENTS)." >&5
$as_echo "$as_me: WARNING: install radius libs to compile this plugin (see REQUIREMENTS)." >&2;}
fi
fi
fi
fi
@ -15775,9 +15832,9 @@ done
_SAVEDLIBS="$LIBS"
LIBS="-L${with_openssl}/lib"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CRYPTO_lock in -lcrypto" >&5
$as_echo_n "checking for CRYPTO_lock in -lcrypto... " >&6; }
if ${ac_cv_lib_crypto_CRYPTO_lock+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CRYPTO_new_ex_data in -lcrypto" >&5
$as_echo_n "checking for CRYPTO_new_ex_data in -lcrypto... " >&6; }
if ${ac_cv_lib_crypto_CRYPTO_new_ex_data+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@ -15791,27 +15848,27 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
char CRYPTO_lock ();
char CRYPTO_new_ex_data ();
int
main ()
{
return CRYPTO_lock ();
return CRYPTO_new_ex_data ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_crypto_CRYPTO_lock=yes
ac_cv_lib_crypto_CRYPTO_new_ex_data=yes
else
ac_cv_lib_crypto_CRYPTO_lock=no
ac_cv_lib_crypto_CRYPTO_new_ex_data=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_CRYPTO_lock" >&5
$as_echo "$ac_cv_lib_crypto_CRYPTO_lock" >&6; }
if test "x$ac_cv_lib_crypto_CRYPTO_lock" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_CRYPTO_new_ex_data" >&5
$as_echo "$ac_cv_lib_crypto_CRYPTO_new_ex_data" >&6; }
if test "x$ac_cv_lib_crypto_CRYPTO_new_ex_data" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCRYPTO 1
_ACEOF
@ -15820,7 +15877,7 @@ _ACEOF
fi
if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lssl" >&5
$as_echo_n "checking for main in -lssl... " >&6; }
if ${ac_cv_lib_ssl_main+:} false; then :
@ -15858,7 +15915,7 @@ fi
fi
LIBS="$_SAVEDLIBS"
if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
if test "$ac_cv_lib_ssl_main" = "yes"; then
if test "$FOUNDINCLUDE" = "yes"; then
FOUNDOPENSSL="yes"
@ -16433,6 +16490,46 @@ $as_echo "no" >&6; }
fi
# Extract the first word of "env", so it can be a program name with args.
set dummy env; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PATH_TO_ENV+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PATH_TO_ENV in
[\\/]* | ?:[\\/]*)
ac_cv_path_PATH_TO_ENV="$PATH_TO_ENV" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PATH_TO_ENV="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
PATH_TO_ENV=$ac_cv_path_PATH_TO_ENV
if test -n "$PATH_TO_ENV"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_TO_ENV" >&5
$as_echo "$PATH_TO_ENV" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ps syntax" >&5
$as_echo_n "checking for ps syntax... " >&6; }
@ -16822,6 +16919,16 @@ then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ps_command" >&5
$as_echo "$ac_cv_ps_command" >&6; }
elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \
egrep -i "^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND" >/dev/null
then
ac_cv_ps_varlist="procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos"
ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'"
ac_cv_ps_format="%s %d %d %d %d %f %s %n"
ac_cv_ps_cols=8
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ps_command" >&5
$as_echo "$ac_cv_ps_command" >&6; }
elif ps -el 2>/dev/null | \
egrep -i "^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+" >/dev/null
then
@ -18078,6 +18185,63 @@ else
$as_echo "$as_me: WARNING: Get ssh in order to make check_by_ssh plugin" >&2;}
fi
# Extract the first word of "sudo", so it can be a program name with args.
set dummy sudo; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PATH_TO_SUDO+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PATH_TO_SUDO in
[\\/]* | ?:[\\/]*)
ac_cv_path_PATH_TO_SUDO="$PATH_TO_SUDO" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PATH_TO_SUDO="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
PATH_TO_SUDO=$ac_cv_path_PATH_TO_SUDO
if test -n "$PATH_TO_SUDO"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_TO_SUDO" >&5
$as_echo "$PATH_TO_SUDO" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
# Check whether --with-sudo_command was given.
if test "${with_sudo_command+set}" = set; then :
withval=$with_sudo_command; PATH_TO_SUDO=$withval
fi
if test -n "$PATH_TO_SUDO"
then
cat >>confdefs.h <<_ACEOF
#define PATH_TO_SUDO "$PATH_TO_SUDO"
_ACEOF
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find sudo or eqivalent" >&5
$as_echo "$as_me: WARNING: Could not find sudo or eqivalent" >&2;}
fi
# Extract the first word of "mailq", so it can be a program name with args.
set dummy mailq; ac_word=$2
@ -28288,6 +28452,103 @@ fi
HAVE_DECL_STRNCASECMP=1;
for ac_func in strcasestr
do :
ac_fn_c_check_func "$LINENO" "strcasestr" "ac_cv_func_strcasestr"
if test "x$ac_cv_func_strcasestr" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRCASESTR 1
_ACEOF
fi
done
if test $ac_cv_func_strcasestr = no; then
HAVE_STRCASESTR=0
else
if test "$gl_cv_func_memchr_works" != yes; then
REPLACE_STRCASESTR=1
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strcasestr works" >&5
$as_echo_n "checking whether strcasestr works... " >&6; }
if ${gl_cv_func_strcasestr_works_always+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __GNU_LIBRARY__
#include <features.h>
#if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
|| defined __UCLIBC__
Lucky user
#endif
#elif defined __CYGWIN__
#include <cygwin/version.h>
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
Lucky user
#endif
#else
Lucky user
#endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "Lucky user" >/dev/null 2>&1; then :
gl_cv_func_strcasestr_works_always="guessing yes"
else
gl_cv_func_strcasestr_works_always="guessing no"
fi
rm -f conftest*
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <string.h> /* for strcasestr */
#define P "_EF_BF_BD"
#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
#define NEEDLE P P P P P
int
main ()
{
return !!strcasestr (HAYSTACK, NEEDLE);
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
gl_cv_func_strcasestr_works_always=yes
else
gl_cv_func_strcasestr_works_always=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strcasestr_works_always" >&5
$as_echo "$gl_cv_func_strcasestr_works_always" >&6; }
case "$gl_cv_func_strcasestr_works_always" in
*yes) ;;
*)
REPLACE_STRCASESTR=1
;;
esac
fi
fi
REPLACE_STRERROR_0=0
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror(0) succeeds" >&5
$as_echo_n "checking whether strerror(0) succeeds... " >&6; }
@ -37665,6 +37926,245 @@ _ACEOF
fi
if test $HAVE_STRCASESTR = 1 && test $REPLACE_STRCASESTR = 0; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strcasestr works in linear time" >&5
$as_echo_n "checking whether strcasestr works in linear time... " >&6; }
if ${gl_cv_func_strcasestr_linear+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <features.h>
#ifdef __GNU_LIBRARY__
#if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
&& !defined __UCLIBC__
Lucky user
#endif
#endif
#ifdef __CYGWIN__
#include <cygwin/version.h>
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
Lucky user
#endif
#endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "Lucky user" >/dev/null 2>&1; then :
gl_cv_func_strcasestr_linear="guessing yes"
else
gl_cv_func_strcasestr_linear="guessing no"
fi
rm -f conftest*
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <signal.h> /* for signal */
#include <string.h> /* for strcasestr */
#include <stdlib.h> /* for malloc */
#include <unistd.h> /* for alarm */
static void quit (int sig) { exit (sig + 128); }
int
main ()
{
int result = 0;
size_t m = 1000000;
char *haystack = (char *) malloc (2 * m + 2);
char *needle = (char *) malloc (m + 2);
/* Failure to compile this test due to missing alarm is okay,
since all such platforms (mingw) also lack strcasestr. */
signal (SIGALRM, quit);
alarm (5);
/* Check for quadratic performance. */
if (haystack && needle)
{
memset (haystack, 'A', 2 * m);
haystack[2 * m] = 'B';
haystack[2 * m + 1] = 0;
memset (needle, 'A', m);
needle[m] = 'B';
needle[m + 1] = 0;
if (!strcasestr (haystack, needle))
result |= 1;
}
return result;
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
gl_cv_func_strcasestr_linear=yes
else
gl_cv_func_strcasestr_linear=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strcasestr_linear" >&5
$as_echo "$gl_cv_func_strcasestr_linear" >&6; }
case "$gl_cv_func_strcasestr_linear" in
*yes) ;;
*)
REPLACE_STRCASESTR=1
;;
esac
fi
if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
gl_LIBOBJS="$gl_LIBOBJS strcasestr.$ac_objext"
:
fi
for ac_func in strcasestr
do :
ac_fn_c_check_func "$LINENO" "strcasestr" "ac_cv_func_strcasestr"
if test "x$ac_cv_func_strcasestr" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRCASESTR 1
_ACEOF
fi
done
if test $ac_cv_func_strcasestr = no; then
HAVE_STRCASESTR=0
else
if test "$gl_cv_func_memchr_works" != yes; then
REPLACE_STRCASESTR=1
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strcasestr works" >&5
$as_echo_n "checking whether strcasestr works... " >&6; }
if ${gl_cv_func_strcasestr_works_always+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __GNU_LIBRARY__
#include <features.h>
#if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
|| defined __UCLIBC__
Lucky user
#endif
#elif defined __CYGWIN__
#include <cygwin/version.h>
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
Lucky user
#endif
#else
Lucky user
#endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "Lucky user" >/dev/null 2>&1; then :
gl_cv_func_strcasestr_works_always="guessing yes"
else
gl_cv_func_strcasestr_works_always="guessing no"
fi
rm -f conftest*
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <string.h> /* for strcasestr */
#define P "_EF_BF_BD"
#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
#define NEEDLE P P P P P
int
main ()
{
return !!strcasestr (HAYSTACK, NEEDLE);
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
gl_cv_func_strcasestr_works_always=yes
else
gl_cv_func_strcasestr_works_always=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strcasestr_works_always" >&5
$as_echo "$gl_cv_func_strcasestr_works_always" >&6; }
case "$gl_cv_func_strcasestr_works_always" in
*yes) ;;
*)
REPLACE_STRCASESTR=1
;;
esac
fi
fi
if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
gl_LIBOBJS="$gl_LIBOBJS strcasestr.$ac_objext"
:
fi
GNULIB_STRCASESTR=1
$as_echo "#define GNULIB_TEST_STRCASESTR 1" >>confdefs.h
@ -40937,7 +41437,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by monitoring-plugins $as_me 2.1.2, which was
This file was extended by monitoring-plugins $as_me 2.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -41003,7 +41503,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
monitoring-plugins config.status 2.1.2
monitoring-plugins config.status 2.2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View file

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(monitoring-plugins,2.1.2)
AC_INIT(monitoring-plugins,2.2)
AC_CONFIG_SRCDIR(NPTest.pm)
AC_CONFIG_FILES([gl/Makefile])
AC_CONFIG_AUX_DIR(build-aux)
@ -273,26 +273,33 @@ AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plug
dnl Check for radius libraries
AS_IF([test "x$with_radius" != "xno"], [
_SAVEDLIBS="$LIBS"
AC_CHECK_LIB(freeradius-client,rc_read_config)
if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
AC_CHECK_LIB(radcli,rc_read_config)
if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lfreeradius-client"
RADIUSLIBS="-lradcli"
AC_SUBST(RADIUSLIBS)
else
AC_CHECK_LIB(radiusclient-ng,rc_read_config)
if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
AC_CHECK_LIB(freeradius-client,rc_read_config)
if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lradiusclient-ng"
RADIUSLIBS="-lfreeradius-client"
AC_SUBST(RADIUSLIBS)
else
AC_CHECK_LIB(radiusclient,rc_read_config)
if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
AC_CHECK_LIB(radiusclient-ng,rc_read_config)
if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lradiusclient"
RADIUSLIBS="-lradiusclient-ng"
AC_SUBST(RADIUSLIBS)
else
AC_MSG_WARN([Skipping radius plugin])
AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
AC_CHECK_LIB(radiusclient,rc_read_config)
if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
RADIUSLIBS="-lradiusclient"
AC_SUBST(RADIUSLIBS)
else
AC_MSG_WARN([Skipping radius plugin])
AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
fi
fi
fi
fi
@ -493,15 +500,15 @@ if ! test x"$with_openssl" = x"no"; then
dnl Check for crypto lib
_SAVEDLIBS="$LIBS"
LIBS="-L${with_openssl}/lib"
AC_CHECK_LIB(crypto,CRYPTO_lock)
if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
AC_CHECK_LIB(crypto,CRYPTO_new_ex_data)
if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
dnl Check for SSL lib
AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
fi
LIBS="$_SAVEDLIBS"
dnl test headers and libs to decide whether check_http should use SSL
if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
if test "$ac_cv_lib_ssl_main" = "yes"; then
if test "$FOUNDINCLUDE" = "yes"; then
FOUNDOPENSSL="yes"
@ -610,6 +617,7 @@ AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
dnl #### Process table test
AC_PATH_PROG(PATH_TO_PS,ps)
AC_PATH_PROG(PATH_TO_ENV,env)
AC_MSG_CHECKING(for ps syntax)
AC_ARG_WITH(ps_command,
@ -931,6 +939,19 @@ then
ac_cv_ps_cols=6
AC_MSG_RESULT([$ac_cv_ps_command])
dnl HP-UX:
dnl S UID RUID USER RUSER PID PPID VSZ %CPU COMMAND COMMAND
dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X
dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit
elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \
egrep -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
then
ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'"
ac_cv_ps_format="%s %d %d %d %d %f %s %n"
ac_cv_ps_cols=8
AC_MSG_RESULT([$ac_cv_ps_command])
dnl AIX 4.1:
dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD
dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper
@ -1464,6 +1485,16 @@ else
AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
fi
AC_PATH_PROG(PATH_TO_SUDO,sudo)
AC_ARG_WITH(sudo_command,
ACX_HELP_STRING([--with-sudo-command=PATH],
[sets path to sudo]), PATH_TO_SUDO=$withval)
if test -n "$PATH_TO_SUDO"
then
AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo])
else
AC_MSG_WARN([Could not find sudo or eqivalent])
fi
AC_PATH_PROG(PATH_TO_MAILQ,mailq)
AC_ARG_WITH(mailq_command,

View file

@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strsep timegm unsetenv vasprintf vsnprintf
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf
AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects
@ -1553,6 +1553,15 @@ EXTRA_libgnu_a_SOURCES += strcasecmp.c strncasecmp.c
## end gnulib module strcase
## begin gnulib module strcasestr-simple
EXTRA_DIST += str-two-way.h strcasestr.c
EXTRA_libgnu_a_SOURCES += strcasestr.c
## end gnulib module strcasestr-simple
## begin gnulib module streq

View file

@ -36,7 +36,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strsep timegm unsetenv vasprintf vsnprintf
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf
@ -155,6 +155,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strcasestr.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
$(top_srcdir)/gl/m4/string_h.m4 \
$(top_srcdir)/gl/m4/strings_h.m4 \
@ -1071,6 +1072,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_APTGET = @PATH_TO_APTGET@
PATH_TO_DIG = @PATH_TO_DIG@
PATH_TO_ENV = @PATH_TO_ENV@
PATH_TO_FPING = @PATH_TO_FPING@
PATH_TO_FPING6 = @PATH_TO_FPING6@
PATH_TO_LMSTAT = @PATH_TO_LMSTAT@
@ -1088,6 +1090,7 @@ PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@
PATH_TO_SNMPGET = @PATH_TO_SNMPGET@
PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@
PATH_TO_SSH = @PATH_TO_SSH@
PATH_TO_SUDO = @PATH_TO_SUDO@
PATH_TO_SWAP = @PATH_TO_SWAP@
PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
PATH_TO_UPTIME = @PATH_TO_UPTIME@
@ -1422,8 +1425,9 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.in.h arpa_inet.in.h btowc.c \
$(top_srcdir)/build-aux/snippet/c++defs.h \
$(top_srcdir)/build-aux/snippet/warn-on-use.h snprintf.c \
w32sock.h stdalign.in.h stdbool.in.h stddef.in.h stdint.in.h \
stdio.in.h stdlib.in.h strcasecmp.c strncasecmp.c streq.h \
strerror.c strerror-override.c strerror-override.h string.in.h \
stdio.in.h stdlib.in.h strcasecmp.c strncasecmp.c \
str-two-way.h strcasestr.c streq.h strerror.c \
strerror-override.c strerror-override.h string.in.h \
strings.in.h strndup.c strnlen.c strsep.c str-two-way.h \
strstr.c sys_socket.in.h sys_types.in.h sys_uio.in.h \
$(top_srcdir)/build-aux/config.rpath time.in.h time_r.c \
@ -1483,10 +1487,10 @@ EXTRA_libgnu_a_SOURCES = btowc.c stripslash.c error.c float.c itold.c \
mbtowc.c memchr.c mktime.c mktime.c mountlist.c msvc-inval.c \
msvc-nothrow.c nl_langinfo.c read.c regcomp.c regex.c \
regex_internal.c regexec.c setenv.c snprintf.c strcasecmp.c \
strncasecmp.c strerror.c strerror-override.c strndup.c \
strnlen.c strsep.c strstr.c time_r.c timegm.c unsetenv.c \
asnprintf.c printf-args.c printf-parse.c vasnprintf.c \
asprintf.c vasprintf.c vsnprintf.c wcrtomb.c
strncasecmp.c strcasestr.c strerror.c strerror-override.c \
strndup.c strnlen.c strsep.c strstr.c time_r.c timegm.c \
unsetenv.c asnprintf.c printf-args.c printf-parse.c \
vasnprintf.c asprintf.c vasprintf.c vsnprintf.c wcrtomb.c
charset_alias = $(DESTDIR)$(libdir)/charset.alias
charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
@ -1620,6 +1624,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockets.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strcasecmp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strcasestr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror-override.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stripslash.Po@am__quote@

View file

@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strsep timegm unsetenv vasprintf vsnprintf
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@ -48,6 +48,7 @@ gl_MODULES([
regex
setenv
strcase
strcasestr
strsep
timegm
unsetenv

View file

@ -121,6 +121,8 @@ AC_DEFUN([gl_EARLY],
# Code from module stdio:
# Code from module stdlib:
# Code from module strcase:
# Code from module strcasestr:
# Code from module strcasestr-simple:
# Code from module streq:
# Code from module strerror:
# Code from module strerror-override:
@ -390,6 +392,17 @@ AC_DEFUN([gl_INIT],
AC_LIBOBJ([strncasecmp])
gl_PREREQ_STRNCASECMP
fi
gl_FUNC_STRCASESTR
if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
AC_LIBOBJ([strcasestr])
gl_PREREQ_STRCASESTR
fi
gl_FUNC_STRCASESTR_SIMPLE
if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
AC_LIBOBJ([strcasestr])
gl_PREREQ_STRCASESTR
fi
gl_STRING_MODULE_INDICATOR([strcasestr])
gl_FUNC_STRERROR
if test $REPLACE_STRERROR = 1; then
AC_LIBOBJ([strerror])
@ -723,6 +736,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/stdlib.in.h
lib/str-two-way.h
lib/strcasecmp.c
lib/strcasestr.c
lib/streq.h
lib/strerror-override.c
lib/strerror-override.h
@ -866,6 +880,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/stdio_h.m4
m4/stdlib_h.m4
m4/strcase.m4
m4/strcasestr.m4
m4/strerror.m4
m4/string_h.m4
m4/strings_h.m4

142
gl/m4/strcasestr.m4 Normal file
View file

@ -0,0 +1,142 @@
# strcasestr.m4 serial 21
dnl Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl Check that strcasestr is present and works.
AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
[
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
dnl Persuade glibc <string.h> to declare strcasestr().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_FUNC_MEMCHR])
AC_CHECK_FUNCS([strcasestr])
if test $ac_cv_func_strcasestr = no; then
HAVE_STRCASESTR=0
else
if test "$gl_cv_func_memchr_works" != yes; then
REPLACE_STRCASESTR=1
else
dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092.
AC_CACHE_CHECK([whether strcasestr works],
[gl_cv_func_strcasestr_works_always],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <string.h> /* for strcasestr */
#define P "_EF_BF_BD"
#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
#define NEEDLE P P P P P
]], [[return !!strcasestr (HAYSTACK, NEEDLE);
]])],
[gl_cv_func_strcasestr_works_always=yes],
[gl_cv_func_strcasestr_works_always=no],
[dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
dnl affected, since it uses different source code for strcasestr
dnl than glibc.
dnl Assume that it works on all other platforms, even if it is not
dnl linear.
AC_EGREP_CPP([Lucky user],
[
#ifdef __GNU_LIBRARY__
#include <features.h>
#if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
|| defined __UCLIBC__
Lucky user
#endif
#elif defined __CYGWIN__
#include <cygwin/version.h>
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
Lucky user
#endif
#else
Lucky user
#endif
],
[gl_cv_func_strcasestr_works_always="guessing yes"],
[gl_cv_func_strcasestr_works_always="guessing no"])
])
])
case "$gl_cv_func_strcasestr_works_always" in
*yes) ;;
*)
REPLACE_STRCASESTR=1
;;
esac
fi
fi
]) # gl_FUNC_STRCASESTR_SIMPLE
dnl Additionally, check that strcasestr is efficient.
AC_DEFUN([gl_FUNC_STRCASESTR],
[
AC_REQUIRE([gl_FUNC_STRCASESTR_SIMPLE])
if test $HAVE_STRCASESTR = 1 && test $REPLACE_STRCASESTR = 0; then
AC_CACHE_CHECK([whether strcasestr works in linear time],
[gl_cv_func_strcasestr_linear],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <signal.h> /* for signal */
#include <string.h> /* for strcasestr */
#include <stdlib.h> /* for malloc */
#include <unistd.h> /* for alarm */
static void quit (int sig) { exit (sig + 128); }
]], [[
int result = 0;
size_t m = 1000000;
char *haystack = (char *) malloc (2 * m + 2);
char *needle = (char *) malloc (m + 2);
/* Failure to compile this test due to missing alarm is okay,
since all such platforms (mingw) also lack strcasestr. */
signal (SIGALRM, quit);
alarm (5);
/* Check for quadratic performance. */
if (haystack && needle)
{
memset (haystack, 'A', 2 * m);
haystack[2 * m] = 'B';
haystack[2 * m + 1] = 0;
memset (needle, 'A', m);
needle[m] = 'B';
needle[m + 1] = 0;
if (!strcasestr (haystack, needle))
result |= 1;
}
return result;
]])],
[gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no],
[dnl Only glibc > 2.12 and cygwin > 1.7.7 are known to have a
dnl strcasestr that works in linear time.
AC_EGREP_CPP([Lucky user],
[
#include <features.h>
#ifdef __GNU_LIBRARY__
#if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
&& !defined __UCLIBC__
Lucky user
#endif
#endif
#ifdef __CYGWIN__
#include <cygwin/version.h>
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
Lucky user
#endif
#endif
],
[gl_cv_func_strcasestr_linear="guessing yes"],
[gl_cv_func_strcasestr_linear="guessing no"])
])
])
case "$gl_cv_func_strcasestr_linear" in
*yes) ;;
*)
REPLACE_STRCASESTR=1
;;
esac
fi
]) # gl_FUNC_STRCASESTR
# Prerequisites of lib/strcasestr.c.
AC_DEFUN([gl_PREREQ_STRCASESTR], [
:
])

82
gl/strcasestr.c Normal file
View file

@ -0,0 +1,82 @@
/* Case-insensitive searching in a string.
Copyright (C) 2005-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2005.
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, 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 <config.h>
/* Specification. */
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <strings.h>
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
/* Two-Way algorithm. */
#define RETURN_TYPE char *
#define AVAILABLE(h, h_l, j, n_l) \
(!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \
&& ((h_l) = (j) + (n_l)))
#define CANON_ELEMENT(c) TOLOWER (c)
#define CMP_FUNC(p1, p2, l) \
strncasecmp ((const char *) (p1), (const char *) (p2), l)
#include "str-two-way.h"
/* Find the first occurrence of NEEDLE in HAYSTACK, using
case-insensitive comparison. This function gives unspecified
results in multibyte locales. */
char *
strcasestr (const char *haystack_start, const char *needle_start)
{
const char *haystack = haystack_start;
const char *needle = needle_start;
size_t needle_len; /* Length of NEEDLE. */
size_t haystack_len; /* Known minimum length of HAYSTACK. */
bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */
/* Determine length of NEEDLE, and in the process, make sure
HAYSTACK is at least as long (no point processing all of a long
NEEDLE if HAYSTACK is too short). */
while (*haystack && *needle)
{
ok &= (TOLOWER ((unsigned char) *haystack)
== TOLOWER ((unsigned char) *needle));
haystack++;
needle++;
}
if (*needle)
return NULL;
if (ok)
return (char *) haystack_start;
needle_len = needle - needle_start;
haystack = haystack_start + 1;
haystack_len = needle_len - 1;
/* Perform the search. Abstract memory is considered to be an array
of 'unsigned char' values, not an array of 'char' values. See
ISO C 99 section 6.2.6.1. */
if (needle_len < LONG_NEEDLE_THRESHOLD)
return two_way_short_needle ((const unsigned char *) haystack,
haystack_len,
(const unsigned char *) needle_start,
needle_len);
return two_way_long_needle ((const unsigned char *) haystack, haystack_len,
(const unsigned char *) needle_start,
needle_len);
}
#undef LONG_NEEDLE_THRESHOLD

View file

@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strcasestr.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
$(top_srcdir)/gl/m4/string_h.m4 \
$(top_srcdir)/gl/m4/strings_h.m4 \
@ -1040,6 +1041,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_APTGET = @PATH_TO_APTGET@
PATH_TO_DIG = @PATH_TO_DIG@
PATH_TO_ENV = @PATH_TO_ENV@
PATH_TO_FPING = @PATH_TO_FPING@
PATH_TO_FPING6 = @PATH_TO_FPING6@
PATH_TO_LMSTAT = @PATH_TO_LMSTAT@
@ -1057,6 +1059,7 @@ PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@
PATH_TO_SNMPGET = @PATH_TO_SNMPGET@
PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@
PATH_TO_SSH = @PATH_TO_SSH@
PATH_TO_SUDO = @PATH_TO_SUDO@
PATH_TO_SWAP = @PATH_TO_SWAP@
PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
PATH_TO_UPTIME = @PATH_TO_UPTIME@

View file

@ -133,6 +133,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strcasestr.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
$(top_srcdir)/gl/m4/string_h.m4 \
$(top_srcdir)/gl/m4/strings_h.m4 \
@ -1048,6 +1049,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_APTGET = @PATH_TO_APTGET@
PATH_TO_DIG = @PATH_TO_DIG@
PATH_TO_ENV = @PATH_TO_ENV@
PATH_TO_FPING = @PATH_TO_FPING@
PATH_TO_FPING6 = @PATH_TO_FPING6@
PATH_TO_LMSTAT = @PATH_TO_LMSTAT@
@ -1065,6 +1067,7 @@ PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@
PATH_TO_SNMPGET = @PATH_TO_SNMPGET@
PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@
PATH_TO_SSH = @PATH_TO_SSH@
PATH_TO_SUDO = @PATH_TO_SUDO@
PATH_TO_SWAP = @PATH_TO_SWAP@
PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
PATH_TO_UPTIME = @PATH_TO_UPTIME@

View file

@ -79,12 +79,14 @@ static pid_t *_cmd_pids = NULL;
* If that fails and the macro isn't defined, we fall back to an educated
* guess. There's no guarantee that our guess is adequate and the program
* will die with SIGSEGV if it isn't and the upper boundary is breached. */
#define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */
#define MAXFD_LIMIT 8192 /* upper limit of open files */
#ifdef _SC_OPEN_MAX
static long maxfd = 0;
#elif defined(OPEN_MAX)
# define maxfd OPEN_MAX
#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */
# define maxfd 256
# define maxfd DEFAULT_MAXFD
#endif
@ -112,10 +114,18 @@ cmd_init (void)
if (!maxfd && (maxfd = sysconf (_SC_OPEN_MAX)) < 0) {
/* possibly log or emit a warning here, since there's no
* guarantee that our guess at maxfd will be adequate */
maxfd = 256;
maxfd = DEFAULT_MAXFD;
}
#endif
/* if maxfd is unnaturally high, we force it to a lower value
* ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
* a segfault when following calloc is called ... ) */
if ( maxfd > MAXFD_LIMIT ) {
maxfd = MAXFD_LIMIT;
}
if (!_cmd_pids)
_cmd_pids = calloc (maxfd, sizeof (pid_t));
}

View file

@ -2,11 +2,11 @@ PKG="NGOSplugin"
NAME="monitoring-plugins"
DESC="Network Monitoring Plugins for Nagios and compatible"
ARCH="unknown"
VERSION="2.1.2,REV=2015.10.16.11.39"
VERSION="2.2,REV=2016.11.29.09.48"
CATEGORY="application"
VENDOR="Monitoring Plugins Development Team"
EMAIL="devel@monitoring-plugins.org"
PSTAMP="nag20151016113911"
PSTAMP="nag20161129094818"
BASEDIR="/"
CLASSES="none"

View file

@ -131,6 +131,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strcasestr.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
$(top_srcdir)/gl/m4/string_h.m4 \
$(top_srcdir)/gl/m4/strings_h.m4 \
@ -1010,6 +1011,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_APTGET = @PATH_TO_APTGET@
PATH_TO_DIG = @PATH_TO_DIG@
PATH_TO_ENV = @PATH_TO_ENV@
PATH_TO_FPING = @PATH_TO_FPING@
PATH_TO_FPING6 = @PATH_TO_FPING6@
PATH_TO_LMSTAT = @PATH_TO_LMSTAT@
@ -1027,6 +1029,7 @@ PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@
PATH_TO_SNMPGET = @PATH_TO_SNMPGET@
PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@
PATH_TO_SSH = @PATH_TO_SSH@
PATH_TO_SUDO = @PATH_TO_SUDO@
PATH_TO_SWAP = @PATH_TO_SWAP@
PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
PATH_TO_UPTIME = @PATH_TO_UPTIME@

View file

@ -463,10 +463,9 @@ int send_dhcp_discover(int sock){
discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH;
/*
* transaction ID is supposed to be random. We won't use the address so
* we don't care about high entropy here. time(2) is good enough.
* transaction ID is supposed to be random.
*/
srand(time(NULL));
srand(time(NULL)^getpid());
packet_xid=random();
discover_packet.xid=htonl(packet_xid);
@ -692,17 +691,11 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
}
else{
/* why do we need to peek first? i don't know, its a hack. without it, the source address of the first packet received was
not being interpreted correctly. sigh... */
bzero(&source_address,sizeof(source_address));
address_size=sizeof(source_address);
recv_result=recvfrom(sock,(char *)buffer,buffer_size,MSG_PEEK,(struct sockaddr *)&source_address,&address_size);
if(verbose)
printf("recv_result_1: %d\n",recv_result);
recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size);
if(verbose)
printf("recv_result_2: %d\n",recv_result);
printf("recv_result: %d\n",recv_result);
if(recv_result==-1){
if(verbose){
@ -1142,11 +1135,11 @@ int call_getopt(int argc, char **argv){
case 'V': /* version */
print_revision(progname, NP_VERSION);
exit(STATE_OK);
exit(STATE_UNKNOWN);
case 'h': /* help */
print_help();
exit(STATE_OK);
exit(STATE_UNKNOWN);
case 'v': /* verbose */
verbose=1;

View file

@ -184,7 +184,7 @@ static u_int get_timevar(const char *);
static u_int get_timevaldiff(struct timeval *, struct timeval *);
static in_addr_t get_ip_address(const char *);
static int wait_for_reply(int, u_int);
static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *);
static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, struct timeval*);
static int send_icmp_ping(int, struct rta_host *);
static int get_threshold(char *str, threshold *th);
static void run_checks(void);
@ -378,6 +378,9 @@ main(int argc, char **argv)
int icmp_sockerrno, udp_sockerrno, tcp_sockerrno;
int result;
struct rta_host *host;
#ifdef SO_TIMESTAMP
int on = 1;
#endif
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@ -402,6 +405,11 @@ main(int argc, char **argv)
/* now drop privileges (no effect if not setsuid or geteuid() == 0) */
setuid(getuid());
#ifdef SO_TIMESTAMP
if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on)))
if(debug) printf("Warning: no SO_TIMESTAMP support\n");
#endif // SO_TIMESTAMP
/* POSIXLY_CORRECT might break things, so unset it (the portable way) */
environ = NULL;
@ -462,13 +470,13 @@ main(int argc, char **argv)
/* parse the arguments */
for(i = 1; i < argc; i++) {
while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) {
long size;
unsigned short size;
switch(arg) {
case 'v':
debug++;
break;
case 'b':
size = strtol(optarg,NULL,0);
size = (unsigned short)strtol(optarg,NULL,0);
if (size >= (sizeof(struct icmp) + sizeof(struct icmp_ping_data)) &&
size < MAX_PING_DATA) {
icmp_data_size = size;
@ -518,10 +526,10 @@ main(int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
}
}
}
@ -727,7 +735,7 @@ wait_for_reply(int sock, u_int t)
/* reap responses until we hit a timeout */
n = recvfrom_wto(sock, buf, sizeof(buf),
(struct sockaddr *)&resp_addr, &t);
(struct sockaddr *)&resp_addr, &t, &now);
if(!n) {
if(debug > 1) {
printf("recvfrom_wto() timed out during a %u usecs wait\n",
@ -777,11 +785,11 @@ wait_for_reply(int sock, u_int t)
/* this is indeed a valid response */
memcpy(&data, icp.icmp_data, sizeof(data));
if (debug > 2)
printf("ICMP echo-reply of len %u, id %u, seq %u, cksum 0x%X\n",
sizeof(data), ntohs(icp.icmp_id), ntohs(icp.icmp_seq), icp.icmp_cksum);
printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n",
(unsigned long)sizeof(data), ntohs(icp.icmp_id),
ntohs(icp.icmp_seq), icp.icmp_cksum);
host = table[ntohs(icp.icmp_seq)/packets];
gettimeofday(&now, &tz);
tdiff = get_timevaldiff(&data.stime, &now);
host->time_waited += tdiff;
@ -823,6 +831,8 @@ send_icmp_ping(int sock, struct rta_host *host)
} packet = { NULL };
long int len;
struct icmp_ping_data data;
struct msghdr hdr;
struct iovec iov;
struct timeval tv;
struct sockaddr *addr;
@ -855,11 +865,27 @@ send_icmp_ping(int sock, struct rta_host *host)
packet.icp->icmp_cksum = icmp_checksum(packet.cksum_in, icmp_pkt_size);
if (debug > 2)
printf("Sending ICMP echo-request of len %u, id %u, seq %u, cksum 0x%X to host %s\n",
sizeof(data), ntohs(packet.icp->icmp_id), ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum, host->name);
printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n",
(unsigned long)sizeof(data), ntohs(packet.icp->icmp_id),
ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum,
host->name);
len = sendto(sock, packet.buf, icmp_pkt_size, 0, (struct sockaddr *)addr,
sizeof(struct sockaddr));
memset(&iov, 0, sizeof(iov));
iov.iov_base = packet.buf;
iov.iov_len = icmp_pkt_size;
memset(&hdr, 0, sizeof(hdr));
hdr.msg_name = addr;
hdr.msg_namelen = sizeof(struct sockaddr);
hdr.msg_iov = &iov;
hdr.msg_iovlen = 1;
/* MSG_CONFIRM is a linux thing and only available on linux kernels >= 2.3.15, see send(2) */
#ifdef MSG_CONFIRM
len = sendmsg(sock, &hdr, MSG_CONFIRM);
#else
len = sendmsg(sock, &hdr, 0);
#endif
if(len < 0 || (unsigned int)len != icmp_pkt_size) {
if(debug) printf("Failed to send ping to %s\n",
@ -875,12 +901,18 @@ send_icmp_ping(int sock, struct rta_host *host)
static int
recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
u_int *timo)
u_int *timo, struct timeval* tv)
{
u_int slen;
int n;
int n, ret;
struct timeval to, then, now;
fd_set rd, wr;
char ans_data[4096];
struct msghdr hdr;
struct iovec iov;
#ifdef SO_TIMESTAMP
struct cmsghdr* chdr;
#endif
if(!*timo) {
if(debug) printf("*timo is not\n");
@ -904,7 +936,32 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
slen = sizeof(struct sockaddr);
return recvfrom(sock, buf, len, 0, saddr, &slen);
memset(&iov, 0, sizeof(iov));
iov.iov_base = buf;
iov.iov_len = len;
memset(&hdr, 0, sizeof(hdr));
hdr.msg_name = saddr;
hdr.msg_namelen = slen;
hdr.msg_iov = &iov;
hdr.msg_iovlen = 1;
hdr.msg_control = ans_data;
hdr.msg_controllen = sizeof(ans_data);
ret = recvmsg(sock, &hdr, 0);
#ifdef SO_TIMESTAMP
for(chdr = CMSG_FIRSTHDR(&hdr); chdr; chdr = CMSG_NXTHDR(&hdr, chdr)) {
if(chdr->cmsg_level == SOL_SOCKET
&& chdr->cmsg_type == SO_TIMESTAMP
&& chdr->cmsg_len >= CMSG_LEN(sizeof(struct timeval))) {
memcpy(tv, CMSG_DATA(chdr), sizeof(*tv));
break ;
}
}
if (!chdr)
#endif // SO_TIMESTAMP
gettimeofday(tv, &tz);
return (ret);
}
static void
@ -1183,7 +1240,7 @@ static u_int
get_timevar(const char *str)
{
char p, u, *ptr;
unsigned int len;
size_t len;
u_int i, d; /* integer and decimal, respectively */
u_int factor = 1000; /* default to milliseconds */

View file

@ -36,6 +36,8 @@ TESTS = @SCRIPT_TEST@
test:
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl t/utils.t # utils.t is excluded from above, so manually ask to test
for SCRIPT in *.pl; do perl -wc $$SCRIPT || exit 1; done
set -e; for SCRIPT in *.sh; do sh -n $$SCRIPT || exit 1; done
test-debug:
NPTEST_DEBUG=1 HARNESS_VERBOSE=1 perl -I $(top_builddir) -I $(top_srcdir) ../test.pl

View file

@ -129,6 +129,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strcasestr.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
$(top_srcdir)/gl/m4/string_h.m4 \
$(top_srcdir)/gl/m4/strings_h.m4 \
@ -1007,6 +1008,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_APTGET = @PATH_TO_APTGET@
PATH_TO_DIG = @PATH_TO_DIG@
PATH_TO_ENV = @PATH_TO_ENV@
PATH_TO_FPING = @PATH_TO_FPING@
PATH_TO_FPING6 = @PATH_TO_FPING6@
PATH_TO_LMSTAT = @PATH_TO_LMSTAT@
@ -1024,6 +1026,7 @@ PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@
PATH_TO_SNMPGET = @PATH_TO_SNMPGET@
PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@
PATH_TO_SSH = @PATH_TO_SSH@
PATH_TO_SUDO = @PATH_TO_SUDO@
PATH_TO_SWAP = @PATH_TO_SWAP@
PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
PATH_TO_UPTIME = @PATH_TO_UPTIME@
@ -1678,6 +1681,8 @@ uninstall-am: uninstall-libexecSCRIPTS
test:
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl t/utils.t # utils.t is excluded from above, so manually ask to test
for SCRIPT in *.pl; do perl -wc $$SCRIPT || exit 1; done
set -e; for SCRIPT in *.sh; do sh -n $$SCRIPT || exit 1; done
test-debug:
NPTEST_DEBUG=1 HARNESS_VERBOSE=1 perl -I $(top_builddir) -I $(top_srcdir) ../test.pl

View file

@ -6,7 +6,6 @@ use Getopt::Long;
use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME = "check_breeze";
@ -29,10 +28,10 @@ GetOptions
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};}
($opt_H) || usage("Host name/address not specified\n");
my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);

View file

@ -26,7 +26,6 @@ use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_
use vars qw($PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
sub print_help ();
@ -55,10 +54,10 @@ GetOptions
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@'); #'
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};}
my $smbclient = $utils::PATH_TO_SMBCLIENT;
$smbclient || usage("check requires smbclient, smbclient not set\n");

View file

@ -27,7 +27,6 @@ use File::stat;
use vars qw($PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw (%ERRORS &print_revision &support);
sub print_help ();
@ -61,12 +60,12 @@ GetOptions(
if ($opt_V) {
print_revision($PROGNAME, '@NP_VERSION@');
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
$opt_f = shift unless ($opt_f);

View file

@ -37,7 +37,6 @@ use Getopt::Long;
use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME="check_flexlm";
@ -59,7 +58,7 @@ GetOptions
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
unless (defined $opt_t) {
@ -67,7 +66,7 @@ unless (defined $opt_t) {
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};}
unless (defined $opt_F) {
print "Missing license.dat file\n";

View file

@ -37,7 +37,6 @@ use POSIX;
use strict;
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use Net::SNMP;
@ -326,7 +325,7 @@ sub print_help() {
printf " (Implies the use of -I)\n";
printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n";
printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n";
printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n";
printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
printf " -V (--version) Plugin version\n";
printf " -h (--help) usage help \n\n";
@ -368,17 +367,17 @@ sub process_arguments() {
if ($status == 0){
print_help();
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if (! utils::is_hostname($hostname)){

View file

@ -35,7 +35,6 @@ use POSIX;
use strict;
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use Net::SNMP;
@ -120,7 +119,7 @@ $status = process_arguments();
if ($status != 0)
{
print_help() ;
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
@ -281,7 +280,7 @@ sub print_help() {
printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
printf " privacy password and authEngineID\n";
printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n";
printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n";
printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
printf " -V (--version) Plugin version\n";
printf " -h (--help) usage help \n\n";
@ -314,17 +313,17 @@ sub process_arguments() {
if ($status == 0){
print_help();
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
unless (defined $timeout) {

View file

@ -51,7 +51,6 @@ use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose);
use vars qw($PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
# ----------------------------------------------------[ Function Prototypes ]--
@ -182,10 +181,10 @@ MAIN:
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};}
($opt_H) || ($opt_H = shift @ARGV) || usage("Host name/address not specified\n");
my $remotehost = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);

View file

@ -28,14 +28,14 @@
use POSIX;
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t
use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s
$opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines
%srcdomains %dstdomains);
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw(%ERRORS &print_revision &support &usage );
my ($sudo);
sub print_help ();
sub print_usage ();
@ -57,6 +57,17 @@ if ($status){
exit $ERRORS{"UNKNOWN"};
}
if ($opt_s) {
if (defined $utils::PATH_TO_SUDO && -x $utils::PATH_TO_SUDO) {
$sudo = $utils::PATH_TO_SUDO;
} else {
print "ERROR: Cannot execute sudo\n";
exit $ERRORS{'UNKNOWN'};
}
} else {
$sudo = "";
}
$SIG{'ALRM'} = sub {
print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n");
exit $ERRORS{"WARNING"};
@ -69,7 +80,7 @@ if ($mailq eq "sendmail") {
## open mailq
if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) {
print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
exit $ERRORS{'UNKNOWN'};
}
@ -298,7 +309,7 @@ elsif ( $mailq eq "postfix" ) {
## open mailq
if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) {
print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
exit $ERRORS{'UNKNOWN'};
}
@ -380,7 +391,7 @@ elsif ( $mailq eq "qmail" ) {
# open qmail-qstat
if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) {
if (! open (MAILQ, "$utils::PATH_TO_QMAIL_QSTAT | " ) ) {
if (! open (MAILQ, "$sudo $utils::PATH_TO_QMAIL_QSTAT | " ) ) {
print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n";
exit $ERRORS{'UNKNOWN'};
}
@ -462,7 +473,7 @@ elsif ( $mailq eq "qmail" ) {
elsif ( $mailq eq "exim" ) {
## open mailq
if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) {
print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
exit $ERRORS{'UNKNOWN'};
}
@ -505,7 +516,7 @@ elsif ( $mailq eq "exim" ) {
elsif ( $mailq eq "nullmailer" ) {
## open mailq
if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) {
print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
exit $ERRORS{'UNKNOWN'};
}
@ -556,17 +567,18 @@ sub process_arguments(){
"M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail)
"w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number
"c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number
"t=i" => \$opt_t, "timeout=i" => \$opt_t
"t=i" => \$opt_t, "timeout=i" => \$opt_t,
"s" => \$opt_s, "sudo" => \$opt_s
);
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if (defined $opt_v ){
@ -637,7 +649,7 @@ sub process_arguments(){
}
sub print_usage () {
print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-v verbose]\n";
print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-v]\n";
}
sub print_help () {
@ -654,6 +666,7 @@ sub print_help () {
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 = autodetect)\n";
print "-s (--sudo) = Use sudo to call the mailq command\n";
print "-h (--help)\n";
print "-V (--version)\n";
print "-v (--verbose) = debugging output\n";

View file

@ -22,7 +22,6 @@
use strict;
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state);
@ -64,12 +63,12 @@ GetOptions(
);
# -h means display verbose help screen
if ($opt_h) { print_help(); exit $ERRORS{'OK'}; }
if ($opt_h) { print_help(); exit $ERRORS{'UNKNOWN'}; }
# -V means display version number
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
# Hash containing all RPC program names and numbers

View file

@ -5,7 +5,6 @@
use strict;
use FindBin;
use lib "$FindBin::Bin";
use lib '@libexecdir@';
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
use Getopt::Long;
@ -32,12 +31,12 @@ GetOptions
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@'); #'
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
exit $ERRORS{'UNKNOWN'};
}
$opt_H = shift unless ($opt_H);

View file

@ -15,7 +15,7 @@ my $successOutput = '/^check_rpc/';
my $t;
$t += checkCmd( "./check_rpc -V", 0, $successOutput );
$t += checkCmd( "./check_rpc -V", 3, $successOutput );
exit(0) if defined($Test::Harness::VERSION);
exit($tests - $t);

View file

@ -17,6 +17,7 @@ sub support();
sub is_hostname;
## updated by autoconf
$PATH_TO_SUDO = "@PATH_TO_SUDO@";
$PATH_TO_RPCINFO = "@PATH_TO_RPCINFO@" ;
$PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ;
$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ;

View file

@ -147,6 +147,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strcasestr.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
$(top_srcdir)/gl/m4/string_h.m4 \
$(top_srcdir)/gl/m4/strings_h.m4 \
@ -1196,6 +1197,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_APTGET = @PATH_TO_APTGET@
PATH_TO_DIG = @PATH_TO_DIG@
PATH_TO_ENV = @PATH_TO_ENV@
PATH_TO_FPING = @PATH_TO_FPING@
PATH_TO_FPING6 = @PATH_TO_FPING6@
PATH_TO_LMSTAT = @PATH_TO_LMSTAT@
@ -1213,6 +1215,7 @@ PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@
PATH_TO_SNMPGET = @PATH_TO_SNMPGET@
PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@
PATH_TO_SSH = @PATH_TO_SSH@
PATH_TO_SUDO = @PATH_TO_SUDO@
PATH_TO_SWAP = @PATH_TO_SWAP@
PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
PATH_TO_UPTIME = @PATH_TO_UPTIME@

View file

@ -160,10 +160,10 @@ int process_arguments (int argc, char **argv) {
switch(c) {
case 'h':
print_help();
exit(STATE_OK);
exit(STATE_UNKNOWN);
case 'V':
print_revision(progname, NP_VERSION);
exit(STATE_OK);
exit(STATE_UNKNOWN);
case 'v':
verbose++;
break;

View file

@ -100,6 +100,13 @@ main (int argc, char **argv)
result = cmd_run_array (commargv, &chld_out, &chld_err, 0);
if (verbose) {
for(i = 0; i < chld_out.lines; i++)
printf("stdout: %s\n", chld_out.line[i]);
for(i = 0; i < chld_err.lines; i++)
printf("stderr: %s\n", chld_err.line[i]);
}
if (skip_stdout == -1) /* --skip-stdout specified without argument */
skip_stdout = chld_out.lines;
if (skip_stderr == -1) /* --skip-stderr specified without argument */
@ -209,10 +216,10 @@ process_arguments (int argc, char **argv)
switch (c) {
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'v': /* help */
verbose = TRUE;
break;

View file

@ -200,7 +200,7 @@ int process_arguments(int argc, char **argv){
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
break;
case 'H': /* help */

View file

@ -368,10 +368,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'c': /* critical range */
critical_range = optarg;

View file

@ -48,7 +48,7 @@ void print_usage (void);
#define UNDEFINED 0
#define DEFAULT_PORT 53
#define DEFAULT_TRIES 3
#define DEFAULT_TRIES 2
char *query_address = NULL;
char *record_type = "A";
@ -94,7 +94,7 @@ main (int argc, char **argv)
timeout_interval_dig = timeout_interval / number_tries + number_tries;
/* get the command to run */
xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +tries=%d +time=%d",
xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +retry=%d +time=%d",
PATH_TO_DIG, dig_args, query_transport, server_port, dns_server, query_address, record_type, number_tries, timeout_interval_dig);
alarm (timeout_interval);
@ -125,7 +125,7 @@ main (int argc, char **argv)
if (verbose)
printf ("%s\n", chld_out.line[i]);
if (strstr (chld_out.line[i], (expected_address == NULL ? query_address : expected_address)) != NULL) {
if (strcasestr (chld_out.line[i], (expected_address == NULL ? query_address : expected_address)) != NULL) {
msg = chld_out.line[i];
result = STATE_OK;
@ -223,10 +223,10 @@ process_arguments (int argc, char **argv)
switch (c) {
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'H': /* hostname */
host_or_die(optarg);
dns_server = optarg;

View file

@ -58,9 +58,6 @@ const char *email = "devel@monitoring-plugins.org";
# define ERROR -1
#endif
/* If nonzero, show inode information. */
static int inode_format = 1;
/* If nonzero, show even filesystems with zero size or
uninteresting types. */
static int show_all_fs = 1;
@ -178,7 +175,7 @@ main (int argc, char **argv)
int temp_result;
struct mount_entry *me;
struct fs_usage fsp, tmpfsp;
struct fs_usage fsp;
struct parameter_list *temp_list, *path;
#ifdef __CYGWIN__
@ -423,9 +420,7 @@ process_arguments (int argc, char **argv)
int c, err;
struct parameter_list *se;
struct parameter_list *temp_list = NULL, *previous = NULL;
struct parameter_list *temp_path_select_list = NULL;
struct mount_entry *me, *temp_me;
int result = OK;
struct mount_entry *me;
regex_t re;
int cflags = REG_NOSUB | REG_EXTENDED;
int default_cflags = cflags;
@ -762,10 +757,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case '?': /* help */
usage (_("Unknown argument"));
}

View file

@ -81,7 +81,6 @@ main (int argc, char **argv)
double elapsed_time;
long microsec;
struct timeval tv;
int multi_address;
int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
output chld_out, chld_err;
size_t i;
@ -127,7 +126,7 @@ main (int argc, char **argv)
if (verbose)
puts(chld_out.line[i]);
if (strstr (chld_out.line[i], ".in-addr.arpa")) {
if (strcasestr (chld_out.line[i], ".in-addr.arpa")) {
if ((temp_buffer = strstr (chld_out.line[i], "name = ")))
addresses[n_addresses++] = strdup (temp_buffer + 7);
else {
@ -249,11 +248,6 @@ main (int argc, char **argv)
elapsed_time = (double)microsec / 1.0e6;
if (result == STATE_OK) {
if (strchr (address, ',') == NULL)
multi_address = FALSE;
else
multi_address = TRUE;
result = get_status(elapsed_time, time_thresholds);
if (result == STATE_OK) {
printf ("DNS %s: ", _("OK"));
@ -395,10 +389,10 @@ process_arguments (int argc, char **argv)
switch (c) {
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'v': /* version */
verbose = TRUE;
break;

View file

@ -52,11 +52,11 @@ main (int argc, char **argv)
usage4 (_("Could not parse arguments"));
else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
}
else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
}
else if (!is_integer (argv[1]))
usage4 (_("Arguments to check_dummy must be an integer"));

View file

@ -105,7 +105,7 @@ main (int argc, char **argv)
xasprintf(&option_string, "%s-I %s ", option_string, sourceif);
#ifdef PATH_TO_FPING6
if (address_family == AF_INET6)
if (address_family != AF_INET && is_inet6_addr(server))
fping_prog = strdup(PATH_TO_FPING6);
else
fping_prog = strdup(PATH_TO_FPING);
@ -314,10 +314,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'v': /* verbose mode */
verbose = TRUE;
break;

View file

@ -196,10 +196,10 @@ process_arguments (int argc, char **argv)
switch (c) {
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'v': /* version */
verbose = TRUE;
break;

View file

@ -350,10 +350,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case '?': /* help */
usage5 ();
}

View file

@ -91,10 +91,12 @@ struct timeval tv_temp;
int specify_port = FALSE;
int server_port = HTTP_PORT;
int virtual_port = 0;
char server_port_text[6] = "";
char server_type[6] = "http";
char *server_address;
char *host_name;
int host_name_length;
char *server_url;
char *user_agent;
int server_url_length;
@ -267,11 +269,11 @@ process_arguments (int argc, char **argv)
break;
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
break;
case 't': /* timeout period */
if (!is_intnonneg (optarg))
@ -343,9 +345,20 @@ process_arguments (int argc, char **argv)
parameters, like -S and -C combinations */
use_ssl = TRUE;
if (c=='S' && optarg != NULL) {
ssl_version = atoi(optarg);
if (ssl_version < 1 || ssl_version > 3)
usage4 (_("Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 (SSLv3)"));
int got_plus = strchr(optarg, '+') != NULL;
if (!strncmp (optarg, "1.2", 3))
ssl_version = got_plus ? MP_TLSv1_2_OR_NEWER : MP_TLSv1_2;
else if (!strncmp (optarg, "1.1", 3))
ssl_version = got_plus ? MP_TLSv1_1_OR_NEWER : MP_TLSv1_1;
else if (optarg[0] == '1')
ssl_version = got_plus ? MP_TLSv1_OR_NEWER : MP_TLSv1;
else if (optarg[0] == '3')
ssl_version = got_plus ? MP_SSLv3_OR_NEWER : MP_SSLv3;
else if (optarg[0] == '2')
ssl_version = got_plus ? MP_SSLv2_OR_NEWER : MP_SSLv2;
else
usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)"));
}
if (specify_port == FALSE)
server_port = HTTPS_PORT;
@ -380,11 +393,25 @@ process_arguments (int argc, char **argv)
case 'H': /* Host Name (virtual host) */
host_name = strdup (optarg);
if (host_name[0] == '[') {
if ((p = strstr (host_name, "]:")) != NULL) /* [IPv6]:port */
server_port = atoi (p + 2);
if ((p = strstr (host_name, "]:")) != NULL) { /* [IPv6]:port */
virtual_port = atoi (p + 2);
/* cut off the port */
host_name_length = strlen (host_name) - strlen (p) - 1;
free (host_name);
host_name = strndup (optarg, host_name_length);
if (specify_port == FALSE)
server_port = virtual_port;
}
} else if ((p = strchr (host_name, ':')) != NULL
&& strchr (++p, ':') == NULL) /* IPv4:port or host:port */
server_port = atoi (p);
&& strchr (++p, ':') == NULL) { /* IPv4:port or host:port */
virtual_port = atoi (p);
/* cut off the port */
host_name_length = strlen (host_name) - strlen (p) - 1;
free (host_name);
host_name = strndup (optarg, host_name_length);
if (specify_port == FALSE)
server_port = virtual_port;
}
break;
case 'I': /* Server IP-address */
server_address = strdup (optarg);
@ -539,9 +566,12 @@ process_arguments (int argc, char **argv)
if (http_method == NULL)
http_method = strdup ("GET");
if (client_cert && !client_privkey)
if (client_cert && !client_privkey)
usage4 (_("If you use a client certificate you must also specify a private key file"));
if (virtual_port == 0)
virtual_port = server_port;
return TRUE;
}
@ -869,53 +899,100 @@ check_http (void)
double elapsed_time_transfer = 0.0;
int page_len = 0;
int result = STATE_OK;
char *force_host_header = NULL;
/* try to connect to the host at the given port number */
gettimeofday (&tv_temp, NULL);
if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK)
die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n"));
microsec_connect = deltime (tv_temp);
/* if we are called with the -I option, the -j method is CONNECT and */
/* we received -S for SSL, then we tunnel the request through a proxy*/
/* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */
if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
&& host_name != NULL && use_ssl == TRUE) {
if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT);
asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent);
asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf);
asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
/* we finished our request, send empty line with CRLF */
asprintf (&buf, "%s%s", buf, CRLF);
if (verbose) printf ("%s\n", buf);
send(sd, buf, strlen (buf), 0);
buf[0]='\0';
if (verbose) printf ("Receive response from proxy\n");
read (sd, buffer, MAX_INPUT_BUFFER-1);
if (verbose) printf ("%s", buffer);
/* Here we should check if we got HTTP/1.1 200 Connection established */
}
#ifdef HAVE_SSL
elapsed_time_connect = (double)microsec_connect / 1.0e6;
if (use_ssl == TRUE) {
gettimeofday (&tv_temp, NULL);
result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey);
if (verbose) printf ("SSL initialized\n");
if (result != STATE_OK)
die (STATE_CRITICAL, NULL);
microsec_ssl = deltime (tv_temp);
elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
if (check_cert == TRUE) {
result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
np_net_ssl_cleanup();
if (sd) close(sd);
np_net_ssl_cleanup();
return result;
}
}
#endif /* HAVE_SSL */
xasprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
&& host_name != NULL && use_ssl == TRUE)
asprintf (&buf, "%s %s %s\r\n%s\r\n", "GET", server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
else
asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
/* tell HTTP/1.1 servers not to keep the connection alive */
xasprintf (&buf, "%sConnection: close\r\n", buf);
/* check if Host header is explicitly set in options */
if (http_opt_headers_count) {
for (i = 0; i < http_opt_headers_count ; i++) {
if (strncmp(http_opt_headers[i], "Host:", 5) == 0) {
force_host_header = http_opt_headers[i];
}
}
}
/* optionally send the host header info */
if (host_name) {
/*
* Specify the port only if we're using a non-default port (see RFC 2616,
* 14.23). Some server applications/configurations cause trouble if the
* (default) port is explicitly specified in the "Host:" header line.
*/
if ((use_ssl == FALSE && server_port == HTTP_PORT) ||
(use_ssl == TRUE && server_port == HTTPS_PORT))
xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
else
xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
if (force_host_header) {
xasprintf (&buf, "%s%s\r\n", buf, force_host_header);
}
else {
/*
* Specify the port only if we're using a non-default port (see RFC 2616,
* 14.23). Some server applications/configurations cause trouble if the
* (default) port is explicitly specified in the "Host:" header line.
*/
if ((use_ssl == FALSE && virtual_port == HTTP_PORT) ||
(use_ssl == TRUE && virtual_port == HTTPS_PORT) ||
(server_address != NULL && strcmp(http_method, "CONNECT") == 0
&& host_name != NULL && use_ssl == TRUE))
xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
else
xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port);
}
}
/* optionally send any other header tag */
if (http_opt_headers_count) {
for (i = 0; i < http_opt_headers_count ; i++) {
xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]);
if (force_host_header != http_opt_headers[i]) {
xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]);
}
}
/* This cannot be free'd here because a redirection will then try to access this and segfault */
/* Covered in a testcase in tests/check_http.t */
@ -964,6 +1041,10 @@ check_http (void)
microsec_firstbyte = deltime (tv_temp);
elapsed_time_firstbyte = (double)microsec_firstbyte / 1.0e6;
}
while (pos = memchr(buffer, '\0', i)) {
/* replace nul character with a blank */
*pos = ' ';
}
buffer[i] = '\0';
xasprintf (&full_page_new, "%s%s", full_page, buffer);
free (full_page);
@ -1005,10 +1086,10 @@ check_http (void)
die (STATE_CRITICAL, _("HTTP CRITICAL - No data received from host\n"));
/* close the connection */
if (sd) close(sd);
#ifdef HAVE_SSL
np_net_ssl_cleanup();
#endif
if (sd) close(sd);
/* Save check time */
microsec = deltime (tv);
@ -1363,6 +1444,9 @@ redir (char *pos, char *status_line)
MAX_PORT, server_type, server_address, server_port, server_url,
display_html ? "</A>" : "");
/* reset virtual port */
virtual_port = server_port;
if (verbose)
printf (_("Redirection to %s://%s:%d%s\n"), server_type,
host_name ? host_name : server_address, server_port, server_url);
@ -1395,32 +1479,32 @@ char *perfd_time (double elapsed_time)
return fperfdata ("time", elapsed_time, "s",
thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0,
thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0,
TRUE, 0, FALSE, 0);
TRUE, 0, TRUE, socket_timeout);
}
char *perfd_time_connect (double elapsed_time_connect)
{
return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0);
return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
}
char *perfd_time_ssl (double elapsed_time_ssl)
{
return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0);
return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
}
char *perfd_time_headers (double elapsed_time_headers)
{
return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0);
return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
}
char *perfd_time_firstbyte (double elapsed_time_firstbyte)
{
return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0);
return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
}
char *perfd_time_transfer (double elapsed_time_transfer)
{
return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0);
return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
}
char *perfd_size (int page_len)
@ -1467,9 +1551,10 @@ print_help (void)
printf (UT_IPv46);
#ifdef HAVE_SSL
printf (" %s\n", "-S, --ssl=VERSION");
printf (" %s\n", "-S, --ssl=VERSION[+]");
printf (" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"));
printf (" %s\n", _("auto-negotiation (1 = TLSv1, 2 = SSLv2, 3 = SSLv3)."));
printf (" %s\n", _("auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"));
printf (" %s\n", _("1.2 = TLSv1.2). With a '+' suffix, newer versions are also accepted."));
printf (" %s\n", "--sni");
printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
@ -1496,7 +1581,7 @@ print_help (void)
printf (" %s\n", _("URL to GET or POST (default: /)"));
printf (" %s\n", "-P, --post=STRING");
printf (" %s\n", _("URL encoded http POST data"));
printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE)");
printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)");
printf (" %s\n", _("Set HTTP method."));
printf (" %s\n", "-N, --no-body");
printf (" %s\n", _("Don't wait for document body: stop reading after headers."));
@ -1570,7 +1655,7 @@ print_help (void)
printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,"));
printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than"));
printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"));
printf (" %s\n", _("the certificate is expired."));
printf (" %s\n\n", _("the certificate is expired."));
printf ("\n");
printf (" %s\n\n", "CHECK CERTIFICATE: check_http -H www.verisign.com -C 30,14");
printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 30 days,"));
@ -1578,6 +1663,13 @@ print_help (void)
printf (" %s\n", _("30 days, but more than 14 days, a STATE_WARNING is returned."));
printf (" %s\n", _("A STATE_CRITICAL will be returned when certificate expires in less than 14 days"));
printf (" %s\n\n", "CHECK SSL WEBSERVER CONTENT VIA PROXY USING HTTP 1.1 CONNECT: ");
printf (" %s\n", _("check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j CONNECT -H www.verisign.com "));
printf (" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -S(sl) -j CONNECT -H <webserver>"));
printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds"));
printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,"));
printf (" %s\n", _("a STATE_CRITICAL will be returned."));
#endif
printf (UT_SUPPORT);

View file

@ -166,7 +166,6 @@ enum SmartCommand
char *get_offline_text (int);
int smart_read_values (int, values_t *);
int values_not_passed (values_t *, thresholds_t *);
int nagios (values_t *, thresholds_t *);
void print_value (value_t *, threshold_t *);
void print_values (values_t *, thresholds_t *);
@ -234,10 +233,10 @@ main (int argc, char *argv[])
break;
case 'h':
print_help ();
return STATE_OK;
return STATE_UNKNOWN;
case 'V':
print_revision (progname, NP_VERSION);
return STATE_OK;
return STATE_UNKNOWN;
default:
usage5 ();
}
@ -249,7 +248,7 @@ main (int argc, char *argv[])
if (!device) {
print_help ();
return STATE_OK;
return STATE_UNKNOWN;
}
fd = open (device, OPEN_MODE);
@ -339,31 +338,6 @@ smart_read_values (int fd, values_t * values)
int
values_not_passed (values_t * p, thresholds_t * t)
{
value_t * value = p->values;
threshold_t * threshold = t->thresholds;
int failed = 0;
int passed = 0;
int i;
for (i = 0; i < NR_ATTRIBUTES; i++) {
if (value->id && threshold->id && value->id == threshold->id) {
if (value->value < threshold->threshold) {
++failed;
}
else {
++passed;
}
}
++value;
++threshold;
}
return (passed ? -failed : 2);
}
int
nagios (values_t * p, thresholds_t * t)
{

View file

@ -1,29 +1,29 @@
/*****************************************************************************
*
*
* Monitoring check_ldap plugin
*
*
* License: GPL
* Copyright (c) 2000-2008 Monitoring Plugins Development Team
*
*
* Description:
*
*
* This file contains the check_ldap 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/>.
*
*
*
*
*****************************************************************************/
/* progname may be check_ldaps */
@ -67,7 +67,10 @@ int ld_protocol = DEFAULT_PROTOCOL;
#endif
double warn_time = UNDEFINED;
double crit_time = UNDEFINED;
thresholds *entries_thresholds = NULL;
struct timeval tv;
char* warn_entries = NULL;
char* crit_entries = NULL;
int starttls = FALSE;
int ssl_on_connect = FALSE;
int verbose = 0;
@ -94,6 +97,12 @@ main (int argc, char *argv[])
int tls;
int version=3;
/* for entry counting */
LDAPMessage *next_entry;
int status_entries = STATE_OK;
int num_entries = 0;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
@ -197,12 +206,14 @@ main (int argc, char *argv[])
}
/* do a search of all objectclasses in the base dn */
if (ldap_search_s (ld, ld_base, LDAP_SCOPE_BASE, ld_attr, NULL, 0, &result)
if (ldap_search_s (ld, ld_base, (crit_entries!=NULL || warn_entries!=NULL) ? LDAP_SCOPE_SUBTREE : LDAP_SCOPE_BASE, ld_attr, NULL, 0, &result)
!= LDAP_SUCCESS) {
if (verbose)
ldap_perror(ld, "ldap_search");
printf (_("Could not search/find objectclasses in %s\n"), ld_base);
return STATE_CRITICAL;
} else if (crit_entries!=NULL || warn_entries!=NULL) {
num_entries = ldap_count_entries(ld, result);
}
/* unbind from the ldap server */
@ -223,14 +234,42 @@ main (int argc, char *argv[])
else
status = STATE_OK;
if(entries_thresholds != NULL) {
if (verbose) {
printf ("entries found: %d\n", num_entries);
print_thresholds("entry threasholds", entries_thresholds);
}
status_entries = get_status(num_entries, entries_thresholds);
if (status_entries == STATE_CRITICAL) {
status = STATE_CRITICAL;
} else if (status != STATE_CRITICAL) {
status = status_entries;
}
}
/* print out the result */
printf (_("LDAP %s - %.3f seconds response time|%s\n"),
state_text (status),
elapsed_time,
fperfdata ("time", elapsed_time, "s",
(int)warn_time, warn_time,
(int)crit_time, crit_time,
TRUE, 0, FALSE, 0));
if (crit_entries!=NULL || warn_entries!=NULL) {
printf (_("LDAP %s - found %d entries in %.3f seconds|%s %s\n"),
state_text (status),
num_entries,
elapsed_time,
fperfdata ("time", elapsed_time, "s",
(int)warn_time, warn_time,
(int)crit_time, crit_time,
TRUE, 0, FALSE, 0),
sperfdata ("entries", (double)num_entries, "",
warn_entries,
crit_entries,
TRUE, 0.0, FALSE, 0.0));
} else {
printf (_("LDAP %s - %.3f seconds response time|%s\n"),
state_text (status),
elapsed_time,
fperfdata ("time", elapsed_time, "s",
(int)warn_time, warn_time,
(int)crit_time, crit_time,
TRUE, 0, FALSE, 0));
}
return status;
}
@ -263,6 +302,8 @@ process_arguments (int argc, char **argv)
{"port", required_argument, 0, 'p'},
{"warn", required_argument, 0, 'w'},
{"crit", required_argument, 0, 'c'},
{"warn-entries", required_argument, 0, 'W'},
{"crit-entries", required_argument, 0, 'C'},
{"verbose", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
@ -276,7 +317,7 @@ process_arguments (int argc, char **argv)
}
while (1) {
c = getopt_long (argc, argv, "hvV234TS6t:c:w:H:b:p:a:D:P:", longopts, &option);
c = getopt_long (argc, argv, "hvV234TS6t:c:w:H:b:p:a:D:P:C:W:", longopts, &option);
if (c == -1 || c == EOF)
break;
@ -284,10 +325,10 @@ process_arguments (int argc, char **argv)
switch (c) {
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 't': /* timeout period */
if (!is_intnonneg (optarg))
usage2 (_("Timeout interval must be a positive integer"), optarg);
@ -318,6 +359,12 @@ process_arguments (int argc, char **argv)
case 'c':
crit_time = strtod (optarg, NULL);
break;
case 'W':
warn_entries = optarg;
break;
case 'C':
crit_entries = optarg;
break;
#ifdef HAVE_LDAP_SET_OPTION
case '2':
ld_protocol = 2;
@ -381,6 +428,10 @@ validate_arguments ()
if (ld_base==NULL)
usage4 (_("Please specify the LDAP base\n"));
if (crit_entries!=NULL || warn_entries!=NULL) {
set_thresholds(&entries_thresholds,
warn_entries, crit_entries);
}
return OK;
}
@ -430,6 +481,11 @@ print_help (void)
printf (UT_WARN_CRIT);
printf (" %s\n", "-W [--warn-entries]");
printf (" %s\n", _("Number of found entries to result in warning status"));
printf (" %s\n", "-C [--crit-entries]");
printf (" %s\n", _("Number of found entries to result in critical status"));
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
printf (UT_VERBOSE);
@ -441,6 +497,7 @@ print_help (void)
printf (" %s\n", _("'SSL on connect' will be used no matter how the plugin was called."));
printf (" %s\n", _("This detection is deprecated, please use 'check_ldap' with the '--starttls' or '--ssl' flags"));
printf (" %s\n", _("to define the behaviour explicitly instead."));
printf (" %s\n", _("The parameters --warn-entries and --crit-entries are optional."));
printf (UT_SUPPORT);
}

View file

@ -160,7 +160,7 @@ main (int argc, char **argv)
sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15);
}
else {
printf (_("could not parse load from uptime: %s\n"), result, PATH_TO_UPTIME);
printf (_("could not parse load from uptime %s: %s\n"), PATH_TO_UPTIME, result);
return STATE_UNKNOWN;
}
@ -251,10 +251,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case '?': /* help */
usage5 ();
}

View file

@ -234,10 +234,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case '?': /* help */
usage5 ();
}

View file

@ -148,37 +148,37 @@ main (int argc, char **argv)
/* report incoming traffic in Bytes/sec */
if (incoming_rate < 1024) {
strcpy (incoming_speed_rating, "B/s");
strcpy (incoming_speed_rating, "B");
adjusted_incoming_rate = (double) incoming_rate;
}
/* report incoming traffic in KBytes/sec */
else if (incoming_rate < (1024 * 1024)) {
strcpy (incoming_speed_rating, "KB/s");
strcpy (incoming_speed_rating, "KB");
adjusted_incoming_rate = (double) (incoming_rate / 1024.0);
}
/* report incoming traffic in MBytes/sec */
else {
strcpy (incoming_speed_rating, "MB/s");
strcpy (incoming_speed_rating, "MB");
adjusted_incoming_rate = (double) (incoming_rate / 1024.0 / 1024.0);
}
/* report outgoing traffic in Bytes/sec */
if (outgoing_rate < 1024) {
strcpy (outgoing_speed_rating, "B/s");
strcpy (outgoing_speed_rating, "B");
adjusted_outgoing_rate = (double) outgoing_rate;
}
/* report outgoing traffic in KBytes/sec */
else if (outgoing_rate < (1024 * 1024)) {
strcpy (outgoing_speed_rating, "KB/s");
strcpy (outgoing_speed_rating, "KB");
adjusted_outgoing_rate = (double) (outgoing_rate / 1024.0);
}
/* report outgoing traffic in MBytes/sec */
else {
strcpy (outgoing_speed_rating, "MB/s");
strcpy (outgoing_speed_rating, "MB");
adjusted_outgoing_rate = (double) (outgoing_rate / 1024.0 / 1024.0);
}
@ -191,7 +191,7 @@ main (int argc, char **argv)
result = STATE_WARNING;
}
xasprintf (&error_message, _("%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"),
xasprintf (&error_message, _("%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"),
(use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate,
incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"),
adjusted_outgoing_rate, outgoing_speed_rating,
@ -270,10 +270,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case '?': /* help */
usage5 ();
}

View file

@ -444,10 +444,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'v':
verbose++;
break;

View file

@ -250,10 +250,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'q':
xasprintf(&sql_query, "%s", optarg);
break;

View file

@ -235,10 +235,10 @@ process_arguments (int argc, char **argv)
switch (c) {
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'F': /* status log */
status_log = optarg;
break;

View file

@ -197,19 +197,40 @@ int main(int argc, char **argv){
case CHECK_UPTIME:
xasprintf(&send_buffer, "%s&3", req_password);
fetch_data (server_address, server_port, send_buffer);
uptime=strtoul(recv_buffer,NULL,10);
updays = uptime / 86400;
uphours = (uptime % 86400) / 3600;
upminutes = ((uptime % 86400) % 3600) / 60;
xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)|uptime=%lu"), updays, uphours, upminutes, uptime);
if (check_critical_value==TRUE && uptime <= critical_value)
return_code=STATE_CRITICAL;
else if (check_warning_value==TRUE && uptime <= warning_value)
return_code=STATE_WARNING;
else
return_code=STATE_OK;
if (value_list == NULL) {
value_list = "minutes";
}
if (strncmp(value_list, "seconds", strlen("seconds") + 1 ) &&
strncmp(value_list, "minutes", strlen("minutes") + 1) &&
strncmp(value_list, "hours", strlen("hours") + 1) &&
strncmp(value_list, "days", strlen("days") + 1)) {
output_message = strdup (_("wrong -l argument"));
} else {
xasprintf(&send_buffer, "%s&3", req_password);
fetch_data (server_address, server_port, send_buffer);
uptime=strtoul(recv_buffer,NULL,10);
updays = uptime / 86400;
uphours = (uptime % 86400) / 3600;
upminutes = ((uptime % 86400) % 3600) / 60;
if (!strncmp(value_list, "minutes", strlen("minutes")))
uptime = uptime / 60;
else if (!strncmp(value_list, "hours", strlen("hours")))
uptime = uptime / 3600;
else if (!strncmp(value_list, "days", strlen("days")))
uptime = uptime / 86400;
/* else uptime in seconds, nothing to do */
xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"),updays, uphours, upminutes, uptime);
if (check_critical_value==TRUE && uptime <= critical_value)
return_code=STATE_CRITICAL;
else if (check_warning_value==TRUE && uptime <= warning_value)
return_code=STATE_WARNING;
else
return_code=STATE_OK;
}
break;
case CHECK_USEDDISKSPACE:
@ -532,10 +553,10 @@ int process_arguments(int argc, char **argv){
usage5 ();
case 'h': /* help */
print_help();
exit(STATE_OK);
exit(STATE_UNKNOWN);
case 'V': /* version */
print_revision(progname, NP_VERSION);
exit(STATE_OK);
exit(STATE_UNKNOWN);
case 'H': /* hostname */
server_address = optarg;
break;
@ -713,7 +734,9 @@ void print_help(void)
printf (" %s\n", "ie: -l 60,90,95,120,90,95");
printf (" %s\n", "UPTIME =");
printf (" %s\n", _("Get the uptime of the machine."));
printf (" %s\n", _("No specific parameters. No warning or critical threshold"));
printf (" %s\n", _("-l <unit> "));
printf (" %s\n", _("<unit> = seconds, minutes, hours, or days. (default: minutes)"));
printf (" %s\n", _("Thresholds will use the unit specified above."));
printf (" %s\n", "USEDDISKSPACE =");
printf (" %s\n", _("Size and percentage of disk use."));
printf (" %s\n", _("Request a -l parameter containing the drive letter only."));

View file

@ -297,7 +297,7 @@ void setup_request(ntp_message *p){
* this is done by filtering servers based on stratum, dispersion, and
* finally round-trip delay. */
int best_offset_server(const ntp_server_results *slist, int nservers){
int i=0, cserver=0, best_server=-1;
int cserver=0, best_server=-1;
/* for each server */
for(cserver=0; cserver<nservers; cserver++){
@ -356,7 +356,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
* we have to do it in a way that our lazy macros don't handle currently :( */
double offset_request(const char *host, int *status){
int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
time_t now_time=0, start_ts=0;
ntp_message *req=NULL;
double avg_offset=0.;
@ -421,7 +421,6 @@ double offset_request(const char *host, int *status){
* been touched in the past second or so and is still lacking
* some responses. for each of these servers, send a new request,
* and update the "waiting" timestamp with the current time. */
one_written=0;
now_time=time(NULL);
for(i=0; i<num_hosts; i++){
@ -431,7 +430,6 @@ double offset_request(const char *host, int *status){
setup_request(&req[i]);
write(socklist[i], &req[i], sizeof(ntp_message));
servers[i].waiting=now_time;
one_written=1;
break;
}
}
@ -691,11 +689,11 @@ int process_arguments(int argc, char **argv){
switch (c) {
case 'h':
print_help();
exit(STATE_OK);
exit(STATE_UNKNOWN);
break;
case 'V':
print_revision(progname, NP_VERSION);
exit(STATE_OK);
exit(STATE_UNKNOWN);
break;
case 'v':
verbose++;

View file

@ -448,11 +448,11 @@ int process_arguments(int argc, char **argv){
switch (c) {
case 'h':
print_help();
exit(STATE_OK);
exit(STATE_UNKNOWN);
break;
case 'V':
print_revision(progname, NP_VERSION);
exit(STATE_OK);
exit(STATE_UNKNOWN);
break;
case 'v':
verbose++;

View file

@ -244,7 +244,7 @@ void setup_request(ntp_message *p){
* this is done by filtering servers based on stratum, dispersion, and
* finally round-trip delay. */
int best_offset_server(const ntp_server_results *slist, int nservers){
int i=0, cserver=0, best_server=-1;
int cserver=0, best_server=-1;
/* for each server */
for(cserver=0; cserver<nservers; cserver++){
@ -303,7 +303,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
* we have to do it in a way that our lazy macros don't handle currently :( */
double offset_request(const char *host, int *status){
int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
time_t now_time=0, start_ts=0;
ntp_message *req=NULL;
double avg_offset=0.;
@ -368,7 +368,6 @@ double offset_request(const char *host, int *status){
* been touched in the past second or so and is still lacking
* some responses. For each of these servers, send a new request,
* and update the "waiting" timestamp with the current time. */
one_written=0;
now_time=time(NULL);
for(i=0; i<num_hosts; i++){
@ -378,7 +377,6 @@ double offset_request(const char *host, int *status){
setup_request(&req[i]);
write(socklist[i], &req[i], sizeof(ntp_message));
servers[i].waiting=now_time;
one_written=1;
break;
}
}
@ -477,11 +475,11 @@ int process_arguments(int argc, char **argv){
switch (c) {
case 'h':
print_help();
exit(STATE_OK);
exit(STATE_UNKNOWN);
break;
case 'V':
print_revision(progname, NP_VERSION);
exit(STATE_OK);
exit(STATE_UNKNOWN);
break;
case 'v':
verbose++;
@ -635,7 +633,7 @@ 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", _("--time-offset is useful for compensating for servers with known"));
printf(" %s\n", _("and expected clock skew."));
printf("\n");
printf(UT_THRESHOLDS_NOTES);

View file

@ -1354,10 +1354,10 @@ int process_arguments(int argc, char **argv) {
usage5 ();
case 'h': /* help */
print_help();
exit(STATE_OK);
exit(STATE_UNKNOWN);
case 'V': /* version */
print_revision(progname, NP_VERSION);
exit(STATE_OK);
exit(STATE_UNKNOWN);
case 'H': /* hostname */
server_address=optarg;
break;

View file

@ -340,10 +340,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'H': /* hostname */
server_address = optarg;
break;

View file

@ -302,10 +302,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 't': /* timeout period */
if (!is_integer (optarg))
usage2 (_("Timeout interval must be a positive integer"), optarg);

View file

@ -224,11 +224,11 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
break;
case 't': /* timeout period */
timeout_interval = atoi (optarg);

View file

@ -428,10 +428,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 't': /* timeout period */
if (!is_integer (optarg))
usage2 (_("Timeout interval must be a positive integer"), optarg);

View file

@ -36,7 +36,9 @@ const char *email = "devel@monitoring-plugins.org";
#include "utils.h"
#include "netutils.h"
#if defined(HAVE_LIBFREERADIUS_CLIENT)
#if defined(HAVE_LIBRADCLI)
#include <radcli/radcli.h>
#elif defined(HAVE_LIBFREERADIUS_CLIENT)
#include <freeradius-client.h>
#elif defined(HAVE_LIBRADIUSCLIENT_NG)
#include <radiusclient-ng.h>
@ -48,22 +50,24 @@ int process_arguments (int, char **);
void print_help (void);
void print_usage (void);
#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
#define my_rc_conf_str(a) rc_conf_str(rch,a)
#if defined(HAVE_LIBRADCLI)
#define my_rc_send_server(a,b) rc_send_server(rch,a,b,AUTH)
#else
#define my_rc_send_server(a,b) rc_send_server(rch,a,b)
#ifdef HAVE_LIBFREERADIUS_CLIENT
#endif
#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADCLI)
#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f)
#else
#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
#endif
#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
#else
#define my_rc_conf_str(a) rc_conf_str(a)
#define my_rc_send_server(a,b) rc_send_server(a, b)
#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f)
#define my_rc_own_ipaddress() rc_own_ipaddress()
#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
#define my_rc_read_dictionary(a) rc_read_dictionary(a)
#endif
@ -76,7 +80,7 @@ void print_usage (void);
int my_rc_read_config(char *);
#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
rc_handle *rch = NULL;
#endif
@ -90,7 +94,6 @@ char *config_file = NULL;
unsigned short port = PW_AUTH_UDP_PORT;
int retries = 1;
int verbose = FALSE;
ENV *env = NULL;
/******************************************************************************
@ -150,6 +153,8 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
int
main (int argc, char **argv)
{
struct sockaddr_storage ss;
char name[HOST_NAME_MAX];
char msg[BUFFER_LEN];
SEND_DATA data;
int result = STATE_UNKNOWN;
@ -185,15 +190,14 @@ main (int argc, char **argv)
die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n"));
}
if (nasipaddress != NULL) {
if (rc_good_ipaddr (nasipaddress))
die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
if ((client_id = rc_get_ipaddr(nasipaddress)) == 0)
die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
} else {
if ((client_id = my_rc_own_ipaddress ()) == 0)
die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n"));
if (nasipaddress == NULL) {
if (gethostname (name, sizeof(name)) != 0)
die (STATE_UNKNOWN, _("gethostname() failed!\n"));
nasipaddress = name;
}
if (!dns_lookup (nasipaddress, &ss, AF_INET)) /* TODO: Support IPv6. */
die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
client_id = ntohl (((struct sockaddr_in *)&ss)->sin_addr.s_addr);
if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
@ -259,10 +263,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (OK);
exit (STATE_UNKNOWN);
case 'v': /* verbose mode */
verbose = TRUE;
break;
@ -274,7 +278,7 @@ process_arguments (int argc, char **argv)
break;
case 'P': /* port */
if (is_intnonneg (optarg))
port = atoi (optarg);
port = (unsigned short)atoi (optarg);
else
usage4 (_("Port must be a positive integer"));
break;
@ -310,7 +314,7 @@ process_arguments (int argc, char **argv)
break;
case 't': /* timeout */
if (is_intpos (optarg))
timeout_interval = atoi (optarg);
timeout_interval = (unsigned)atoi (optarg);
else
usage2 (_("Timeout interval must be a positive integer"), optarg);
break;
@ -399,7 +403,7 @@ print_usage (void)
int my_rc_read_config(char * a)
{
#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
rch = rc_read_config(a);
return (rch == NULL) ? 1 : 0;
#else

View file

@ -163,17 +163,17 @@ main (int argc, char **argv)
/* Part I - Server Check */
/* send the OPTIONS request */
sprintf (buffer, "DESCRIBE rtsp://%s:%d%s RTSP/1.0\n", host_name,
/* send the DESCRIBE request */
sprintf (buffer, "DESCRIBE rtsp://%s:%d%s RTSP/1.0\r\n", host_name,
server_port, server_url);
result = send (sd, buffer, strlen (buffer), 0);
/* send the header sync */
sprintf (buffer, "CSeq: 2\n");
sprintf (buffer, "CSeq: 2\r\n");
result = send (sd, buffer, strlen (buffer), 0);
/* send a newline so the server knows we're done with the request */
sprintf (buffer, "\n");
sprintf (buffer, "\r\n");
result = send (sd, buffer, strlen (buffer), 0);
/* watch for the REAL connection string */
@ -359,10 +359,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case '?': /* usage */
usage5 ();
}

View file

@ -59,10 +59,6 @@ enum {
#define SMTP_STARTTLS "STARTTLS\r\n"
#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
#ifndef HOST_MAX_BYTES
#define HOST_MAX_BYTES 255
#endif
#define EHLO_SUPPORTS_STARTTLS 1
int process_arguments (int, char **);
@ -128,6 +124,7 @@ main (int argc, char **argv)
char *cmd_str = NULL;
char *helocmd = NULL;
char *error_msg = "";
char *server_response = NULL;
struct timeval tv;
/* Catch pipe errors in read/write - sometimes occurs when writing QUIT */
@ -189,21 +186,9 @@ main (int argc, char **argv)
printf (_("recv() failed\n"));
return STATE_WARNING;
}
else {
if (verbose)
printf ("%s", buffer);
/* strip the buffer of carriage returns */
strip (buffer);
/* make sure we find the response we are looking for */
if (!strstr (buffer, server_expect)) {
if (server_port == SMTP_PORT)
printf (_("Invalid SMTP response received from host: %s\n"), buffer);
else
printf (_("Invalid SMTP response received from host on port %d: %s\n"),
server_port, buffer);
return STATE_WARNING;
}
}
/* save connect return (220 hostname ..) for later use */
xasprintf(&server_response, "%s", buffer);
/* send the HELO/EHLO command */
send(sd, helocmd, strlen(helocmd), 0);
@ -231,7 +216,7 @@ main (int argc, char **argv)
send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0);
recvlines(buffer, MAX_INPUT_BUFFER); /* wait for it */
if (!strstr (buffer, server_expect)) {
if (!strstr (buffer, SMTP_EXPECT)) {
printf (_("Server does not support STARTTLS\n"));
smtp_quit();
return STATE_UNKNOWN;
@ -239,8 +224,8 @@ main (int argc, char **argv)
result = np_net_ssl_init(sd);
if(result != STATE_OK) {
printf (_("CRITICAL - Cannot create SSL context.\n"));
np_net_ssl_cleanup();
close(sd);
np_net_ssl_cleanup();
return STATE_CRITICAL;
} else {
ssl_established = 1;
@ -276,6 +261,7 @@ main (int argc, char **argv)
# ifdef USE_OPENSSL
if ( check_cert ) {
result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
smtp_quit();
my_close();
return result;
}
@ -283,6 +269,24 @@ main (int argc, char **argv)
}
#endif
if (verbose)
printf ("%s", buffer);
/* save buffer for later use */
xasprintf(&server_response, "%s%s", server_response, buffer);
/* strip the buffer of carriage returns */
strip (server_response);
/* make sure we find the droids we are looking for */
if (!strstr (server_response, server_expect)) {
if (server_port == SMTP_PORT)
printf (_("Invalid SMTP response received from host: %s\n"), server_response);
else
printf (_("Invalid SMTP response received from host on port %d: %s\n"),
server_port, server_response);
return STATE_WARNING;
}
if (send_mail_from) {
my_send(cmd_str, strlen(cmd_str));
if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose)
@ -581,11 +585,6 @@ process_arguments (int argc, char **argv)
usage4 (_("Timeout interval must be a positive integer"));
}
break;
case 'S':
/* starttls */
use_ssl = TRUE;
use_ehlo = TRUE;
break;
case 'D':
/* Check SSL cert validity */
#ifdef USE_OPENSSL
@ -607,9 +606,14 @@ process_arguments (int argc, char **argv)
days_till_exp_warn = atoi (optarg);
}
check_cert = TRUE;
ignore_send_quit_failure = TRUE;
#else
usage (_("SSL support not available - install OpenSSL and recompile"));
#endif
case 'S':
/* starttls */
use_ssl = TRUE;
use_ehlo = TRUE;
break;
case '4':
address_family = AF_INET;
@ -623,10 +627,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case '?': /* help */
usage5 ();
}
@ -763,10 +767,12 @@ recvlines(char *buf, size_t bufsize)
int
my_close (void)
{
int result;
result = close(sd);
#ifdef HAVE_SSL
np_net_ssl_cleanup();
np_net_ssl_cleanup();
#endif
return close(sd);
return result;
}

View file

@ -103,6 +103,8 @@ int errcode, excode;
char *server_address = NULL;
char *community = NULL;
char **contextargs = NULL;
char *context = NULL;
char **authpriv = NULL;
char *proto = NULL;
char *seclevel = NULL;
@ -127,6 +129,7 @@ size_t nunits = 0;
size_t unitv_size = OID_COUNT_STEP;
int numoids = 0;
int numauthpriv = 0;
int numcontext = 0;
int verbose = 0;
int usesnmpgetnext = FALSE;
char *warning_thresholds = NULL;
@ -149,7 +152,7 @@ state_data *previous_state;
double *previous_value;
size_t previous_size = OID_COUNT_STEP;
int perf_labels = 1;
char* ip_version = "";
static char *fix_snmp_range(char *th)
{
@ -296,8 +299,8 @@ main (int argc, char **argv)
snmpcmd = strdup (PATH_TO_SNMPGET);
}
/* 10 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */
command_line = calloc (10 + numauthpriv + 1 + numoids + 1, sizeof (char *));
/* 10 arguments to pass before context and authpriv options + 1 for host and numoids. Add one for terminating NULL */
command_line = calloc (10 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *));
command_line[0] = snmpcmd;
command_line[1] = strdup ("-Le");
command_line[2] = strdup ("-t");
@ -309,23 +312,27 @@ main (int argc, char **argv)
command_line[8] = "-v";
command_line[9] = strdup (proto);
for (i = 0; i < numcontext; i++) {
command_line[10 + i] = contextargs[i];
}
for (i = 0; i < numauthpriv; i++) {
command_line[10 + i] = authpriv[i];
command_line[10 + numcontext + i] = authpriv[i];
}
xasprintf (&command_line[10 + numauthpriv], "%s:%s", server_address, port);
xasprintf (&command_line[10 + numcontext + numauthpriv], "%s:%s", server_address, port);
/* This is just for display purposes, so it can remain a string */
xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s:%s",
snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]",
xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s %s:%s",
snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[context]", "[authpriv]",
server_address, port);
for (i = 0; i < numoids; i++) {
command_line[10 + numauthpriv + 1 + i] = oids[i];
command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i];
xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
}
command_line[10 + numauthpriv + 1 + numoids] = NULL;
command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL;
if (verbose)
printf ("%s\n", cl_hidden_auth);
@ -410,6 +417,9 @@ main (int argc, char **argv)
else if (strstr (response, "INTEGER: ")) {
show = strstr (response, "INTEGER: ") + 9;
}
else if (strstr (response, "OID: ")) {
show = strstr (response, "OID: ") + 5;
}
else if (strstr (response, "STRING: ")) {
show = strstr (response, "STRING: ") + 8;
conv = "%.10g";
@ -566,6 +576,18 @@ main (int argc, char **argv)
len = sizeof(perfstr)-strlen(perfstr)-1;
strncat(perfstr, show, len>ptr-show ? ptr-show : len);
if (warning_thresholds) {
strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
}
if (critical_thresholds) {
if (!warning_thresholds)
strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
}
if (type)
strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
@ -645,6 +667,7 @@ process_arguments (int argc, char **argv)
{"retries", required_argument, 0, 'e'},
{"miblist", required_argument, 0, 'm'},
{"protocol", required_argument, 0, 'P'},
{"context", required_argument, 0, 'N'},
{"seclevel", required_argument, 0, 'L'},
{"secname", required_argument, 0, 'U'},
{"authproto", required_argument, 0, 'a'},
@ -657,6 +680,8 @@ process_arguments (int argc, char **argv)
{"offset", required_argument, 0, L_OFFSET},
{"invert-search", no_argument, 0, L_INVERT_SEARCH},
{"perf-oids", no_argument, 0, 'O'},
{"ipv4", no_argument, 0, '4'},
{"ipv6", no_argument, 0, '6'},
{0, 0, 0, 0}
};
@ -674,7 +699,7 @@ process_arguments (int argc, char **argv)
}
while (1) {
c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:",
c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:",
longopts, &option);
if (c == -1 || c == EOF)
@ -685,10 +710,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'v': /* verbose */
verbose++;
break;
@ -712,6 +737,9 @@ process_arguments (int argc, char **argv)
case 'P': /* SNMP protocol version */
proto = optarg;
break;
case 'N': /* SNMPv3 context */
context = optarg;
break;
case 'L': /* security level */
seclevel = optarg;
break;
@ -896,6 +924,13 @@ process_arguments (int argc, char **argv)
case 'O':
perf_labels=0;
break;
case '4':
break;
case '6':
xasprintf(&ip_version, "udp6:");
if(verbose>2)
printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n");
break;
}
}
@ -959,6 +994,13 @@ validate_arguments ()
authpriv[1] = strdup (community);
}
else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */
if (!(context == NULL)) {
numcontext = 2;
contextargs = calloc (numcontext, sizeof (char *));
contextargs[0] = strdup ("-n");
contextargs[1] = strdup (context);
}
if (seclevel == NULL)
xasprintf(&seclevel, "noAuthNoPriv");
@ -1094,6 +1136,7 @@ print_help (void)
printf (UT_HELP_VRSN);
printf (UT_EXTRA_OPTS);
printf (UT_IPv46);
printf (UT_HOST_PORT, 'p', DEFAULT_PORT);
@ -1102,6 +1145,8 @@ print_help (void)
printf (" %s\n", _("Use SNMP GETNEXT instead of SNMP GET"));
printf (" %s\n", "-P, --protocol=[1|2c|3]");
printf (" %s\n", _("SNMP protocol version"));
printf (" %s\n", "-N, --context=CONTEXT");
printf (" %s\n", _("SNMPv3 context"));
printf (" %s\n", "-L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]");
printf (" %s\n", _("SNMPv3 securityLevel"));
printf (" %s\n", "-a, --authproto=[MD5|SHA]");
@ -1209,6 +1254,6 @@ print_usage (void)
printf ("%s -H <ip_address> -o <OID> [-w warn_range] [-c crit_range]\n",progname);
printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n");
printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
printf ("[-m miblist] [-P snmp version] [-L seclevel] [-U secname] [-a authproto]\n");
printf ("[-A authpasswd] [-x privproto] [-X privpasswd]\n");
printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
}

View file

@ -128,10 +128,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'v': /* verbose */
verbose = TRUE;
break;
@ -253,18 +253,18 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol
if (remote_version && strcmp(remote_version, ssh_server)) {
printf
(_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"),
(_("SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"),
ssh_server, ssh_proto, remote_version);
close(sd);
exit (STATE_WARNING);
exit (STATE_CRITICAL);
}
if (remote_protocol && strcmp(remote_protocol, ssh_proto)) {
printf
(_("SSH WARNING - %s (protocol %s) protocol version mismatch, expected '%s'\n"),
(_("SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"),
ssh_server, ssh_proto, remote_protocol);
close(sd);
exit (STATE_WARNING);
exit (STATE_CRITICAL);
}
elapsed_time = (double)deltime(tv) / 1.0e6;
@ -307,10 +307,10 @@ print_help (void)
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
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", _("Alert 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 (" %s\n", _("Alert if protocol doesn't match expected protocol version (ex: 2.0)"));
printf (UT_VERBOSE);

View file

@ -1,6 +1,6 @@
/*****************************************************************************
*
* Monitoring check_disk plugin
* Monitoring check_swap plugin
*
* License: GPL
* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
@ -352,6 +352,7 @@ main (int argc, char **argv)
percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb);
} else {
percent_used = 100;
status = "- Swap is either disabled, not present, or of zero size. ";
}
result = max_state (result, check_swap (percent_used, free_swap_mb));
@ -469,10 +470,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case '?': /* error */
usage5 ();
}

View file

@ -237,7 +237,7 @@ main (int argc, char **argv)
gettimeofday (&tv, NULL);
result = np_net_connect (server_address, server_port, &sd, PROTOCOL);
if (result == STATE_CRITICAL) return STATE_CRITICAL;
if (result == STATE_CRITICAL) return econn_refuse_state;
#ifdef HAVE_SSL
if (flags & FLAG_SSL){
@ -247,8 +247,8 @@ main (int argc, char **argv)
}
}
if(result != STATE_OK){
np_net_ssl_cleanup();
if(sd) close(sd);
np_net_ssl_cleanup();
return result;
}
#endif /* HAVE_SSL */
@ -321,10 +321,10 @@ main (int argc, char **argv)
if (server_quit != NULL) {
my_send(server_quit, strlen(server_quit));
}
if (sd) close (sd);
#ifdef HAVE_SSL
np_net_ssl_cleanup();
#endif
if (sd) close (sd);
microsec = deltime (tv);
elapsed_time = (double)microsec / 1.0e6;
@ -463,10 +463,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'v': /* verbose mode */
flags |= FLAG_VERBOSE;
match_flags |= NP_MATCH_VERBOSE;
@ -577,7 +577,8 @@ process_arguments (int argc, char **argv)
if ((temp=strchr(optarg,','))!=NULL) {
*temp='\0';
if (!is_intnonneg (optarg))
usage2 (_("Invalid certificate expiration period"), optarg); days_till_exp_warn = atoi(optarg);
usage2 (_("Invalid certificate expiration period"), optarg);
days_till_exp_warn = atoi (optarg);
*temp=',';
temp++;
if (!is_intnonneg (temp))

View file

@ -231,10 +231,10 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'H': /* hostname */
if (is_host (optarg) == FALSE)
usage2 (_("Invalid hostname/address"), optarg);

View file

@ -558,10 +558,10 @@ process_arguments (int argc, char **argv)
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
}
}

View file

@ -54,15 +54,15 @@ int process_arguments (int, char **);
void print_help (void);
void print_usage (void);
int wusers = -1;
int cusers = -1;
char *warning_range = NULL;
char *critical_range = NULL;
thresholds *thlds = NULL;
int
main (int argc, char **argv)
{
int users = -1;
int result = STATE_UNKNOWN;
char *perf;
#if HAVE_WTSAPI32_H
WTS_SESSION_INFO *wtsinfo;
DWORD wtscount;
@ -77,8 +77,6 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
perf = strdup ("");
/* Parse extra opts if any */
argv = np_extra_opts (&argc, argv, progname);
@ -160,23 +158,15 @@ main (int argc, char **argv)
#endif
/* check the user count against warning and critical thresholds */
if (users > cusers)
result = STATE_CRITICAL;
else if (users > wusers)
result = STATE_WARNING;
else if (users >= 0)
result = STATE_OK;
result = get_status((double)users, thlds);
if (result == STATE_UNKNOWN)
printf ("%s\n", _("Unable to read output"));
else {
xasprintf (&perf, "%s", perfdata ("users", users, "",
TRUE, wusers,
TRUE, cusers,
TRUE, 0,
FALSE, 0));
printf (_("USERS %s - %d users currently logged in |%s\n"), state_text (result),
users, perf);
printf (_("USERS %s - %d users currently logged in |%s\n"),
state_text(result), users,
sperfdata_int("users", users, "", warning_range,
critical_range, TRUE, 0, FALSE, 0));
}
return result;
@ -210,38 +200,32 @@ process_arguments (int argc, char **argv)
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
exit (STATE_UNKNOWN);
case 'c': /* critical */
if (!is_intnonneg (optarg))
usage4 (_("Critical threshold must be a positive integer"));
else
cusers = atoi (optarg);
critical_range = optarg;
break;
case 'w': /* warning */
if (!is_intnonneg (optarg))
usage4 (_("Warning threshold must be a positive integer"));
else
wusers = atoi (optarg);
warning_range = optarg;
break;
}
}
c = optind;
if (wusers == -1 && argc > c) {
if (is_intnonneg (argv[c]) == FALSE)
usage4 (_("Warning threshold must be a positive integer"));
else
wusers = atoi (argv[c++]);
}
if (cusers == -1 && argc > c) {
if (is_intnonneg (argv[c]) == FALSE)
usage4 (_("Warning threshold must be a positive integer"));
else
cusers = atoi (argv[c]);
}
if (warning_range == NULL && argc > c)
warning_range = argv[c++];
if (critical_range == NULL && argc > c)
critical_range = argv[c++];
/* this will abort in case of invalid ranges */
set_thresholds (&thlds, warning_range, critical_range);
if (thlds->warning->end < 0)
usage4 (_("Warning threshold must be a positive integer"));
if (thlds->critical->end < 0)
usage4 (_("Critical threshold must be a positive integer"));
return OK;
}

View file

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

View file

@ -59,8 +59,8 @@ static int state[4] = {
int
main (int argc, char **argv)
{
int found = 0, result = STATE_UNKNOWN;
char *buf, *sub;
int result = STATE_UNKNOWN;
char *sub;
char **command_line;
output chld_out, chld_err;
int i;

View file

@ -161,6 +161,10 @@ process_request (const char *server_address, int server_port, int proto,
int
np_net_connect (const char *host_name, int port, int *sd, int proto)
{
/* send back STATE_UNKOWN if there's an error
send back STATE_OK if we connect
send back STATE_CRITICAL if we can't connect.
Let upstream figure out what to send to the user. */
struct addrinfo hints;
struct addrinfo *r, *res;
struct sockaddr_un su;
@ -250,16 +254,14 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
else if (was_refused) {
switch (econn_refuse_state) { /* a user-defined expected outcome */
case STATE_OK:
case STATE_WARNING: /* user wants WARN or OK on refusal */
return econn_refuse_state;
break;
case STATE_CRITICAL: /* user did not set econn_refuse_state */
case STATE_WARNING: /* user wants WARN or OK on refusal, or... */
case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */
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;
return STATE_CRITICAL;
break;
default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
return STATE_UNKNOWN;
@ -357,20 +359,21 @@ is_addr (const char *address)
}
int
resolve_host_or_addr (const char *address, int family)
dns_lookup (const char *in, struct sockaddr_storage *ss, int family)
{
struct addrinfo hints;
struct addrinfo *res;
int retval;
memset (&hints, 0, sizeof (hints));
memset (&hints, 0, sizeof(struct addrinfo));
hints.ai_family = family;
retval = getaddrinfo (address, NULL, &hints, &res);
retval = getaddrinfo (in, NULL, &hints, &res);
if (retval != 0)
return FALSE;
else {
freeaddrinfo (res);
return TRUE;
}
if (ss != NULL)
memcpy (ss, res->ai_addr, res->ai_addrlen);
freeaddrinfo (res);
return TRUE;
}

View file

@ -45,6 +45,10 @@
# endif /* UNIX_PATH_MAX */
#endif /* HAVE_SYS_UN_H */
#ifndef HOST_MAX_BYTES
# define HOST_MAX_BYTES 255
#endif
/* process_request and wrapper macros */
#define process_tcp_request(addr, port, sbuf, rbuf, rsize) \
process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize)
@ -71,8 +75,9 @@ int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer,
/* "is_*" wrapper macros and functions */
int is_host (const char *);
int is_addr (const char *);
int resolve_host_or_addr (const char *, int);
int dns_lookup (const char *, struct sockaddr_storage *, int);
void host_or_die(const char *str);
#define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family)
#define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET)
#ifdef USE_IPV6
# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6)
@ -91,6 +96,16 @@ RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn));
/* SSL-Related functionality */
#ifdef HAVE_SSL
# define MP_SSLv2 1
# define MP_SSLv3 2
# define MP_TLSv1 3
# define MP_TLSv1_1 4
# define MP_TLSv1_2 5
# define MP_SSLv2_OR_NEWER 6
# define MP_SSLv3_OR_NEWER 7
# define MP_TLSv1_OR_NEWER 8
# define MP_TLSv1_1_OR_NEWER 9
# define MP_TLSv1_2_OR_NEWER 10
/* maybe this could be merged with the above np_net_connect, via some flags */
int np_net_ssl_init(int sd);
int np_net_ssl_init_with_hostname(int sd, char *host_name);

View file

@ -48,34 +48,79 @@ int np_net_ssl_init_with_hostname_and_version(int sd, char *host_name, int versi
}
int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int version, char *cert, char *privkey) {
SSL_METHOD *method = NULL;
const SSL_METHOD *method = NULL;
long options = 0;
switch (version) {
case 0: /* Deafult to auto negotiation */
method = SSLv23_client_method();
break;
case 1: /* TLSv1 protocol */
method = TLSv1_client_method();
break;
case 2: /* SSLv2 protocol */
case MP_SSLv2: /* SSLv2 protocol */
#if defined(USE_GNUTLS) || defined(OPENSSL_NO_SSL2)
printf("%s\n", _("CRITICAL - SSL protocol version 2 is not supported by your SSL library."));
return STATE_CRITICAL;
printf("%s\n", _("UNKNOWN - SSL protocol version 2 is not supported by your SSL library."));
return STATE_UNKNOWN;
#else
method = SSLv2_client_method();
#endif
break;
case 3: /* SSLv3 protocol */
#endif
case MP_SSLv3: /* SSLv3 protocol */
#if defined(OPENSSL_NO_SSL3)
printf("%s\n", _("CRITICAL - SSL protocol version 3 is not supported by your SSL library."));
return STATE_CRITICAL;
printf("%s\n", _("UNKNOWN - SSL protocol version 3 is not supported by your SSL library."));
return STATE_UNKNOWN;
#else
method = SSLv3_client_method();
#endif
break;
default: /* Unsupported */
printf("%s\n", _("CRITICAL - Unsupported SSL protocol version."));
return STATE_CRITICAL;
#endif
case MP_TLSv1: /* TLSv1 protocol */
#if defined(OPENSSL_NO_TLS1)
printf("%s\n", _("UNKNOWN - TLS protocol version 1 is not supported by your SSL library."));
return STATE_UNKNOWN;
#else
method = TLSv1_client_method();
break;
#endif
case MP_TLSv1_1: /* TLSv1.1 protocol */
#if !defined(SSL_OP_NO_TLSv1_1)
printf("%s\n", _("UNKNOWN - TLS protocol version 1.1 is not supported by your SSL library."));
return STATE_UNKNOWN;
#else
method = TLSv1_1_client_method();
break;
#endif
case MP_TLSv1_2: /* TLSv1.2 protocol */
#if !defined(SSL_OP_NO_TLSv1_2)
printf("%s\n", _("UNKNOWN - TLS protocol version 1.2 is not supported by your SSL library."));
return STATE_UNKNOWN;
#else
method = TLSv1_2_client_method();
break;
#endif
case MP_TLSv1_2_OR_NEWER:
#if !defined(SSL_OP_NO_TLSv1_1)
printf("%s\n", _("UNKNOWN - Disabling TLSv1.1 is not supported by your SSL library."));
return STATE_UNKNOWN;
#else
options |= SSL_OP_NO_TLSv1_1;
#endif
/* FALLTHROUGH */
case MP_TLSv1_1_OR_NEWER:
#if !defined(SSL_OP_NO_TLSv1)
printf("%s\n", _("UNKNOWN - Disabling TLSv1 is not supported by your SSL library."));
return STATE_UNKNOWN;
#else
options |= SSL_OP_NO_TLSv1;
#endif
/* FALLTHROUGH */
case MP_TLSv1_OR_NEWER:
#if defined(SSL_OP_NO_SSLv3)
options |= SSL_OP_NO_SSLv3;
#endif
/* FALLTHROUGH */
case MP_SSLv3_OR_NEWER:
#if defined(SSL_OP_NO_SSLv2)
options |= SSL_OP_NO_SSLv2;
#endif
case MP_SSLv2_OR_NEWER:
/* FALLTHROUGH */
default: /* Default to auto negotiation */
method = SSLv23_client_method();
}
if (!initialized) {
/* Initialize SSL context */
@ -99,8 +144,9 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
#endif
}
#ifdef SSL_OP_NO_TICKET
SSL_CTX_set_options(c, SSL_OP_NO_TICKET);
options |= SSL_OP_NO_TICKET;
#endif
SSL_CTX_set_options(c, options);
SSL_CTX_set_mode(c, SSL_MODE_AUTO_RETRY);
if ((s = SSL_new(c)) != NULL) {
#ifdef SSL_set_tlsext_host_name
@ -149,7 +195,10 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
# ifdef USE_OPENSSL
X509 *certificate=NULL;
X509_NAME *subj=NULL;
char timestamp[50] = "";
char cn[MAX_CN_LENGTH]= "";
char *tz;
int cnlen =-1;
int status=STATE_UNKNOWN;
@ -158,7 +207,7 @@ 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[50] = "";
int time_remaining;
time_t tm_t;
certificate=SSL_get_peer_certificate(s);
@ -212,32 +261,55 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
(tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0');
stamp.tm_min =
(tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0');
stamp.tm_sec = 0;
stamp.tm_sec =
(tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0');
stamp.tm_isdst = -1;
time_left = difftime(timegm(&stamp), time(NULL));
tm_t = timegm(&stamp);
time_left = difftime(tm_t, time(NULL));
days_left = time_left / 86400;
tm_t = mktime (&stamp);
strftime(timestamp, 50, "%c", localtime(&tm_t));
tz = getenv("TZ");
setenv("TZ", "GMT", 1);
tzset();
strftime(timestamp, 50, "%c %z", localtime(&tm_t));
if (tz)
setenv("TZ", tz, 1);
else
unsetenv("TZ");
tzset();
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);
if (days_left > days_till_exp_crit)
return STATE_WARNING;
status = STATE_WARNING;
else
return STATE_CRITICAL;
status = STATE_CRITICAL;
} else if (days_left == 0 && time_left > 0) {
if (time_left >= 3600)
time_remaining = (int) time_left / 3600;
else
time_remaining = (int) time_left / 60;
printf (_("%s - Certificate '%s' expires in %u %s (%s)\n"),
(days_left>days_till_exp_crit) ? "WARNING" : "CRITICAL", cn, time_remaining,
time_left >= 3600 ? "hours" : "minutes", timestamp);
if ( days_left > days_till_exp_crit)
status = STATE_WARNING;
else
status = STATE_CRITICAL;
} else if (time_left < 0) {
printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), cn, timestamp);
status=STATE_CRITICAL;
} else if (days_left == 0) {
printf (_("%s - Certificate '%s' expires today (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, timestamp);
printf (_("%s - Certificate '%s' just expired (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, timestamp);
if (days_left > days_till_exp_crit)
return STATE_WARNING;
status = STATE_WARNING;
else
return STATE_CRITICAL;
status = STATE_CRITICAL;
} else {
printf(_("OK - Certificate '%s' will expire on %s.\n"), cn, timestamp);
status=STATE_OK;
status = STATE_OK;
}
X509_free(certificate);
return status;

View file

@ -11,7 +11,7 @@
'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
'NP_HOST_RESPONSIVE' => 'localhost',
'NP_HOST_SMB' => '',
'NP_HOST_SNMP' => '',
'NP_HOST_SNMP' => 'localhost',
'NP_HOST_TCP_FTP' => '',
'NP_HOST_TCP_HPJD' => '',
'NP_HOST_HPJD_PORT_INVALID' => '161',
@ -19,12 +19,14 @@
'NP_HOST_TCP_HTTP' => 'localhost',
'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org',
'NP_HOST_TCP_IMAP' => 'imap.web.de',
'NP_HOST_TCP_LDAP' => 'localhost',
'NP_HOST_TCP_POP' => 'pop.web.de',
'NP_HOST_TCP_SMTP' => 'localhost',
'NP_HOST_TCP_SMTP_NOTLS' => '',
'NP_HOST_TCP_SMTP_TLS' => '',
'NP_INTERNET_ACCESS' => 'yes',
'NP_MOUNTPOINT2_VALID' => '',
'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain',
'NP_MOUNTPOINT2_VALID' => '/media/ramdisk',
'NP_MOUNTPOINT_VALID' => '/',
'NP_MYSQL_SERVER' => 'localhost',
'NP_HOST_UDP_TIME' => 'localhost',
@ -37,7 +39,7 @@
'NP_SMB_SHARE_SPC' => '',
'NP_SMB_VALID_USER' => '',
'NP_SMB_VALID_USER_PASS' => '',
'NP_SNMP_COMMUNITY' => '',
'NP_SNMP_COMMUNITY' => 'public',
'NP_SSH_CONFIGFILE' => '~/.ssh/config',
'NP_SSH_HOST' => 'localhost',
'NP_SSH_IDENTITY' => '~/.ssh/id_dsa',

View file

@ -6,9 +6,10 @@
use strict;
use Test::More;
use POSIX qw/mktime strftime/;
use NPTest;
plan tests => 30;
plan tests => 49;
my $successOutput = '/OK.*HTTP.*second/';
@ -34,6 +35,8 @@ my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
"A host providing an index page containing the string 'monitoring'",
"test.monitoring-plugins.org" );
my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
$res = NPTest->testCmd(
"./check_http $host_tcp_http -wt 300 -ct 600"
@ -47,10 +50,10 @@ $res = NPTest->testCmd(
like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
$res = NPTest->testCmd(
"./check_http $host_nonresponsive -wt 1 -ct 2"
"./check_http $host_nonresponsive -wt 1 -ct 2 -t 3"
);
cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 10 seconds", "Output OK");
cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 3 seconds", "Output OK");
$res = NPTest->testCmd(
"./check_http $hostname_invalid -wt 1 -ct 2"
@ -61,6 +64,32 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
# Is also possible to get a socket timeout if DNS is not responding fast enough
like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
# host header checks
$res = NPTest->testCmd("./check_http -v -H $host_tcp_http");
like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
$res = NPTest->testCmd("./check_http -v -H $host_tcp_http -p 80");
like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
SKIP: {
skip "No internet access", 3 if $internet_access eq "no";
$res = NPTest->testCmd("./check_http -v -H www.verisign.com -S");
like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
$res = NPTest->testCmd("./check_http -v -H www.verisign.com:8080 -S -p 443");
like( $res->output, '/^Host: www.verisign.com:8080\s*$/ms', "Host Header OK" );
$res = NPTest->testCmd("./check_http -v -H www.verisign.com:443 -S -p 443");
like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
};
SKIP: {
skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
@ -112,12 +141,46 @@ SKIP: {
$res = NPTest->testCmd( "./check_http www.verisign.com -C 1" );
cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
# run some certificate checks with faketime
SKIP: {
skip "No faketime binary found", 12 if !$faketime;
$res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com");
like($res->output, qr/OK - Certificate 'www.verisign.com' will expire on/, "Catch cert output");
is( $res->return_code, 0, "Catch cert output exit code" );
my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/);
if(!defined $year) {
die("parsing date failed from: ".$res->output);
}
my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11};
my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900);
my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts));
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_http -C 1 www.verisign.com");
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' just expired/, "Output on expire date");
is( $res->return_code, 2, "Output on expire date" );
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./check_http -C 1 www.verisign.com");
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 0 minutes/, "cert expires in 1 second output");
is( $res->return_code, 2, "cert expires in 1 second exit code" );
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./check_http -C 1 www.verisign.com");
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 minutes/, "cert expires in 2 minutes output");
is( $res->return_code, 2, "cert expires in 2 minutes exit code" );
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./check_http -C 1 www.verisign.com");
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 hours/, "cert expires in 2 hours output");
is( $res->return_code, 2, "cert expires in 2 hours exit code" );
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_http -C 1 www.verisign.com");
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expired on/, "Certificate expired output");
is( $res->return_code, 2, "Certificate expired exit code" );
};
$res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" );
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
$res = NPTest->testCmd(
"./check_http --ssl www.e-paycobalt.com"
"./check_http --ssl -H www.e-paycobalt.com"
);
cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );

80
plugins/t/check_ldap.t Normal file
View file

@ -0,0 +1,80 @@
#!/usr/bin/env perl -I ..
#
# Lightweight Directory Access Protocol (LDAP) Test via check_ldap
#
#
use strict;
use warnings;
use Test::More;
use NPTest;
my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP",
"A host providing the LDAP Service",
"localhost" );
my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN",
"A base dn for the LDAP Service",
"cn=admin" );
my $host_nonresponsive = getTestParameter("host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
"The hostname of system not responsive to network requests" );
my $hostname_invalid = getTestParameter("hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
"An invalid (not known to DNS) hostname" );
my($result, $cmd);
my $command = './check_ldap';
plan tests => 16;
SKIP: {
skip "NP_HOST_NONRESPONSIVE not set", 2 if ! $host_nonresponsive;
$result = NPTest->testCmd("$command -H $host_nonresponsive -b ou=blah -t 2 -w 1 -c 1");
is( $result->return_code, 2, "$command -H $host_nonresponsive -b ou=blah -t 5 -w 2 -c 3" );
is( $result->output, 'CRITICAL - Socket timeout after 2 seconds', "output ok" );
};
SKIP: {
skip "NP_HOSTNAME_INVALID not set", 2 if ! $hostname_invalid;
$result = NPTest->testCmd("$command -H $hostname_invalid -b ou=blah -t 5");
is( $result->return_code, 2, "$command -H $hostname_invalid -b ou=blah -t 5" );
is( $result->output, 'Could not bind to the LDAP server', "output ok" );
};
SKIP: {
skip "NP_HOST_TCP_LDAP not set", 12 if ! $host_tcp_ldap;
skip "NP_LDAP_BASE_DN not set", 12 if ! $ldap_base_dn;
$cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3";
$result = NPTest->testCmd($cmd);
is( $result->return_code, 0, $cmd );
like( $result->output, '/^LDAP OK - \d+.\d+ seconds response time\|time=\d+\.\d+s;2\.0+;3\.0+;0\.0+$/', "output ok" );
$cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000 -C 10000001";
$result = NPTest->testCmd($cmd);
is( $result->return_code, 0, $cmd );
like( $result->output, '/^LDAP OK - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000;10000001;0\.0+$/', "output ok" );
$cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001:";
$result = NPTest->testCmd($cmd);
is( $result->return_code, 2, $cmd );
like( $result->output, '/^LDAP CRITICAL - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000:;10000001:;0\.0+$/', "output ok" );
$cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 0 -C 0";
$result = NPTest->testCmd($cmd);
is( $result->return_code, 2, $cmd );
like( $result->output, '/^LDAP CRITICAL - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;0;0;0\.0+$/', "output ok" );
$cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001";
$result = NPTest->testCmd($cmd);
is( $result->return_code, 1, $cmd );
like( $result->output, '/^LDAP WARNING - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000:;10000001;0\.0+$/', "output ok" );
$cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -C 10000001";
$result = NPTest->testCmd($cmd);
is( $result->return_code, 0, $cmd );
like( $result->output, '/^LDAP OK - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;;10000001;0\.0+$/', "output ok" );
};

View file

@ -10,7 +10,7 @@ use NPTest;
BEGIN {
plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp";
plan tests => 61;
plan tests => 63;
}
my $res;
@ -45,7 +45,7 @@ is( $res->return_code, 3, "Invalid protocol" );
like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
SKIP: {
skip "no snmp host defined", 48 if ( ! $host_snmp );
skip "no snmp host defined", 50 if ( ! $host_snmp );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" );
@ -153,6 +153,10 @@ SKIP: {
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0");
cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
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");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunParameters.1");
cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
is( $res->output, 'SNMP OK - "" | ', "snmp response without datatype" );
}
SKIP: {

View file

@ -13,7 +13,7 @@ use Test;
use NPTest;
use vars qw($tests);
BEGIN {$tests = 4; plan tests => $tests}
BEGIN {$tests = 8; plan tests => $tests}
my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/';
my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/';
@ -22,6 +22,8 @@ my $t;
$t += checkCmd( "./check_users 1000 1000", 0, $successOutput );
$t += checkCmd( "./check_users 0 0", 2, $failureOutput );
$t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput );
$t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput );
exit(0) if defined($Test::Harness::VERSION);
exit($tests - $t);

View file

@ -17,6 +17,8 @@ use Test::More;
use NPTest;
use FindBin qw($Bin);
$ENV{'LC_TIME'} = "C";
my $common_tests = 70;
my $ssl_only_tests = 8;
# Check that all dependent modules are available
@ -186,21 +188,21 @@ SKIP: {
$result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:00 2019.', "output ok" );
is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:28 2019 +0000.', "output ok" );
$result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" );
like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "output ok" );
# Expired cert tests
$result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" );
like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "output ok" );
$result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
is( $result->output,
'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:00 2009.',
'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009 +0000.',
"output ok" );
}

View file

@ -128,7 +128,7 @@ sleep 1;
$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.10 --rate -w 600" );
is($res->return_code, 1, "WARNING - due to going above rate calculation" );
is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666 ");
is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666;600 ");
$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.10 --rate -w 600" );
is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" );
@ -209,7 +209,7 @@ is($res->output, 'SNMP OK - "stringtests" | ', "OK as inverted string no match"
$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.12 -w 4:5" );
is($res->return_code, 1, "Numeric in string test" );
is($res->output, 'SNMP WARNING - *3.5* | iso.3.6.1.4.1.8072.3.2.67.12=3.5 ', "WARNING threshold checks for string masquerading as number" );
is($res->output, 'SNMP WARNING - *3.5* | iso.3.6.1.4.1.8072.3.2.67.12=3.5;4:5 ', "WARNING threshold checks for string masquerading as number" );
$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.13" );
is($res->return_code, 0, "Not really numeric test" );
@ -225,29 +225,29 @@ is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check w
$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" );
is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2;-2:;-3: ', "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" );
is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3;-2:;-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" );
is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4;-2:;-3: ', "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" );
is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-3:;-6: ', "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" );
is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-2:;-3: ', "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" );
$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" );
is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;~:-6.5 ', "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" );
$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" );
is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;~:-6.65;~:-6.55 ', "Negative float WARNING output" );

View file

@ -144,8 +144,6 @@ usage5 (void)
void
print_revision (const char *command_name, const char *revision)
{
char plugin_revision[STRLEN];
printf ("%s v%s (%s %s)\n",
command_name, revision, PACKAGE, VERSION);
}
@ -630,3 +628,84 @@ char *fperfdata (const char *label,
return data;
}
char *sperfdata (const char *label,
double val,
const char *uom,
char *warn,
char *crit,
int minp,
double minv,
int maxp,
double maxv)
{
char *data = NULL;
if (strpbrk (label, "'= "))
xasprintf (&data, "'%s'=", label);
else
xasprintf (&data, "%s=", label);
xasprintf (&data, "%s%f", data, val);
xasprintf (&data, "%s%s;", data, uom);
if (warn!=NULL)
xasprintf (&data, "%s%s", data, warn);
xasprintf (&data, "%s;", data);
if (crit!=NULL)
xasprintf (&data, "%s%s", data, crit);
xasprintf (&data, "%s;", data);
if (minp)
xasprintf (&data, "%s%f", data, minv);
if (maxp) {
xasprintf (&data, "%s;", data);
xasprintf (&data, "%s%f", data, maxv);
}
return data;
}
char *sperfdata_int (const char *label,
int val,
const char *uom,
char *warn,
char *crit,
int minp,
int minv,
int maxp,
int maxv)
{
char *data = NULL;
if (strpbrk (label, "'= "))
xasprintf (&data, "'%s'=", label);
else
xasprintf (&data, "%s=", label);
xasprintf (&data, "%s%d", data, val);
xasprintf (&data, "%s%s;", data, uom);
if (warn!=NULL)
xasprintf (&data, "%s%s", data, warn);
xasprintf (&data, "%s;", data);
if (crit!=NULL)
xasprintf (&data, "%s%s", data, crit);
xasprintf (&data, "%s;", data);
if (minp)
xasprintf (&data, "%s%d", data, minv);
if (maxp) {
xasprintf (&data, "%s;", data);
xasprintf (&data, "%s%d", data, maxv);
}
return data;
}

View file

@ -94,29 +94,17 @@ const char *state_text (int);
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
char *perfdata (const char *,
long int,
const char *,
int,
long int,
int,
long int,
int,
long int,
int,
long int);
char *perfdata (const char *, long int, const char *, int, long int,
int, long int, int, long int, int, long int);
char *fperfdata (const char *,
double,
const char *,
int,
double,
int,
double,
int,
double,
int,
double);
char *fperfdata (const char *, double, const char *, int, double,
int, double, int, double, int, double);
char *sperfdata (const char *, double, const char *, char *, char *,
int, double, int, double);
char *sperfdata_int (const char *, int, const char *, char *, char *,
int, int, int, int);
/* The idea here is that, although not every plugin will use all of these,
most will or should. Therefore, for consistency, these very common

BIN
po/de.gmo

Binary file not shown.

1699
po/de.po

File diff suppressed because it is too large Load diff

BIN
po/fr.gmo

Binary file not shown.

1628
po/fr.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1 +1 @@
2.1.2
2.2

Some files were not shown because too many files have changed in this diff Show more