New upstream version 2.3

This commit is contained in:
Jan Wagner 2020-12-10 21:00:09 +01:00
parent 0f5a7fe8f1
commit 3031044324
129 changed files with 14313 additions and 2999 deletions

View file

@ -20,7 +20,7 @@ Using the DLPI support on SysV systems to get the host MAC address in check_dhcp
Stenberg, Daniel
Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se>
http://curl.haxx.se/
Use of duplication of macros in m4/np_curl.m4
Use of duplication of macros in m4/np_curl.m4 (slighly adapted for m4/uriparser.m4 too)
Coreutils team
Copyright (C) 91, 1995-2004 Free Software Foundation, Inc.
@ -31,3 +31,9 @@ Gnulib team
Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc
http://www.gnu.org/software/gnulib/
Use of lib files that originally were used from coreutils
Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase,
Shigeo Mitsunari
picohttpparser
https://github.com/h2o/picohttpparser
Use of the library for HTTP header parsing in check_curl.

View file

@ -7,7 +7,7 @@ EXTRA_DIST = config.rpath \
NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
NPTest.pm pkg \
config_test/Makefile config_test/run_tests config_test/child_test.c \
tools/build_perl_modules \
perlmods tools/build_perl_modules \
tools/tinderbox_build
ACLOCAL_AMFLAGS = -I gl/m4 -I m4
@ -31,9 +31,10 @@ install-root:
test test-debug:
cd lib && $(MAKE) $@
if test "$(PERLMODS_DIR)" != ""; then cd && $(MAKE) $@; fi
if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi
cd plugins && $(MAKE) $@
cd plugins-scripts && $(MAKE) $@
cd plugins-root && $(MAKE) $@
# Solaris pkgmk
BUILDDIR = build-solaris

View file

@ -60,8 +60,10 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
build-aux/ltmain.sh build-aux/missing build-aux/mkinstalldirs \
config.rpath mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -941,6 +943,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1066,6 +1073,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1283,6 +1291,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1293,6 +1306,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@ -1360,7 +1374,7 @@ EXTRA_DIST = config.rpath \
NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
NPTest.pm pkg \
config_test/Makefile config_test/run_tests config_test/child_test.c \
tools/build_perl_modules \
perlmods tools/build_perl_modules \
tools/tinderbox_build
ACLOCAL_AMFLAGS = -I gl/m4 -I m4
@ -1903,9 +1917,10 @@ install-root:
test test-debug:
cd lib && $(MAKE) $@
if test "$(PERLMODS_DIR)" != ""; then cd && $(MAKE) $@; fi
if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi
cd plugins && $(MAKE) $@
cd plugins-scripts && $(MAKE) $@
cd plugins-root && $(MAKE) $@
solpkg:
if [ ! -d $(BUILDDIR) ] ; then mkdir $(BUILDDIR); fi

47
NEWS
View file

@ -1,5 +1,52 @@
This file documents the major additions and syntax changes between releases.
2.3 10th December 2020
ENHANCEMENTS
check_dns: allow 'expected address' (-a) to be specified in CIDR notation
(IPv4 only).
check_dns: allow for IPv6 RDNS
check_dns: Accept CIDR
check_dns: allow unsorted addresses
check_dns: allow forcing complete match of all addresses
check_apt: add --only-critical switch
check_apt: add -l/--list option to print packages
check_file_age: add range checking
check_file_age: enable to test for maximum file size
check_apt: adding packages-warning option
check_load: Adding top consuming processes option
check_http: Adding Proxy-Authorization and extra headers
check_snmp: make calcualtion of timeout value in help output more clear
check_uptime: new plugin for checking uptime to see how long the system is running
check_curl: check_http replacement based on libcurl
check_http: Allow user to specify HTTP method after proxy CONNECT
check_http: Add new flag --show-body/-B to print body
check_cluster: Added data argument validation
check_icmp: Add IPv6 support
check_icmp: Automatically detect IP protocol
check_icmp: emit error if multiple protocol version
check_disk: add support to display inodes usage in perfdata
check_hpjd: Added -D option to disable warning on 'out of paper'
check_http: support the --show-body/-B flag when --expect is used
check_mysql: allow mariadbclient to be used
check_tcp: add --sni
check_dns: detect unreachable dns service in nslookup output
FIXES
Fix regression where check_dhcp was rereading response in a tight loop
check_dns: fix error detection on sles nslookup
check_disk_smb: fix timeout issue
check_swap: repaired "-n" behaviour
check_icmp: Correctly set address_family on lookup
check_icmp: Do not overwrite -4,-6 on lookup
check_smtp: initializes n before it is used
check_dns: fix typo in parameter description
check_by_ssh: fix child process leak on timeouts
check_mysql: Allow sockets to be specified to -H
check_procs: improve command examples for 'at least' processes
check_swap: repaired "-n" behaviour
check_disk: include -P switch in help
check_mailq: restore accidentially removed options
2.2 29th November 2016
ENHANCEMENTS
The check_http -S/--ssl option now accepts the arguments "1.1" and "1.2"

View file

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

112
NPTest.pm
View file

@ -62,17 +62,6 @@ runs will use these values. The user is able to change the values by
amending the values in the file /var/tmp/NPTest.cache, or by setting
the appropriate environment variable before running the test.
The option exists to store parameters in a scoped means, allowing a
test harness to a localise a parameter should the need arise. This
allows a parameter of the same name to exist in a test harness
specific scope, while not affecting the globally scoped parameter. The
scoping identifier is the name of the test harness sans the trailing
".t". All cache searches first look to a scoped parameter before
looking for the parameter at global scope. Thus for a test harness
called "check_disk.t" requesting the parameter "mountpoint_valid", the
cache is first searched for "check_disk"/"mountpoint_valid", if this
fails, then a search is conducted for "mountpoint_valid".
To facilitate quick testing setup, it is possible to accept all the
developer provided defaults by setting the environment variable
"NPTEST_ACCEPTDEFAULT" to "1" (or any other perl truth value). Note
@ -327,78 +316,51 @@ sub skipMsg
return $testStatus;
}
sub getTestParameter
{
my( $param, $envvar, $default, $brief, $scoped );
my $new_style;
if (scalar @_ <= 3) {
($param, $brief, $default) = @_;
$envvar = $param;
$new_style = 1;
} else {
( $param, $envvar, $default, $brief, $scoped ) = @_;
$new_style = 0;
sub getTestParameter {
my($param, $description, $default) = @_;
if($param !~ m/^NP_[A-Z0-9_]+$/mx) {
die("parameter should be all uppercase and start with NP_ (requested from ".(caller(0))[1].")");
}
# Apply default values for optional arguments
$scoped = ( defined( $scoped ) && $scoped );
return $ENV{$param} if $ENV{$param};
my $testharness = basename( (caller(0))[1], ".t" ); # used for scoping
if ( defined( $envvar ) && exists( $ENV{$envvar} ) && $ENV{$envvar} )
{
return $ENV{$envvar};
}
my $cachedValue = SearchCache( $param, $testharness );
if ( defined( $cachedValue ) )
{
# This save required to convert to new style because the key required is
# changing to the environment variable
if ($new_style == 0) {
SetCacheParameter( $envvar, undef, $cachedValue );
}
my $cachedValue = SearchCache($param);
if(defined $cachedValue) {
return $cachedValue;
}
my $defaultValid = ( defined( $default ) && $default );
my $autoAcceptDefault = ( exists( $ENV{'NPTEST_ACCEPTDEFAULT'} ) && $ENV{'NPTEST_ACCEPTDEFAULT'} );
if ( $autoAcceptDefault && $defaultValid )
{
return $default;
if($ENV{'NPTEST_ACCEPTDEFAULT'}) {
return $default if $default;
return "";
}
# Set "none" if no terminal attached (eg, tinderbox build servers when new variables set)
return "" unless (-t STDIN);
my $userResponse = "";
while ( $userResponse eq "" )
{
while($userResponse eq "") {
print STDERR "\n";
print STDERR "Test Harness : $testharness\n";
print STDERR "Test File : ".(caller(0))[1]."\n";
print STDERR "Test Parameter : $param\n";
print STDERR "Environment Variable : $envvar\n" if ($param ne $envvar);
print STDERR "Brief Description : $brief\n";
print STDERR "Enter value (or 'none') ", ($defaultValid ? "[${default}]" : "[]"), " => ";
print STDERR "Description : $description\n";
print STDERR "Enter value (or 'none') ", ($default ? "[${default}]" : "[]"), " => ";
$userResponse = <STDIN>;
$userResponse = "" if ! defined( $userResponse ); # Handle EOF
chomp( $userResponse );
if ( $defaultValid && $userResponse eq "" )
{
chomp($userResponse);
if($default && $userResponse eq "") {
$userResponse = $default;
}
}
print STDERR "\n";
if ($userResponse =~ /^(na|none)$/) {
if($userResponse =~ /^(na|none)$/) {
$userResponse = "";
}
# define all user responses at global scope
SetCacheParameter( $param, ( $scoped ? $testharness : undef ), $userResponse );
# store user responses
SetCacheParameter($param, $userResponse);
return $userResponse;
}
@ -407,37 +369,20 @@ sub getTestParameter
# Internal Cache Management Functions
#
sub SearchCache
{
my( $param, $scope ) = @_;
sub SearchCache {
my($param) = @_;
LoadCache();
if ( exists( $CACHE{$scope} ) && exists( $CACHE{$scope}{$param} ) )
{
return $CACHE{$scope}{$param};
}
if ( exists( $CACHE{$param} ) )
{
if(exists $CACHE{$param}) {
return $CACHE{$param};
}
return undef; # Need this to say "nothing found"
}
sub SetCacheParameter
{
my( $param, $scope, $value ) = @_;
if ( defined( $scope ) )
{
$CACHE{$scope}{$param} = $value;
}
else
{
sub SetCacheParameter {
my($param, $value) = @_;
$CACHE{$param} = $value;
}
SaveCache();
}
@ -475,6 +420,11 @@ sub SaveCache
delete $CACHE{'_cache_loaded_'};
my $oldFileContents = delete $CACHE{'_original_cache'};
# clean up old style params
for my $key (keys %CACHE) {
delete $CACHE{$key} if $key !~ m/^NP_[A-Z0-9_]+$/mx;
}
my($dataDumper) = new Data::Dumper([\%CACHE]);
$dataDumper->Terse(1);
$dataDumper->Sortkeys(1);
@ -486,7 +436,7 @@ sub SaveCache
if($oldFileContents ne $data) {
my($fileHandle) = new IO::File;
if (!$fileHandle->open( "> ${CACHEFILENAME}")) {
print STDERR "NPTest::LoadCache() : Problem saving ${CACHEFILENAME} : $!\n";
print STDERR "NPTest::SaveCache() : Problem saving ${CACHEFILENAME} : $!\n";
return;
}
print $fileHandle $data;

4
README
View file

@ -10,7 +10,7 @@ Monitoring Plugins
* For information on detailed changes that have been made or plugins
that have been added, read the `ChangeLog` file.
* Some plugins require that you have additional programs and/or
* Some plugins require that you have additional programs or
libraries installed on your system before they can be used. Plugins that
are dependent on other programs/libraries that are missing are usually not
compiled. Read the `REQUIREMENTS` file for more information.
@ -19,7 +19,7 @@ Monitoring Plugins
the basic guidelines for development will provide detailed help when
invoked with the `-h` or `--help` options.
You can check for the latest plugins at:
You can check the latest plugins at:
* <https://www.monitoring-plugins.org/>

View file

@ -11,6 +11,22 @@ check_ldaps, check_http --ssl, check_tcp --ssl, check_smtp --starttls
- Requires openssl or gnutls libraries for SSL connections
http://www.openssl.org, http://www.gnu.org/software/gnutls
check_curl:
- Requires libcurl 7.15.2 or later
http://www.haxx.se
- --ssl/-S and -C requires OpenSSL for certificate checks, otherwise
libcurl must be quite new to support CURLINFO_CERTINFO with
GnuTLS and NSS libraries:
- 7.42.0 or newer for GnuTLS
- 7.34.0 or newer for NSS
GnuTLS is known to create problems on some distributions with
self-signed certificate chains
http://www.openssl.org, http://www.gnu.org/software/gnutls,
http://www.mozilla.org/projects/security/pki/nss/,
other SSL implementations are currently not supported
- uriparser 0.7.5 or later
https://uriparser.github.io/
check_fping:
- Requires the fping utility distributed with SATAN. Either
download and install SATAN or grab the fping program from

26
THANKS
View file

@ -5,6 +5,8 @@ raising bug reports, creating patches or contributing new plugins.
Diego Elio Pettenò
fabiodds
Elan Ruusamäe
Nicolai Søborg
Marc Sánchez
dag rob?le
Matthias Hähnel
Randy O'Meara
@ -18,16 +20,20 @@ Felipe Gustavo de Almeida
Michael Almond
Michael Anthon
Bernd Apfel
Bernd Arnold
Paula Arnold
Kondoros Attila
Daniel Austin
Karol Babioch
Markus Baertschi
Bradley Baetz
Michael Bakker
Nobuhiro Ban
John Barbuto
Andreas Baumann
Jeremy Baumgartner
Marco Beck
Rolf Eike Beer
Andreas Behal
Lutz Behnke
Marlo Bell
@ -42,6 +48,7 @@ Jimmy Bergman
Jochen Bern
Tom Bertelston
Gunnar Beutner
Prathamesh Bhanuse
Daniel Bimschas
Jeffery Blank
Tom De Blende
@ -57,6 +64,7 @@ Tobias Brox
Tilmann Bubeck
Dick van den Burg
Jason Burnett
Lucas Bussey
Grant Byers
Carlos Canau
Jethro Carr
@ -79,6 +87,7 @@ Greg Cox
Jason Crawford
David Croft
Robert Dale
Vincent Danjean
Rok Debevc
Marcos Della
Phil Dibowitz
@ -103,6 +112,7 @@ O'Shaughnessy Evans
Merijn Evertse
Karl Ewald
Mikael Falkvidd
Guido Falsi
Paul Farrall
Reuben Farrelly
Mark Favas
@ -120,6 +130,7 @@ Felix Frank
Dann Frazier
Rick Frey
John C. Frickson
Markus Frosch
Matt Garrett
Sven Geggus
Jonas Genannt
@ -139,6 +150,7 @@ Steven Grimm
Sebastien Guay
Jon Hallett
Steve Hanselman
Jacob Hansen
Ask Bjoern Hansen
Sebastian Harl
Michael Haro
@ -152,6 +164,7 @@ Jason Hoos
Richard Edward Horner
Chester Hosey
Marc Huffnagle
Kostyantyn Hushchyn
Bob Ingraham
Cire Iriarte
Bryan Irvine
@ -171,9 +184,12 @@ Matthieu Kermagoret
Bo Kersey
Konstantin Khomoutov
Serhan Kiymaz
Alexander A. Klimov
Denis Knauf
Harald Koch
Tilman Koschnick
John Koyle
Michael Kraus
Steven Kreuzer
Julius Kriukas
Christoph Kron
@ -224,6 +240,7 @@ Stefan Meier
Michael Melcher
Jan-Piet Mens
Sven Meyer
Lars Michelsen
Emil Michles
Christian Mies
Jonathan Milby
@ -256,6 +273,7 @@ William Pietri
Tomasz Pilat
Myke Place
Ari Pollak
Iustin Pop
Marc Poulin
Matt Pounsett
Peter Pramberger
@ -266,8 +284,10 @@ Darian Rackham
Peter Radcliffe
Steve Rader
Olivier 'Babar' Raginel
Jean-François Rameau
Phil Randal
Abid Rasheed
Patrick Rauscher
Jeremy Reed
Spenser Reinhardt
Marc Remy
@ -291,6 +311,7 @@ Sven Schaffranneck
Christoph Schell
Thomas Schimpke
Benjamin Schmid
Christian Schmidt
Sebastian Schmidt
Henning Schmiedehausen
Christian Schneemann
@ -311,12 +332,14 @@ John Sivak
Nik Soggia
Robin Sonefors
Erwan Ben Souiden
Bernard Spil
Lars Stavholm
Daniel Stirnimann
Nikolay Sturm
David Sullivan
Kjell Sundtjonn
Ziya Suzen
Christian Tacke
Michael Tiernan
Ben Timby
Ronald Tin
@ -334,6 +357,7 @@ Laurent Vaslin
Matej Vela
Carole Verdon
Ludse Verhoeven
Valentin Vidic
Robert August Vincent
Dave Viner
Lars Vogdt
@ -356,6 +380,8 @@ Shawn Wills
Rob Windsor
Mario Witte
Alexander Wittig
Tobias Wolf
Brian De Wolf
Patric Wust
Jamie Zawinski
Vadim Zhukov

2
aclocal.m4 vendored
View file

@ -1044,7 +1044,9 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([m4/libcurl.m4])
m4_include([m4/np_mysqlclient.m4])
m4_include([m4/uriparser.m4])
m4_include([gl/m4/00gnulib.m4])
m4_include([gl/m4/alloca.m4])
m4_include([gl/m4/arpa_inet_h.m4])

View file

@ -452,6 +452,9 @@
/* Define to 1 if you have the `crypto' library (-lcrypto). */
#undef HAVE_LIBCRYPTO
/* Define to 1 if you have a functional curl library. */
#undef HAVE_LIBCURL
/* Define to 1 if you have the `dbi' library (-ldbi). */
#undef HAVE_LIBDBI
@ -550,7 +553,7 @@
concept. */
#undef HAVE_MSVC_INVALID_PARAMETER_HANDLER
/* Defined if mysqlclient is found and can compile */
/* Defined if mariadbclient is found and can compile */
#undef HAVE_MYSQLCLIENT
/* Define to 1 if you have the <netdb.h> header file. */
@ -1670,6 +1673,9 @@
/* Define to 1 if the system has the type 'unsigned long long int'. */
#undef HAVE_UNSIGNED_LONG_LONG_INT
/* Define to 1 if you have a functional uriparser library. */
#undef HAVE_URIPARSER
/* Define to 1 if you have the <utmpx.h> header file. */
#undef HAVE_UTMPX_H
@ -1742,6 +1748,69 @@
/* Define HOST_NAME_MAX when <limits.h> does not define it. */
#undef HOST_NAME_MAX
/* Defined if libcurl supports AsynchDNS */
#undef LIBCURL_FEATURE_ASYNCHDNS
/* Defined if libcurl supports IDN */
#undef LIBCURL_FEATURE_IDN
/* Defined if libcurl supports IPv6 */
#undef LIBCURL_FEATURE_IPV6
/* Defined if libcurl supports KRB4 */
#undef LIBCURL_FEATURE_KRB4
/* Defined if libcurl supports libz */
#undef LIBCURL_FEATURE_LIBZ
/* Defined if libcurl supports NTLM */
#undef LIBCURL_FEATURE_NTLM
/* Defined if libcurl supports SSL */
#undef LIBCURL_FEATURE_SSL
/* Defined if libcurl supports SSPI */
#undef LIBCURL_FEATURE_SSPI
/* Defined if libcurl supports DICT */
#undef LIBCURL_PROTOCOL_DICT
/* Defined if libcurl supports FILE */
#undef LIBCURL_PROTOCOL_FILE
/* Defined if libcurl supports FTP */
#undef LIBCURL_PROTOCOL_FTP
/* Defined if libcurl supports FTPS */
#undef LIBCURL_PROTOCOL_FTPS
/* Defined if libcurl supports HTTP */
#undef LIBCURL_PROTOCOL_HTTP
/* Defined if libcurl supports HTTPS */
#undef LIBCURL_PROTOCOL_HTTPS
/* Defined if libcurl supports IMAP */
#undef LIBCURL_PROTOCOL_IMAP
/* Defined if libcurl supports LDAP */
#undef LIBCURL_PROTOCOL_LDAP
/* Defined if libcurl supports POP3 */
#undef LIBCURL_PROTOCOL_POP3
/* Defined if libcurl supports RTSP */
#undef LIBCURL_PROTOCOL_RTSP
/* Defined if libcurl supports SMTP */
#undef LIBCURL_PROTOCOL_SMTP
/* Defined if libcurl supports TELNET */
#undef LIBCURL_PROTOCOL_TELNET
/* Defined if libcurl supports TFTP */
#undef LIBCURL_PROTOCOL_TFTP
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
@ -1925,6 +1994,9 @@
/* Whether the ps utility uses the "procetime" field */
#undef PS_USES_PROCETIME
/* Whether the ps utility uses the "procpcpu" field */
#undef PS_USES_PROCPCPU
/* Variable list for sscanf of 'ps' output */
#undef PS_VARLIST
@ -2213,6 +2285,9 @@
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define curl_free() as free() if our version of curl lacks curl_free. */
#undef curl_free
/* Please see the Gnulib manual for how to use these macros.
Suppress extern inline with HP-UX cc, as it appears to be broken; see

766
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.2.
# Generated by GNU Autoconf 2.69 for monitoring-plugins 2.3.
#
#
# 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.2'
PACKAGE_STRING='monitoring-plugins 2.2'
PACKAGE_VERSION='2.3'
PACKAGE_STRING='monitoring-plugins 2.3'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@ -1641,6 +1641,18 @@ check_tcp_ssl
SSLINCLUDE
KRBINCLUDE
PATH_TO_WHO
URIPARSERCFLAGS
URIPARSERLIBS
URIPARSERINCLUDE
URIPARSER
URIPARSER_CPPFLAGS
PKGCONFIG
LIBCURLCFLAGS
LIBCURLLIBS
LIBCURLINCLUDE
LIBCURL
LIBCURL_CPPFLAGS
_libcurl_config
WTSAPI32LIBS
HAVE_WTS32API_FALSE
HAVE_WTS32API_TRUE
@ -1822,6 +1834,8 @@ with_dbi
with_radius
with_ldap
with_mysql
with_libcurl
with_uriparser
with_ipv6
with_ps_command
with_ps_format
@ -2403,7 +2417,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.2 to adapt to many kinds of systems.
\`configure' configures monitoring-plugins 2.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -2474,7 +2488,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of monitoring-plugins 2.2:";;
short | recursive ) echo "Configuration of monitoring-plugins 2.3:";;
esac
cat <<\_ACEOF
@ -2530,6 +2544,10 @@ Optional Packages:
--with-mysql=DIR Locates mysql libraries. Expects
DIR/bin/mysql_config. Default to search for
mysql_config in PATH
--with-libcurl=PREFIX look for the curl library in PREFIX/lib and headers
in PREFIX/include
--with-uriparser=PREFIX look for the uriparser library in PREFIX/lib and
headers in PREFIX/include
--with-ipv6 support IPv6 [default=check]
--with-ps-command=PATH Verbatim command to execute for ps
--with-ps-format=FORMAT Format string for scanning ps output
@ -2641,7 +2659,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
monitoring-plugins configure 2.2
monitoring-plugins configure 2.3
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -3346,7 +3364,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.2, which was
It was created by monitoring-plugins $as_me 2.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -4217,7 +4235,7 @@ fi
# Define the identity of the package.
PACKAGE='monitoring-plugins'
VERSION='2.2'
VERSION='2.3'
cat >>confdefs.h <<_ACEOF
@ -15410,6 +15428,7 @@ fi
_savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $np_mysql_include"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmysqlclient" >&5
$as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; }
if ${ac_cv_lib_mysqlclient_mysql_init+:} false; then :
@ -15453,10 +15472,60 @@ if test "x$ac_cv_lib_mysqlclient_mysql_init" = xyes; then :
$as_echo "#define HAVE_MYSQLCLIENT 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmariadbclient" >&5
$as_echo_n "checking for mysql_init in -lmariadbclient... " >&6; }
if ${ac_cv_lib_mariadbclient_mysql_init+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmariadbclient $np_mysql_libs $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 mysql_init ();
int
main ()
{
return mysql_init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_mariadbclient_mysql_init=yes
else
ac_cv_lib_mariadbclient_mysql_init=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_mariadbclient_mysql_init" >&5
$as_echo "$ac_cv_lib_mariadbclient_mysql_init" >&6; }
if test "x$ac_cv_lib_mariadbclient_mysql_init" = xyes; then :
with_mysql=$np_mysql_config
$as_echo "#define HAVE_MYSQLCLIENT 1" >>confdefs.h
else
with_mysql=no
fi
fi
CPPFLAGS=$_savedcppflags
fi
@ -15525,6 +15594,662 @@ if test "$ac_cv_header_wtsapi32_h" = "yes"; then
fi
_can_enable_check_curl=no
# Check whether --with-libcurl was given.
if test "${with_libcurl+set}" = set; then :
withval=$with_libcurl; _libcurl_with=$withval
else
_libcurl_with=yes
fi
if test "$_libcurl_with" != "no" ; then
for ac_prog in gawk mawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; 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_prog_AWK+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$AWK"; then
ac_cv_prog_AWK="$AWK" # Let the user override the test.
else
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_prog_AWK="$ac_prog"
$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
fi
fi
AWK=$ac_cv_prog_AWK
if test -n "$AWK"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
$as_echo "$AWK" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$AWK" && break
done
_libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[1]+256*A[2]+A[3]; print X;}'"
_libcurl_try_link=yes
if test -d "$_libcurl_with" ; then
LIBCURL_CPPFLAGS="-I$withval/include"
_libcurl_ldflags="-L$withval/lib"
# Extract the first word of "curl-config", so it can be a program name with args.
set dummy curl-config; 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__libcurl_config+:} false; then :
$as_echo_n "(cached) " >&6
else
case $_libcurl_config in
[\\/]* | ?:[\\/]*)
ac_cv_path__libcurl_config="$_libcurl_config" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in "$withval/bin"
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__libcurl_config="$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
_libcurl_config=$ac_cv_path__libcurl_config
if test -n "$_libcurl_config"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_libcurl_config" >&5
$as_echo "$_libcurl_config" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
else
# Extract the first word of "curl-config", so it can be a program name with args.
set dummy curl-config; 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__libcurl_config+:} false; then :
$as_echo_n "(cached) " >&6
else
case $_libcurl_config in
[\\/]* | ?:[\\/]*)
ac_cv_path__libcurl_config="$_libcurl_config" # 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__libcurl_config="$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
_libcurl_config=$ac_cv_path__libcurl_config
if test -n "$_libcurl_config"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_libcurl_config" >&5
$as_echo "$_libcurl_config" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test x$_libcurl_config != "x" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the version of libcurl" >&5
$as_echo_n "checking for the version of libcurl... " >&6; }
if ${libcurl_cv_lib_curl_version+:} false; then :
$as_echo_n "(cached) " >&6
else
libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $2}'`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_curl_version" >&5
$as_echo "$libcurl_cv_lib_curl_version" >&6; }
_libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
_libcurl_wanted=`echo 7.15.2 | $_libcurl_version_parse`
if test $_libcurl_wanted -gt 0 ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libcurl >= version 7.15.2" >&5
$as_echo_n "checking for libcurl >= version 7.15.2... " >&6; }
if ${libcurl_cv_lib_version_ok+:} false; then :
$as_echo_n "(cached) " >&6
else
if test $_libcurl_version -ge $_libcurl_wanted ; then
libcurl_cv_lib_version_ok=yes
else
libcurl_cv_lib_version_ok=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_version_ok" >&5
$as_echo "$libcurl_cv_lib_version_ok" >&6; }
fi
if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
if test x"$LIBCURL_CPPFLAGS" = "x" ; then
LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
fi
if test x"$LIBCURL" = "x" ; then
LIBCURL=`$_libcurl_config --libs`
# This is so silly, but Apple actually has a bug in their
# curl-config script. Fixed in Tiger, but there are still
# lots of Panther installs around.
case "${host}" in
powerpc-apple-darwin7*)
LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
;;
esac
fi
# All curl-config scripts support --feature
_libcurl_features=`$_libcurl_config --feature`
# Is it modern enough to have --protocols? (7.12.4)
if test $_libcurl_version -ge 461828 ; then
_libcurl_protocols=`$_libcurl_config --protocols`
fi
else
_libcurl_try_link=no
fi
unset _libcurl_wanted
fi
if test $_libcurl_try_link = yes ; then
# we didn't find curl-config, so let's see if the user-supplied
# link line (or failing that, "-lcurl") is enough.
LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libcurl is usable" >&5
$as_echo_n "checking whether libcurl is usable... " >&6; }
if ${libcurl_cv_lib_curl_usable+:} false; then :
$as_echo_n "(cached) " >&6
else
_libcurl_save_cppflags=$CPPFLAGS
CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
_libcurl_save_libs=$LIBS
LIBS="$LIBCURL $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <curl/curl.h>
int
main ()
{
/* Try and use a few common options to force a failure if we are
missing symbols or can't link. */
int x;
curl_easy_setopt(NULL,CURLOPT_URL,NULL);
x=CURL_ERROR_SIZE;
x=CURLOPT_WRITEFUNCTION;
x=CURLOPT_WRITEDATA;
x=CURLOPT_ERRORBUFFER;
x=CURLOPT_STDERR;
x=CURLOPT_VERBOSE;
if (x) {;}
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
libcurl_cv_lib_curl_usable=yes
else
libcurl_cv_lib_curl_usable=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CPPFLAGS=$_libcurl_save_cppflags
LIBS=$_libcurl_save_libs
unset _libcurl_save_cppflags
unset _libcurl_save_libs
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_curl_usable" >&5
$as_echo "$libcurl_cv_lib_curl_usable" >&6; }
if test $libcurl_cv_lib_curl_usable = yes ; then
# Does curl_free() exist in this version of libcurl?
# If not, fake it with free()
_libcurl_save_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
_libcurl_save_libs=$LIBS
LIBS="$LIBS $LIBCURL"
ac_fn_c_check_func "$LINENO" "curl_free" "ac_cv_func_curl_free"
if test "x$ac_cv_func_curl_free" = xyes; then :
else
$as_echo "#define curl_free free" >>confdefs.h
fi
CPPFLAGS=$_libcurl_save_cppflags
LIBS=$_libcurl_save_libs
unset _libcurl_save_cppflags
unset _libcurl_save_libs
$as_echo "#define HAVE_LIBCURL 1" >>confdefs.h
for _libcurl_feature in $_libcurl_features ; do
cat >>confdefs.h <<_ACEOF
#define `$as_echo "libcurl_feature_$_libcurl_feature" | $as_tr_cpp` 1
_ACEOF
eval `$as_echo "libcurl_feature_$_libcurl_feature" | $as_tr_sh`=yes
done
if test "x$_libcurl_protocols" = "x" ; then
# We don't have --protocols, so just assume that all
# protocols are available
_libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
if test x$libcurl_feature_SSL = xyes ; then
_libcurl_protocols="$_libcurl_protocols HTTPS"
# FTPS wasn't standards-compliant until version
# 7.11.0 (0x070b00 == 461568)
if test $_libcurl_version -ge 461568; then
_libcurl_protocols="$_libcurl_protocols FTPS"
fi
fi
# RTSP, IMAP, POP3 and SMTP were added in
# 7.20.0 (0x071400 == 463872)
if test $_libcurl_version -ge 463872; then
_libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP"
fi
fi
for _libcurl_protocol in $_libcurl_protocols ; do
cat >>confdefs.h <<_ACEOF
#define `$as_echo "libcurl_protocol_$_libcurl_protocol" | $as_tr_cpp` 1
_ACEOF
eval `$as_echo "libcurl_protocol_$_libcurl_protocol" | $as_tr_sh`=yes
done
else
unset LIBCURL
unset LIBCURL_CPPFLAGS
fi
fi
unset _libcurl_try_link
unset _libcurl_version_parse
unset _libcurl_config
unset _libcurl_feature
unset _libcurl_features
unset _libcurl_protocol
unset _libcurl_protocols
unset _libcurl_version
unset _libcurl_ldflags
fi
if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
# This is the IF-NO path
_can_enable_check_curl=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Skipping curl plugin" >&5
$as_echo "$as_me: WARNING: Skipping curl plugin" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: install libcurl libs to compile this plugin (see REQUIREMENTS)." >&5
$as_echo "$as_me: WARNING: install libcurl libs to compile this plugin (see REQUIREMENTS)." >&2;}
else
# This is the IF-YES path
_can_enable_check_curl=yes
LIBCURLINCLUDE="$LIBCURL_CPPFLAGS"
LIBCURLLIBS="$LIBCURL"
LIBCURLCFLAGS="$LIBCURL_CPPFLAGS"
fi
unset _libcurl_with
# Check whether --with-uriparser was given.
if test "${with_uriparser+set}" = set; then :
withval=$with_uriparser; _uriparser_with=$withval
else
_uriparser_with=yes
fi
if test "$_uriparser_with" != "no" ; then
_uriparser_try_link=yes
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; 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_prog_PKGCONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$PKGCONFIG"; then
ac_cv_prog_PKGCONFIG="$PKGCONFIG" # Let the user override the test.
else
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_prog_PKGCONFIG="pkg-config"
$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
test -z "$ac_cv_prog_PKGCONFIG" && ac_cv_prog_PKGCONFIG="no"
fi
fi
PKGCONFIG=$ac_cv_prog_PKGCONFIG
if test -n "$PKGCONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKGCONFIG" >&5
$as_echo "$PKGCONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$URIPARSER" != "x" || test "x$URIPARSER_CPPFLAGS" != "x"; then
:
elif test -d "$_uriparser_with" ; then
URIPARSER_CPPFLAGS="-I$withval/include"
_uriparser_ldflags="-L$withval/lib"
elif test x$PKGCONFIG != xno; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the version of uriparser" >&5
$as_echo_n "checking for the version of uriparser... " >&6; }
if ${uriparser_cv_uriparser_version+:} false; then :
$as_echo_n "(cached) " >&6
else
uriparser_cv_uriparser_version=`$PKGCONFIG liburiparser --modversion`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $uriparser_cv_uriparser_version" >&5
$as_echo "$uriparser_cv_uriparser_version" >&6; }
for ac_prog in gawk mawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; 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_prog_AWK+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$AWK"; then
ac_cv_prog_AWK="$AWK" # Let the user override the test.
else
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_prog_AWK="$ac_prog"
$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
fi
fi
AWK=$ac_cv_prog_AWK
if test -n "$AWK"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
$as_echo "$AWK" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$AWK" && break
done
_uriparser_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[1]+256*A[2]+A[3]; print X;}'"
_uriparser_version=`echo $uriparser_cv_uriparser_version | $_uriparser_version_parse`
_uriparser_wanted=`echo 0.7.5 | $_uriparser_version_parse`
if test $_uriparser_wanted -gt 0 ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uriparser >= version 0.7.5" >&5
$as_echo_n "checking for uriparser >= version 0.7.5... " >&6; }
if ${uriparser_cv_lib_version_ok+:} false; then :
$as_echo_n "(cached) " >&6
else
if test $_uriparser_version -ge $_uriparser_wanted ; then
uriparser_cv_lib_version_ok=yes
else
uriparser_cv_lib_version_ok=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $uriparser_cv_lib_version_ok" >&5
$as_echo "$uriparser_cv_lib_version_ok" >&6; }
fi
if test $_uriparser_wanted -eq 0 || test x$uriparser_cv_lib_version_ok = xyes ; then
if test x"$URIPARSER_CPPFLAGS" = "x" ; then
URIPARSER_CPPFLAGS=`$PKGCONFIG liburiparser --cflags`
fi
if test x"$URIPARSER" = "x" ; then
URIPARSER=`$PKGCONFIG liburiparser --libs`
fi
else
_uriparser_try_link=no
fi
unset _uriparser_wanted
else
URIPARSER_CPPFLAGS="-I/usr/include"
URIPARSER="-luriparser -L/usr/lib -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i686-linux-gnu"
fi
if test $_uriparser_try_link = yes ; then
# let's see if the user-supplied
# link line (or failing that, "-luriparser") is enough.
URIPARSER=${URIPARSER-"$_uriparser_ldflags -luriparser"}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether uriparser is usable" >&5
$as_echo_n "checking whether uriparser is usable... " >&6; }
if ${uriparser_cv_lib_uriparser_usable+:} false; then :
$as_echo_n "(cached) " >&6
else
_liburiparser_save_cppflags=$CPPFLAGS
CPPFLAGS="$URIPARSER_CPPFLAGS $CPPFLAGS"
_liburiparser_save_libs=$LIBS
LIBS="$URIPARSER $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <uriparser/Uri.h>
int
main ()
{
/* Try and use a few common options to force a failure if we are
missing symbols or cannot link. */
UriParserStateA state;
UriUriA uri;
state.uri = &uri;
char *location = "http://test.dom/dir/file.ext";
int x = uriParseUriA (&state, location);
if (x == URI_SUCCESS) {;}
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
uriparser_cv_lib_uriparser_usable=yes
else
uriparser_cv_lib_uriparser_usable=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CPPFLAGS=$_liburiparser_save_cppflags
LIBS=$_liburiparser_save_libs
unset _liburiparser_save_cppflags
unset _liburiparser_save_libs
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $uriparser_cv_lib_uriparser_usable" >&5
$as_echo "$uriparser_cv_lib_uriparser_usable" >&6; }
if test $uriparser_cv_lib_uriparser_usable = yes ; then
$as_echo "#define HAVE_URIPARSER 1" >>confdefs.h
else
unset URIPARSER
unset URIPARSER_CPPFLAGS
fi
fi
unset _uriparser_try_link
unset _uriparser_version_parse
unset _uriparser_version
unset _uriparser_ldflags
fi
if test x$_uriparser_with = xno || test x$uriparser_cv_lib_uriparser_usable != xyes ; then
# This is the IF-NO path
_can_enable_check_curl=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Skipping curl plugin" >&5
$as_echo "$as_me: WARNING: Skipping curl plugin" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: install the uriparser library to compile this plugin (see REQUIREMENTS)." >&5
$as_echo "$as_me: WARNING: install the uriparser library to compile this plugin (see REQUIREMENTS)." >&2;}
else
# This is the IF-YES path
URIPARSERINCLUDE="$URIPARSER_CPPFLAGS"
URIPARSERLIBS="$URIPARSER"
URIPARSERCFLAGS="$URIPARSER_CPPFLAGS"
fi
unset _uriparser_with
if test x$_can_enable_check_curl = xyes; then
EXTRAS="$EXTRAS check_curl\$(EXEEXT)"
fi
ac_config_files="$ac_config_files plugins/picohttpparser/Makefile"
if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no"
then
# Extract the first word of "who", so it can be a program name with args.
@ -17000,6 +17725,11 @@ _ACEOF
$as_echo "#define PS_USES_PROCETIME \"yes\"" >>confdefs.h
fi
if echo "$ac_cv_ps_varlist" | grep "procpcpu" >/dev/null; then
$as_echo "#define PS_USES_PROCPCPU \"yes\"" >>confdefs.h
fi
fi
@ -17129,6 +17859,15 @@ then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_ping_command" >&5
$as_echo "$with_ping_command" >&6; }
elif $PATH_TO_PING -4 -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
egrep -i "^round-trip|^rtt" >/dev/null
then
# check if -4 is supported - issue #1550
with_ping_command="$PATH_TO_PING -4 -n -U -w %d -c %d %s"
ac_cv_ping_packets_first=yes
ac_cv_ping_has_timeout=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_ping_command" >&5
$as_echo "$with_ping_command" >&6; }
elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
egrep -i "^round-trip|^rtt" >/dev/null
then
@ -40815,7 +41554,7 @@ if test "$ac_cv_uname_s" = 'SunOS' -a \( "x$ac_cv_prog_ac_ct_AR" = "x" -o "$ac_c
as_fn_error $? "No ar found for Solaris - is /usr/ccs/bin in PATH?" "$LINENO" 5
fi
ac_config_files="$ac_config_files Makefile tap/Makefile lib/Makefile plugins/Makefile lib/tests/Makefile plugins-root/Makefile plugins-scripts/Makefile plugins-scripts/utils.pm plugins-scripts/utils.sh test.pl pkg/solaris/pkginfo po/Makefile.in"
ac_config_files="$ac_config_files Makefile tap/Makefile lib/Makefile plugins/Makefile lib/tests/Makefile plugins-root/Makefile plugins-scripts/Makefile plugins-scripts/utils.pm plugins-scripts/utils.sh perlmods/Makefile test.pl pkg/solaris/pkginfo po/Makefile.in"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@ -41437,7 +42176,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.2, which was
This file was extended by monitoring-plugins $as_me 2.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -41503,7 +42242,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.2
monitoring-plugins config.status 2.3
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@ -41920,6 +42659,7 @@ do
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
"plugins/picohttpparser/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/picohttpparser/Makefile" ;;
"po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"tap/Makefile") CONFIG_FILES="$CONFIG_FILES tap/Makefile" ;;
@ -41930,6 +42670,7 @@ do
"plugins-scripts/Makefile") CONFIG_FILES="$CONFIG_FILES plugins-scripts/Makefile" ;;
"plugins-scripts/utils.pm") CONFIG_FILES="$CONFIG_FILES plugins-scripts/utils.pm" ;;
"plugins-scripts/utils.sh") CONFIG_FILES="$CONFIG_FILES plugins-scripts/utils.sh" ;;
"perlmods/Makefile") CONFIG_FILES="$CONFIG_FILES perlmods/Makefile" ;;
"test.pl") CONFIG_FILES="$CONFIG_FILES test.pl" ;;
"pkg/solaris/pkginfo") CONFIG_FILES="$CONFIG_FILES pkg/solaris/pkginfo" ;;
"po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;;
@ -43422,4 +44163,5 @@ echo " --enable-perl-modules: $enable_perl_modules"
echo " --with-cgiurl: $with_cgiurl"
echo " --with-trusted-path: $with_trusted_path"
echo " --enable-libtap: $enable_libtap"
echo " --with-libcurl: $with_libcurl"
echo " --with-uriparser: $with_uriparser"

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.2)
AC_INIT(monitoring-plugins,2.3)
AC_CONFIG_SRCDIR(NPTest.pm)
AC_CONFIG_FILES([gl/Makefile])
AC_CONFIG_AUX_DIR(build-aux)
@ -385,6 +385,42 @@ if test "$ac_cv_header_wtsapi32_h" = "yes"; then
AC_SUBST(WTSAPI32LIBS)
fi
_can_enable_check_curl=no
dnl Check for cURL library
LIBCURL_CHECK_CONFIG(yes, 7.15.2, [
_can_enable_check_curl=yes
LIBCURLINCLUDE="$LIBCURL_CPPFLAGS"
LIBCURLLIBS="$LIBCURL"
LIBCURLCFLAGS="$LIBCURL_CPPFLAGS"
AC_SUBST(LIBCURLINCLUDE)
AC_SUBST(LIBCURLLIBS)
AC_SUBST(LIBCURLCFLAGS)
], [
_can_enable_check_curl=no
AC_MSG_WARN([Skipping curl plugin])
AC_MSG_WARN([install libcurl libs to compile this plugin (see REQUIREMENTS).])
])
dnl Check for uriparser library
URIPARSER_CHECK(yes, 0.7.5, [
URIPARSERINCLUDE="$URIPARSER_CPPFLAGS"
URIPARSERLIBS="$URIPARSER"
URIPARSERCFLAGS="$URIPARSER_CPPFLAGS"
AC_SUBST(URIPARSERINCLUDE)
AC_SUBST(URIPARSERLIBS)
AC_SUBST(URIPARSERCFLAGS)
], [
_can_enable_check_curl=no
AC_MSG_WARN([Skipping curl plugin])
AC_MSG_WARN([install the uriparser library to compile this plugin (see REQUIREMENTS).])
])
dnl prerequisites met, enable the plugin
if test x$_can_enable_check_curl = xyes; then
EXTRAS="$EXTRAS check_curl\$(EXEEXT)"
fi
AC_CONFIG_FILES([plugins/picohttpparser/Makefile])
dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface
if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no"
then
@ -1016,6 +1052,10 @@ if test -n "$ac_cv_ps_varlist" ; then
AC_DEFINE(PS_USES_PROCETIME,"yes",
[Whether the ps utility uses the "procetime" field])
fi
if echo "$ac_cv_ps_varlist" | grep "procpcpu" >/dev/null; then
AC_DEFINE(PS_USES_PROCPCPU,"yes",
[Whether the ps utility uses the "procpcpu" field])
fi
fi
AC_PATH_PROG(PATH_TO_PING,ping)
@ -1060,6 +1100,14 @@ then
ac_cv_ping_packets_first=yes
AC_MSG_RESULT([$with_ping_command])
elif $PATH_TO_PING -4 -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
egrep -i "^round-trip|^rtt" >/dev/null
then
# check if -4 is supported - issue #1550
with_ping_command="$PATH_TO_PING -4 -n -U -w %d -c %d %s"
ac_cv_ping_packets_first=yes
ac_cv_ping_has_timeout=yes
AC_MSG_RESULT([$with_ping_command])
elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
egrep -i "^round-trip|^rtt" >/dev/null
then
@ -1840,6 +1888,7 @@ AC_OUTPUT(
plugins-scripts/Makefile
plugins-scripts/utils.pm
plugins-scripts/utils.sh
perlmods/Makefile
test.pl
pkg/solaris/pkginfo
po/Makefile.in
@ -1881,4 +1930,5 @@ ACX_FEATURE([enable],[perl-modules])
ACX_FEATURE([with],[cgiurl])
ACX_FEATURE([with],[trusted-path])
ACX_FEATURE([enable],[libtap])
ACX_FEATURE([with],[libcurl])
ACX_FEATURE([with],[uriparser])

View file

@ -79,8 +79,10 @@ subdir = gl
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -974,6 +976,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1099,6 +1106,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1316,6 +1324,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1326,6 +1339,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View file

@ -143,6 +143,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (vfsd.f_bavail) != 0;
fsp->fsu_files = PROPAGATE_ALL_ONES (vfsd.f_files);
fsp->fsu_ffree = PROPAGATE_ALL_ONES (vfsd.f_ffree);
fsp->fsu_favail = PROPAGATE_ALL_ONES (vfsd.f_favail);
return 0;
}
@ -174,6 +175,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.fd_req.bfreen) != 0;
fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
#elif defined STAT_READ_FILSYS /* SVR2 */
# ifndef SUPERBOFF
@ -209,6 +211,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
? UINTMAX_MAX
: (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.s_tinode);
#elif defined STAT_STATFS3_OSF1 /* OSF/1 */
@ -296,6 +299,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0;
fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.f_files);
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree);
fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.f_ffree);
#endif
@ -323,6 +327,7 @@ statfs (char *file, struct statfs *fsb)
fsb->f_bavail = fsd.du_tfree;
fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb;
fsb->f_ffree = fsd.du_tinode;
fsb->f_favail = fsd.du_tinode;
fsb->f_fsid.val[0] = fsd.du_site;
fsb->f_fsid.val[1] = fsd.du_pckno;
return 0;

View file

@ -32,7 +32,8 @@ struct fs_usage
uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */
bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
uintmax_t fsu_files; /* Total file nodes. */
uintmax_t fsu_ffree; /* Free file nodes. */
uintmax_t fsu_ffree; /* Free file nodes to superuser. */
uintmax_t fsu_favail; /* Free file nodes to non-superuser. */
};
int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp);

View file

@ -54,8 +54,10 @@ host_triplet = @host@
subdir = lib
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -943,6 +945,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1068,6 +1075,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1285,6 +1293,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1295,6 +1308,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View file

@ -57,8 +57,10 @@ EXTRA_PROGRAMS = test_utils$(EXEEXT) test_disk$(EXEEXT) \
subdir = lib/tests
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -951,6 +953,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1076,6 +1083,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1293,6 +1301,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1303,6 +1316,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View file

@ -37,6 +37,9 @@
monitoring_plugin *this_monitoring_plugin=NULL;
unsigned int timeout_state = STATE_CRITICAL;
unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
int _np_state_read_file(FILE *);
void np_init( char *plugin_name, int argc, char **argv ) {
@ -87,10 +90,13 @@ void _get_monitoring_plugin( monitoring_plugin **pointer ){
void
die (int result, const char *fmt, ...)
{
if(fmt!=NULL) {
va_list ap;
va_start (ap, fmt);
vprintf (fmt, ap);
va_end (ap);
}
if(this_monitoring_plugin!=NULL) {
np_cleanup();
}
@ -356,6 +362,22 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
return value;
}
const char *
state_text (int result)
{
switch (result) {
case STATE_OK:
return "OK";
case STATE_WARNING:
return "WARNING";
case STATE_CRITICAL:
return "CRITICAL";
case STATE_DEPENDENT:
return "DEPENDENT";
default:
return "UNKNOWN";
}
}
/*
* Read a string representing a state (ok, warning... or numeric: 0, 1) and

View file

@ -61,6 +61,10 @@ void print_thresholds(const char *, thresholds *);
int check_range(double, range *);
int get_status(double, thresholds *);
/* Handle timeouts */
extern unsigned int timeout_state;
extern unsigned int timeout_interval;
/* All possible characters in a threshold range */
#define NP_THRESHOLDS_CHARS "-0123456789.:@~"
@ -107,5 +111,6 @@ void np_state_write_string(time_t, char *);
void np_init(char *, int argc, char **argv);
void np_set_args(int argc, char **argv);
void np_cleanup();
const char *state_text (int);
#endif /* _UTILS_BASE_ */

View file

@ -40,6 +40,7 @@
/** includes **/
#include "common.h"
#include "utils.h"
#include "utils_cmd.h"
#include "utils_base.h"
#include <fcntl.h>
@ -65,31 +66,6 @@ extern char **environ;
# define SIG_ERR ((Sigfunc *)-1)
#endif
/* This variable must be global, since there's no way the caller
* can forcibly slay a dead or ungainly running program otherwise.
* Multithreading apps and plugins can initialize it (via CMD_INIT)
* in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
* for the first time.
*
* The check for initialized values is atomic and can
* occur in any number of threads simultaneously. */
static pid_t *_cmd_pids = NULL;
/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
* 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 DEFAULT_MAXFD
#endif
/** prototypes **/
static int _cmd_open (char *const *, int *, int *)
__attribute__ ((__nonnull__ (1, 2, 3)));
@ -406,3 +382,19 @@ cmd_file_read ( char *filename, output *out, int flags)
return 0;
}
void
timeout_alarm_handler (int signo)
{
size_t i;
if (signo == SIGALRM) {
printf (_("%s - Plugin timed out after %d seconds\n"),
state_text(timeout_state), timeout_interval);
if(_cmd_pids) for(i = 0; i < maxfd; i++) {
if(_cmd_pids[i] != 0) kill(_cmd_pids[i], SIGKILL);
}
exit (timeout_state);
}
}

View file

@ -32,4 +32,17 @@ void cmd_init (void);
#define CMD_NO_ARRAYS 0x01 /* don't populate arrays at all */
#define CMD_NO_ASSOC 0x02 /* output.line won't point to buf */
/* This variable must be global, since there's no way the caller
* can forcibly slay a dead or ungainly running program otherwise.
* Multithreading apps and plugins can initialize it (via CMD_INIT)
* in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
* for the first time.
*
* The check for initialized values is atomic and can
* occur in any number of threads simultaneously. */
static pid_t *_cmd_pids = NULL;
RETSIGTYPE timeout_alarm_handler (int);
#endif /* _UTILS_CMD_ */

View file

@ -69,6 +69,8 @@ np_add_parameter(struct parameter_list **list, const char *name)
new_path->dtotal_units = 0;
new_path->inodes_total = 0;
new_path->inodes_free = 0;
new_path->inodes_free_to_root = 0;
new_path->inodes_used = 0;
new_path->dused_inodes_percent = 0;
new_path->dfree_inodes_percent = 0;

View file

@ -24,7 +24,8 @@ struct parameter_list
char *group;
struct mount_entry *best_match;
struct parameter_list *name_next;
uintmax_t total, available, available_to_root, used, inodes_free, inodes_total;
uintmax_t total, available, available_to_root, used,
inodes_free, inodes_free_to_root, inodes_used, inodes_total;
double dfree_pct, dused_pct;
double dused_units, dfree_units, dtotal_units;
double dused_inodes_percent, dfree_inodes_percent;

272
m4/libcurl.m4 Normal file
View file

@ -0,0 +1,272 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 2006, David Shaw <dshaw@jabberwocky.com>
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.haxx.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
###########################################################################
# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
# [ACTION-IF-YES], [ACTION-IF-NO])
# ----------------------------------------------------------
# David Shaw <dshaw@jabberwocky.com> May-09-2006
#
# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
# specify whether to default to --with-libcurl or --without-libcurl.
# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
# minimum version of libcurl to accept. Pass the version as a regular
# version number like 7.10.1. If not supplied, any version is
# accepted. ACTION-IF-YES is a list of shell commands to run if
# libcurl was successfully found and passed the various tests.
# ACTION-IF-NO is a list of shell commands that are run otherwise.
# Note that using --without-libcurl does run ACTION-IF-NO.
#
# This macro #defines HAVE_LIBCURL if a working libcurl setup is
# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
# values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
# where yyy are the various protocols supported by libcurl. Both xxx
# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
# the macro for the complete list of possible defines. Shell
# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
# defined to 'yes' for those features and protocols that were found.
# Note that xxx and yyy keep the same capitalization as in the
# curl-config list (e.g. it's "HTTP" and not "http").
#
# Users may override the detected values by doing something like:
# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
#
# For the sake of sanity, this macro assumes that any libcurl that is
# found is after version 7.7.2, the first version that included the
# curl-config script. Note that it is very important for people
# packaging binary versions of libcurl to include this script!
# Without curl-config, we can only guess what protocols are available,
# or use curl_version_info to figure it out at runtime.
AC_DEFUN([LIBCURL_CHECK_CONFIG],
[
AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP])
AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3])
AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP])
AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP])
AC_ARG_WITH(libcurl,
AS_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]),
[_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
if test "$_libcurl_with" != "no" ; then
AC_PROG_AWK
_libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
_libcurl_try_link=yes
if test -d "$_libcurl_with" ; then
LIBCURL_CPPFLAGS="-I$withval/include"
_libcurl_ldflags="-L$withval/lib"
AC_PATH_PROG([_libcurl_config],[curl-config],[],
["$withval/bin"])
else
AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH])
fi
if test x$_libcurl_config != "x" ; then
AC_CACHE_CHECK([for the version of libcurl],
[libcurl_cv_lib_curl_version],
[libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
_libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
_libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
if test $_libcurl_wanted -gt 0 ; then
AC_CACHE_CHECK([for libcurl >= version $2],
[libcurl_cv_lib_version_ok],
[
if test $_libcurl_version -ge $_libcurl_wanted ; then
libcurl_cv_lib_version_ok=yes
else
libcurl_cv_lib_version_ok=no
fi
])
fi
if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
if test x"$LIBCURL_CPPFLAGS" = "x" ; then
LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
fi
if test x"$LIBCURL" = "x" ; then
LIBCURL=`$_libcurl_config --libs`
# This is so silly, but Apple actually has a bug in their
# curl-config script. Fixed in Tiger, but there are still
# lots of Panther installs around.
case "${host}" in
powerpc-apple-darwin7*)
LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
;;
esac
fi
# All curl-config scripts support --feature
_libcurl_features=`$_libcurl_config --feature`
# Is it modern enough to have --protocols? (7.12.4)
if test $_libcurl_version -ge 461828 ; then
_libcurl_protocols=`$_libcurl_config --protocols`
fi
else
_libcurl_try_link=no
fi
unset _libcurl_wanted
fi
if test $_libcurl_try_link = yes ; then
# we didn't find curl-config, so let's see if the user-supplied
# link line (or failing that, "-lcurl") is enough.
LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
AC_CACHE_CHECK([whether libcurl is usable],
[libcurl_cv_lib_curl_usable],
[
_libcurl_save_cppflags=$CPPFLAGS
CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
_libcurl_save_libs=$LIBS
LIBS="$LIBCURL $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curl/curl.h>]],[[
/* Try and use a few common options to force a failure if we are
missing symbols or can't link. */
int x;
curl_easy_setopt(NULL,CURLOPT_URL,NULL);
x=CURL_ERROR_SIZE;
x=CURLOPT_WRITEFUNCTION;
x=CURLOPT_WRITEDATA;
x=CURLOPT_ERRORBUFFER;
x=CURLOPT_STDERR;
x=CURLOPT_VERBOSE;
if (x) {;}
]])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
CPPFLAGS=$_libcurl_save_cppflags
LIBS=$_libcurl_save_libs
unset _libcurl_save_cppflags
unset _libcurl_save_libs
])
if test $libcurl_cv_lib_curl_usable = yes ; then
# Does curl_free() exist in this version of libcurl?
# If not, fake it with free()
_libcurl_save_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
_libcurl_save_libs=$LIBS
LIBS="$LIBS $LIBCURL"
AC_CHECK_FUNC(curl_free,,
AC_DEFINE(curl_free,free,
[Define curl_free() as free() if our version of curl lacks curl_free.]))
CPPFLAGS=$_libcurl_save_cppflags
LIBS=$_libcurl_save_libs
unset _libcurl_save_cppflags
unset _libcurl_save_libs
AC_DEFINE(HAVE_LIBCURL,1,
[Define to 1 if you have a functional curl library.])
AC_SUBST(LIBCURL_CPPFLAGS)
AC_SUBST(LIBCURL)
for _libcurl_feature in $_libcurl_features ; do
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
done
if test "x$_libcurl_protocols" = "x" ; then
# We don't have --protocols, so just assume that all
# protocols are available
_libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
if test x$libcurl_feature_SSL = xyes ; then
_libcurl_protocols="$_libcurl_protocols HTTPS"
# FTPS wasn't standards-compliant until version
# 7.11.0 (0x070b00 == 461568)
if test $_libcurl_version -ge 461568; then
_libcurl_protocols="$_libcurl_protocols FTPS"
fi
fi
# RTSP, IMAP, POP3 and SMTP were added in
# 7.20.0 (0x071400 == 463872)
if test $_libcurl_version -ge 463872; then
_libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP"
fi
fi
for _libcurl_protocol in $_libcurl_protocols ; do
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
done
else
unset LIBCURL
unset LIBCURL_CPPFLAGS
fi
fi
unset _libcurl_try_link
unset _libcurl_version_parse
unset _libcurl_config
unset _libcurl_feature
unset _libcurl_features
unset _libcurl_protocol
unset _libcurl_protocols
unset _libcurl_version
unset _libcurl_ldflags
fi
if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
# This is the IF-NO path
ifelse([$4],,:,[$4])
else
# This is the IF-YES path
ifelse([$3],,:,[$3])
fi
unset _libcurl_with
])dnl

View file

@ -53,16 +53,32 @@ AC_DEFUN([np_mysqlclient],
_savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $np_mysql_include"
np_check_lib_mysqlclient
CPPFLAGS=$_savedcppflags
fi
fi
])
dnl Test mysql_init using mysqlclient
AC_DEFUN([np_check_lib_mysqlclient],
[
dnl Putting $np_mysql_libs as other libraries ensures that all mysql dependencies are linked in
dnl Although -lmysqlclient is duplicated, it is not a problem
AC_CHECK_LIB([mysqlclient], [mysql_init], [
with_mysql=$np_mysql_config
AC_DEFINE(HAVE_MYSQLCLIENT, 1, [Defined if mysqlclient is found and can compile])
], [with_mysql=no], [$np_mysql_libs])
CPPFLAGS=$_savedcppflags
], [np_check_lib_mariadbclient], [$np_mysql_libs])
])
fi
fi
dnl Test mysql_init using mariadbclient
AC_DEFUN([np_check_lib_mariadbclient],
[
AC_CHECK_LIB([mariadbclient], [mysql_init], [
with_mysql=$np_mysql_config
AC_DEFINE(HAVE_MYSQLCLIENT, 1, [Defined if mariadbclient is found and can compile])
], [with_mysql=no], [$np_mysql_libs])
])
dnl Will take $1, find last occurrance of -LDIR and add DIR to LD_RUN_PATH

140
m4/uriparser.m4 Normal file
View file

@ -0,0 +1,140 @@
# (this check is rougly based on and inspired libcurl.m4)
# URIPARSER_CHECK ([DEFAULT-ACTION], [MINIMUM-VERSION],
# [ACTION-IF-YES], [ACTION-IF-NO])
# Checks for uriparser library. DEFAULT-ACTION is the string yes or no to
# specify whether to default to --with-uriparser or --without-liburiparser.
# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
# minimum version of uriparser to accept. Pass the version as a regular
# version number like 0.8.5. If not supplied, any version is
# accepted. ACTION-IF-YES is a list of shell commands to run if
# uriparser was successfully found and passed the various tests.
# ACTION-IF-NO is a list of shell commands that are run otherwise.
# Note that using --without-uriparser does run ACTION-IF-NO.
#
# This macro #defines HAVE_URIPARSER if a working uriparser setup is
# found, and sets @URIPARSER@ and @URIPARSER_CPPFLAGS@ to the necessary
# values.
#
# Users may override the detected values by doing something like:
# URIPARSER="-luriparser" URIPARSER_CPPFLAGS="-I/usr/myinclude" ./configure
#
AC_DEFUN([URIPARSER_CHECK],
[
AC_ARG_WITH(uriparser,
AS_HELP_STRING([--with-uriparser=PREFIX],[look for the uriparser library in PREFIX/lib and headers in PREFIX/include]),
[_uriparser_with=$withval],[_uriparser_with=ifelse([$1],,[yes],[$1])])
if test "$_uriparser_with" != "no" ; then
_uriparser_try_link=yes
AC_CHECK_PROG(PKGCONFIG,pkg-config,pkg-config,no)
if test "x$URIPARSER" != "x" || test "x$URIPARSER_CPPFLAGS" != "x"; then
:
elif test -d "$_uriparser_with" ; then
URIPARSER_CPPFLAGS="-I$withval/include"
_uriparser_ldflags="-L$withval/lib"
elif test x$PKGCONFIG != xno; then
AC_CACHE_CHECK([for the version of uriparser],
[uriparser_cv_uriparser_version],
[uriparser_cv_uriparser_version=`$PKGCONFIG liburiparser --modversion`])
AC_PROG_AWK
_uriparser_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
_uriparser_version=`echo $uriparser_cv_uriparser_version | $_uriparser_version_parse`
_uriparser_wanted=`echo ifelse([$2],,[0],[$2]) | $_uriparser_version_parse`
if test $_uriparser_wanted -gt 0 ; then
AC_CACHE_CHECK([for uriparser >= version $2],
[uriparser_cv_lib_version_ok],
[
if test $_uriparser_version -ge $_uriparser_wanted ; then
uriparser_cv_lib_version_ok=yes
else
uriparser_cv_lib_version_ok=no
fi
])
fi
if test $_uriparser_wanted -eq 0 || test x$uriparser_cv_lib_version_ok = xyes ; then
if test x"$URIPARSER_CPPFLAGS" = "x" ; then
URIPARSER_CPPFLAGS=`$PKGCONFIG liburiparser --cflags`
fi
if test x"$URIPARSER" = "x" ; then
URIPARSER=`$PKGCONFIG liburiparser --libs`
fi
else
_uriparser_try_link=no
fi
unset _uriparser_wanted
else
dnl no pkg-config, ok, do our best and set some defaults
URIPARSER_CPPFLAGS="-I/usr/include"
URIPARSER="-luriparser -L/usr/lib -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i686-linux-gnu"
fi
if test $_uriparser_try_link = yes ; then
# let's see if the user-supplied
# link line (or failing that, "-luriparser") is enough.
URIPARSER=${URIPARSER-"$_uriparser_ldflags -luriparser"}
AC_CACHE_CHECK([whether uriparser is usable],
[uriparser_cv_lib_uriparser_usable],
[
_liburiparser_save_cppflags=$CPPFLAGS
CPPFLAGS="$URIPARSER_CPPFLAGS $CPPFLAGS"
_liburiparser_save_libs=$LIBS
LIBS="$URIPARSER $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <uriparser/Uri.h>]],[[
/* Try and use a few common options to force a failure if we are
missing symbols or cannot link. */
UriParserStateA state;
UriUriA uri;
state.uri = &uri;
char *location = "http://test.dom/dir/file.ext";
int x = uriParseUriA (&state, location);
if (x == URI_SUCCESS) {;}
]])],uriparser_cv_lib_uriparser_usable=yes,uriparser_cv_lib_uriparser_usable=no)
CPPFLAGS=$_liburiparser_save_cppflags
LIBS=$_liburiparser_save_libs
unset _liburiparser_save_cppflags
unset _liburiparser_save_libs
])
if test $uriparser_cv_lib_uriparser_usable = yes ; then
AC_DEFINE(HAVE_URIPARSER,1,
[Define to 1 if you have a functional uriparser library.])
AC_SUBST(URIPARSER_CPPFLAGS)
AC_SUBST(URIPARSER)
else
unset URIPARSER
unset URIPARSER_CPPFLAGS
fi
fi
unset _uriparser_try_link
unset _uriparser_version_parse
unset _uriparser_version
unset _uriparser_ldflags
fi
if test x$_uriparser_with = xno || test x$uriparser_cv_lib_uriparser_usable != xyes ; then
# This is the IF-NO path
ifelse([$4],,:,[$4])
else
# This is the IF-YES path
ifelse([$3],,:,[$3])
fi
unset _uriparser_with
])dnl

Binary file not shown.

Binary file not shown.

1514
perlmods/Makefile Normal file

File diff suppressed because it is too large Load diff

14
perlmods/Makefile.am Normal file
View file

@ -0,0 +1,14 @@
perlmoduledir = $(exec_prefix)/perl
all-local:
$(top_srcdir)/tools/build_perl_modules -d $(perlmoduledir) -em .
install-exec-local:
$(top_srcdir)/tools/build_perl_modules -d $(perlmoduledir) -i .
# Don't run test-debug differently here yet
test test-debug:
$(top_srcdir)/tools/build_perl_modules -d $(perlmoduledir) -t .
clean-local:
$(top_srcdir)/tools/build_perl_modules -d $(perlmoduledir) -c .

1514
perlmods/Makefile.in Normal file

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

16
perlmods/install_order Normal file
View file

@ -0,0 +1,16 @@
# Modules installed in this order
default:
Test-Simple
Perl-OSType
Module-Implementation
Module-Metadata
version
Module-Build
Module-Runtime
parent
Try-Tiny
Params-Validate
Math-Calc-Units
Class-Accessor
Config-Tiny
Monitoring-Plugin

Binary file not shown.

Binary file not shown.

View file

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

View file

@ -55,8 +55,10 @@ EXTRA_PROGRAMS = pst3$(EXEEXT)
subdir = plugins-root
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -913,6 +915,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1038,6 +1045,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1255,6 +1263,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1265,6 +1278,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View file

@ -323,7 +323,8 @@ int get_hardware_address(int sock,char *interface_name){
#elif defined(__bsd__)
/* King 2004 see ACKNOWLEDGEMENTS */
int mib[6], len;
size_t len;
int mib[6];
char *buf;
unsigned char *ptr;
struct if_msghdr *ifm;
@ -693,7 +694,7 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
else{
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);
recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size);
if(verbose)
printf("recv_result: %d\n",recv_result);

View file

@ -67,7 +67,9 @@ const char *email = "devel@monitoring-plugins.org";
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/ip_icmp.h>
#include <netinet/icmp6.h>
#include <arpa/inet.h>
#include <signal.h>
#include <float.h>
@ -113,8 +115,8 @@ typedef struct rta_host {
unsigned short id; /* id in **table, and icmp pkts */
char *name; /* arg used for adding this host */
char *msg; /* icmp error message, if any */
struct sockaddr_in saddr_in; /* the address of this host */
struct in_addr error_addr; /* stores address of error replies */
struct sockaddr_storage saddr_in; /* the address of this host */
struct sockaddr_storage error_addr; /* stores address of error replies */
unsigned long long time_waited; /* total time waited, in usecs */
unsigned int icmp_sent, icmp_recv, icmp_lost; /* counters */
unsigned char icmp_type, icmp_code; /* type and code from errors */
@ -140,6 +142,18 @@ typedef struct icmp_ping_data {
unsigned short ping_id;
} icmp_ping_data;
typedef union ip_hdr {
struct ip ip;
struct ip6_hdr ip6;
} ip_hdr;
typedef union icmp_packet {
void *buf;
struct icmp *icp;
struct icmp6_hdr *icp6;
u_short *cksum_in;
} icmp_packet;
/* the different modes of this program are as follows:
* MODE_RTA: send all packets no matter what (mimic check_icmp and check_ping)
* MODE_HOSTCHECK: Return immediately upon any sign of life
@ -190,8 +204,9 @@ static int get_threshold(char *str, threshold *th);
static void run_checks(void);
static void set_source_ip(char *);
static int add_target(char *);
static int add_target_ip(char *, struct in_addr *);
static int handle_random_icmp(unsigned char *, struct sockaddr_in *);
static int add_target_ip(char *, struct sockaddr_storage *);
static int handle_random_icmp(unsigned char *, struct sockaddr_storage *);
static void parse_address(struct sockaddr_storage *, char *, int);
static unsigned short icmp_checksum(unsigned short *, int);
static void finish(int);
static void crash(const char *, ...);
@ -300,7 +315,7 @@ get_icmp_error_msg(unsigned char icmp_type, unsigned char icmp_code)
}
static int
handle_random_icmp(unsigned char *packet, struct sockaddr_in *addr)
handle_random_icmp(unsigned char *packet, struct sockaddr_storage *addr)
{
struct icmp p, sent_icmp;
struct rta_host *host = NULL;
@ -342,9 +357,11 @@ handle_random_icmp(unsigned char *packet, struct sockaddr_in *addr)
/* it is indeed a response for us */
host = table[ntohs(sent_icmp.icmp_seq)/packets];
if(debug) {
char address[INET6_ADDRSTRLEN];
parse_address(addr, address, sizeof(address));
printf("Received \"%s\" from %s for ICMP ECHO sent to %s.\n",
get_icmp_error_msg(p.icmp_type, p.icmp_code),
inet_ntoa(addr->sin_addr), host->name);
address, host->name);
}
icmp_lost++;
@ -364,11 +381,23 @@ handle_random_icmp(unsigned char *packet, struct sockaddr_in *addr)
}
host->icmp_type = p.icmp_type;
host->icmp_code = p.icmp_code;
host->error_addr.s_addr = addr->sin_addr.s_addr;
host->error_addr = *addr;
return 0;
}
void parse_address(struct sockaddr_storage *addr, char *address, int size)
{
switch (address_family) {
case AF_INET:
inet_ntop(address_family, &((struct sockaddr_in *)addr)->sin_addr, address, size);
break;
case AF_INET6:
inet_ntop(address_family, &((struct sockaddr_in6 *)addr)->sin6_addr, address, size);
break;
}
}
int
main(int argc, char **argv)
{
@ -381,6 +410,7 @@ main(int argc, char **argv)
#ifdef SO_TIMESTAMP
int on = 1;
#endif
char * opts_str = "vhVw:c:n:p:t:H:s:i:b:I:l:m:64";
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@ -390,33 +420,8 @@ main(int argc, char **argv)
* that before pointer magic (esp. on network data) */
icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0;
if((icmp_sock = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)) != -1)
sockets |= HAVE_ICMP;
else icmp_sockerrno = errno;
/* if((udp_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) != -1) */
/* sockets |= HAVE_UDP; */
/* else udp_sockerrno = errno; */
/* if((tcp_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) != -1) */
/* sockets |= HAVE_TCP; */
/* else tcp_sockerrno = errno; */
/* 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;
/* use the pid to mark packets as ours */
/* Some systems have 32-bit pid_t so mask off only 16 bits */
pid = getpid() & 0xffff;
/* printf("pid = %u\n", pid); */
address_family = -1;
int icmp_proto = IPPROTO_ICMP;
/* get calling name the old-fashioned way for portability instead
* of relying on the glibc-ism __progname */
@ -456,20 +461,35 @@ main(int argc, char **argv)
packets = 5;
}
/* Parse extra opts if any */
argv=np_extra_opts(&argc, argv, progname);
/* support "--help" and "--version" */
if(argc == 2) {
if(!strcmp(argv[1], "--help"))
strcpy(argv[1], "-h");
if(!strcmp(argv[1], "--version"))
strcpy(argv[1], "-V");
/* Parse protocol arguments first */
for(i = 1; i < argc; i++) {
while((arg = getopt(argc, argv, opts_str)) != EOF) {
unsigned short size;
switch(arg) {
case '4':
if (address_family != -1)
crash("Multiple protocol versions not supported");
address_family = AF_INET;
break;
case '6':
#ifdef USE_IPV6
if (address_family != -1)
crash("Multiple protocol versions not supported");
address_family = AF_INET6;
#else
usage (_("IPv6 support not available\n"));
#endif
break;
}
}
}
/* Reset argument scanning */
optind = 1;
/* 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) {
while((arg = getopt(argc, argv, opts_str)) != EOF) {
unsigned short size;
switch(arg) {
case 'v':
@ -530,10 +550,30 @@ main(int argc, char **argv)
case 'h': /* help */
print_help ();
exit (STATE_UNKNOWN);
break;
}
}
}
/* POSIXLY_CORRECT might break things, so unset it (the portable way) */
environ = NULL;
/* use the pid to mark packets as ours */
/* Some systems have 32-bit pid_t so mask off only 16 bits */
pid = getpid() & 0xffff;
/* printf("pid = %u\n", pid); */
/* Parse extra opts if any */
argv=np_extra_opts(&argc, argv, progname);
/* support "--help" and "--version" */
if(argc == 2) {
if(!strcmp(argv[1], "--help"))
strcpy(argv[1], "-h");
if(!strcmp(argv[1], "--version"))
strcpy(argv[1], "-V");
}
argv = &argv[optind];
while(*argv) {
add_target(*argv);
@ -545,6 +585,30 @@ main(int argc, char **argv)
exit(3);
}
// add_target might change address_family
switch ( address_family ){
case AF_INET: icmp_proto = IPPROTO_ICMP;
break;
case AF_INET6: icmp_proto = IPPROTO_ICMPV6;
break;
default: crash("Address family not supported");
}
if((icmp_sock = socket(address_family, SOCK_RAW, icmp_proto)) != -1)
sockets |= HAVE_ICMP;
else icmp_sockerrno = errno;
#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
/* now drop privileges (no effect if not setsuid or geteuid() == 0) */
if (setuid(getuid()) == -1) {
printf("ERROR: Failed to drop privileges\n");
return 1;
}
if(!sockets) {
if(icmp_sock == -1) {
errno = icmp_sockerrno;
@ -608,7 +672,7 @@ main(int argc, char **argv)
if(max_completion_time > (u_int)timeout * 1000000) {
printf("max_completion_time: %llu timeout: %u\n",
max_completion_time, timeout);
printf("Timout must be at lest %llu\n",
printf("Timeout must be at least %llu\n",
max_completion_time / 1000000 + 1);
}
}
@ -633,7 +697,7 @@ main(int argc, char **argv)
}
host = list;
table = malloc(sizeof(struct rta_host **) * targets);
table = (struct rta_host**)malloc(sizeof(struct rta_host **) * targets);
i = 0;
while(host) {
host->id = i*packets;
@ -697,9 +761,15 @@ run_checks()
}
}
/* response structure:
* IPv4:
* ip header : 20 bytes
* icmp header : 28 bytes
* IPv6:
* ip header : 40 bytes
* icmp header : 28 bytes
* both:
* icmp echo reply : the rest
*/
static int
@ -707,16 +777,27 @@ wait_for_reply(int sock, u_int t)
{
int n, hlen;
static unsigned char buf[4096];
struct sockaddr_in resp_addr;
struct ip *ip;
struct icmp icp;
struct sockaddr_storage resp_addr;
union ip_hdr *ip;
union icmp_packet packet;
struct rta_host *host;
struct icmp_ping_data data;
struct timeval wait_start, now;
u_int tdiff, i, per_pkt_wait;
if (!(packet.buf = malloc(icmp_pkt_size))) {
crash("send_icmp_ping(): failed to malloc %d bytes for send buffer",
icmp_pkt_size);
return -1; /* might be reached if we're in debug mode */
}
memset(packet.buf, 0, icmp_pkt_size);
/* if we can't listen or don't have anything to listen to, just return */
if(!t || !icmp_pkts_en_route) return 0;
if(!t || !icmp_pkts_en_route) {
free(packet.buf);
return 0;
}
gettimeofday(&wait_start, &tz);
@ -745,12 +826,23 @@ wait_for_reply(int sock, u_int t)
}
if(n < 0) {
if(debug) printf("recvfrom_wto() returned errors\n");
free(packet.buf);
return n;
}
ip = (struct ip *)buf;
if(debug > 1) printf("received %u bytes from %s\n",
ntohs(ip->ip_len), inet_ntoa(resp_addr.sin_addr));
// FIXME: with ipv6 we don't have an ip header here
if (address_family != AF_INET6) {
ip = (union ip_hdr *)buf;
if(debug > 1) {
char address[INET6_ADDRSTRLEN];
parse_address(&resp_addr, address, sizeof(address));
printf("received %u bytes from %s\n",
address_family == AF_INET6 ? ntohs(ip->ip6.ip6_plen)
: ntohs(ip->ip.ip_len),
address);
}
}
/* obsolete. alpha on tru64 provides the necessary defines, but isn't broken */
/* #if defined( __alpha__ ) && __STDC__ && !defined( __GLIBC__ ) */
@ -759,12 +851,14 @@ wait_for_reply(int sock, u_int t)
* off the bottom 4 bits */
/* hlen = (ip->ip_vhl & 0x0f) << 2; */
/* #else */
hlen = ip->ip_hl << 2;
hlen = (address_family == AF_INET6) ? 0 : ip->ip.ip_hl << 2;
/* #endif */
if(n < (hlen + ICMP_MINLEN)) {
char address[INET6_ADDRSTRLEN];
parse_address(&resp_addr, address, sizeof(address));
crash("received packet too short for ICMP (%d bytes, expected %d) from %s\n",
n, hlen + icmp_pkt_size, inet_ntoa(resp_addr.sin_addr));
n, hlen + icmp_pkt_size, address);
}
/* else if(debug) { */
/* printf("ip header size: %u, packet size: %u (expected %u, %u)\n", */
@ -773,23 +867,39 @@ wait_for_reply(int sock, u_int t)
/* } */
/* check the response */
memcpy(&icp, buf + hlen, sizeof(icp));
if(ntohs(icp.icmp_id) != pid || icp.icmp_type != ICMP_ECHOREPLY ||
ntohs(icp.icmp_seq) >= targets*packets) {
memcpy(packet.buf, buf + hlen, icmp_pkt_size);
/* address_family == AF_INET6 ? sizeof(struct icmp6_hdr)
: sizeof(struct icmp));*/
if( (address_family == PF_INET &&
(ntohs(packet.icp->icmp_id) != pid || packet.icp->icmp_type != ICMP_ECHOREPLY
|| ntohs(packet.icp->icmp_seq) >= targets * packets))
|| (address_family == PF_INET6 &&
(ntohs(packet.icp6->icmp6_id) != pid || packet.icp6->icmp6_type != ICMP6_ECHO_REPLY
|| ntohs(packet.icp6->icmp6_seq) >= targets * packets))) {
if(debug > 2) printf("not a proper ICMP_ECHOREPLY\n");
handle_random_icmp(buf + hlen, &resp_addr);
continue;
}
/* this is indeed a valid response */
memcpy(&data, icp.icmp_data, sizeof(data));
if (address_family == PF_INET) {
memcpy(&data, packet.icp->icmp_data, sizeof(data));
if (debug > 2)
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);
(unsigned long)sizeof(data), ntohs(packet.icp->icmp_id),
ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum);
host = table[ntohs(packet.icp->icmp_seq)/packets];
} else {
memcpy(&data, &packet.icp6->icmp6_dataun.icmp6_un_data8[4], sizeof(data));
if (debug > 2)
printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n",
(unsigned long)sizeof(data), ntohs(packet.icp6->icmp6_id),
ntohs(packet.icp6->icmp6_seq), packet.icp6->icmp6_cksum);
host = table[ntohs(packet.icp6->icmp6_seq)/packets];
}
host = table[ntohs(icp.icmp_seq)/packets];
tdiff = get_timevaldiff(&data.stime, &now);
host->time_waited += tdiff;
@ -801,9 +911,11 @@ wait_for_reply(int sock, u_int t)
host->rtmin = tdiff;
if(debug) {
char address[INET6_ADDRSTRLEN];
parse_address(&resp_addr, address, sizeof(address));
printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u, max: %0.3f, min: %0.3f\n",
(float)tdiff / 1000, inet_ntoa(resp_addr.sin_addr),
ttl, ip->ip_ttl, (float)host->rtmax / 1000, (float)host->rtmin / 1000);
(float)tdiff / 1000, address,
ttl, ip->ip.ip_ttl, (float)host->rtmax / 1000, (float)host->rtmin / 1000);
}
/* if we're in hostcheck mode, exit with limited printouts */
@ -817,6 +929,7 @@ wait_for_reply(int sock, u_int t)
}
}
free(packet.buf);
return 0;
}
@ -824,62 +937,81 @@ wait_for_reply(int sock, u_int t)
static int
send_icmp_ping(int sock, struct rta_host *host)
{
static union {
void *buf; /* re-use so we prevent leaks */
struct icmp *icp;
u_short *cksum_in;
} packet = { NULL };
long int len;
struct icmp_ping_data data;
struct msghdr hdr;
struct iovec iov;
struct timeval tv;
struct sockaddr *addr;
void *buf = NULL;
if(sock == -1) {
errno = 0;
crash("Attempt to send on bogus socket");
return -1;
}
addr = (struct sockaddr *)&host->saddr_in;
if(!packet.buf) {
if (!(packet.buf = malloc(icmp_pkt_size))) {
if(!buf) {
if (!(buf = malloc(icmp_pkt_size))) {
crash("send_icmp_ping(): failed to malloc %d bytes for send buffer",
icmp_pkt_size);
return -1; /* might be reached if we're in debug mode */
}
}
memset(packet.buf, 0, icmp_pkt_size);
memset(buf, 0, icmp_pkt_size);
if((gettimeofday(&tv, &tz)) == -1) return -1;
if((gettimeofday(&tv, &tz)) == -1) {
free(buf);
return -1;
}
data.ping_id = 10; /* host->icmp.icmp_sent; */
memcpy(&data.stime, &tv, sizeof(tv));
memcpy(&packet.icp->icmp_data, &data, sizeof(data));
packet.icp->icmp_type = ICMP_ECHO;
packet.icp->icmp_code = 0;
packet.icp->icmp_cksum = 0;
packet.icp->icmp_id = htons(pid);
packet.icp->icmp_seq = htons(host->id++);
packet.icp->icmp_cksum = icmp_checksum(packet.cksum_in, icmp_pkt_size);
if (address_family == AF_INET) {
struct icmp *icp = (struct icmp*)buf;
memcpy(&icp->icmp_data, &data, sizeof(data));
icp->icmp_type = ICMP_ECHO;
icp->icmp_code = 0;
icp->icmp_cksum = 0;
icp->icmp_id = htons(pid);
icp->icmp_seq = htons(host->id++);
icp->icmp_cksum = icmp_checksum((unsigned short*)buf, icmp_pkt_size);
if (debug > 2)
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);
(unsigned long)sizeof(data), ntohs(icp->icmp_id), ntohs(icp->icmp_seq), icp->icmp_cksum, host->name);
}
else {
struct icmp6_hdr *icp6 = (struct icmp6_hdr*)buf;
memcpy(&icp6->icmp6_dataun.icmp6_un_data8[4], &data, sizeof(data));
icp6->icmp6_type = ICMP6_ECHO_REQUEST;
icp6->icmp6_code = 0;
icp6->icmp6_cksum = 0;
icp6->icmp6_id = htons(pid);
icp6->icmp6_seq = htons(host->id++);
// let checksum be calculated automatically
if (debug > 2) {
printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n",
(unsigned long)sizeof(data), ntohs(icp6->icmp6_id),
ntohs(icp6->icmp6_seq), icp6->icmp6_cksum, host->name);
}
}
memset(&iov, 0, sizeof(iov));
iov.iov_base = packet.buf;
iov.iov_base = buf;
iov.iov_len = icmp_pkt_size;
memset(&hdr, 0, sizeof(hdr));
hdr.msg_name = addr;
hdr.msg_namelen = sizeof(struct sockaddr);
hdr.msg_name = (struct sockaddr *)&host->saddr_in;
hdr.msg_namelen = sizeof(struct sockaddr_storage);
hdr.msg_iov = &iov;
hdr.msg_iovlen = 1;
errno = 0;
/* 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);
@ -887,9 +1019,15 @@ send_icmp_ping(int sock, struct rta_host *host)
len = sendmsg(sock, &hdr, 0);
#endif
free(buf);
if(len < 0 || (unsigned int)len != icmp_pkt_size) {
if(debug) printf("Failed to send ping to %s\n",
inet_ntoa(host->saddr_in.sin_addr));
if(debug) {
char address[INET6_ADDRSTRLEN];
parse_address((struct sockaddr_storage *)&host->saddr_in, address, sizeof(address));
printf("Failed to send ping to %s: %s\n", address, strerror(errno));
}
errno = 0;
return -1;
}
@ -934,7 +1072,7 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
if(!n) return 0; /* timeout */
slen = sizeof(struct sockaddr);
slen = sizeof(struct sockaddr_storage);
memset(&iov, 0, sizeof(iov));
iov.iov_base = buf;
@ -958,6 +1096,7 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
break ;
}
}
if (!chdr)
#endif // SO_TIMESTAMP
gettimeofday(tv, &tz);
@ -991,6 +1130,7 @@ finish(int sig)
/* iterate thrice to calculate values, give output, and print perfparse */
host = list;
while(host) {
if(!host->icmp_recv) {
/* rta 0 is ofcourse not entirely correct, but will still show up
@ -1039,10 +1179,12 @@ finish(int sig)
if(!host->icmp_recv) {
status = STATE_CRITICAL;
if(host->flags & FLAG_LOST_CAUSE) {
char address[INET6_ADDRSTRLEN];
parse_address(&host->error_addr, address, sizeof(address));
printf("%s: %s @ %s. rta nan, lost %d%%",
host->name,
get_icmp_error_msg(host->icmp_type, host->icmp_code),
inet_ntoa(host->error_addr),
address,
100);
}
else { /* not marked as lost cause, so we have no flags for it */
@ -1104,7 +1246,6 @@ get_timevaldiff(struct timeval *early, struct timeval *later)
{
return 0;
}
ret = (later->tv_sec - early->tv_sec) * 1000000;
ret += later->tv_usec - early->tv_usec;
@ -1112,18 +1253,35 @@ get_timevaldiff(struct timeval *early, struct timeval *later)
}
static int
add_target_ip(char *arg, struct in_addr *in)
add_target_ip(char *arg, struct sockaddr_storage *in)
{
struct rta_host *host;
struct sockaddr_in *sin, *host_sin;
struct sockaddr_in6 *sin6, *host_sin6;
/* disregard obviously stupid addresses */
if(in->s_addr == INADDR_NONE || in->s_addr == INADDR_ANY)
if (address_family == AF_INET)
sin = (struct sockaddr_in *)in;
else
sin6 = (struct sockaddr_in6 *)in;
/* disregard obviously stupid addresses
* (I didn't find an ipv6 equivalent to INADDR_NONE) */
if (((address_family == AF_INET && (sin->sin_addr.s_addr == INADDR_NONE
|| sin->sin_addr.s_addr == INADDR_ANY)))
|| (address_family == AF_INET6 && (sin6->sin6_addr.s6_addr == in6addr_any.s6_addr))) {
return -1;
}
/* no point in adding two identical IP's, so don't. ;) */
host = list;
while(host) {
if(host->saddr_in.sin_addr.s_addr == in->s_addr) {
host_sin = (struct sockaddr_in *)&host->saddr_in;
host_sin6 = (struct sockaddr_in6 *)&host->saddr_in;
if( (address_family == AF_INET && host_sin->sin_addr.s_addr == sin->sin_addr.s_addr)
|| (address_family == AF_INET6 && host_sin6->sin6_addr.s6_addr == sin6->sin6_addr.s6_addr)) {
if(debug) printf("Identical IP already exists. Not adding %s\n", arg);
return -1;
}
@ -1131,19 +1289,29 @@ add_target_ip(char *arg, struct in_addr *in)
}
/* add the fresh ip */
host = malloc(sizeof(struct rta_host));
host = (struct rta_host*)malloc(sizeof(struct rta_host));
if(!host) {
char straddr[INET6_ADDRSTRLEN];
parse_address((struct sockaddr_storage*)&in, straddr, sizeof(straddr));
crash("add_target_ip(%s, %s): malloc(%d) failed",
arg, inet_ntoa(*in), sizeof(struct rta_host));
arg, straddr, sizeof(struct rta_host));
}
memset(host, 0, sizeof(struct rta_host));
/* set the values. use calling name for output */
host->name = strdup(arg);
/* fill out the sockaddr_in struct */
host->saddr_in.sin_family = AF_INET;
host->saddr_in.sin_addr.s_addr = in->s_addr;
/* fill out the sockaddr_storage struct */
if(address_family == AF_INET) {
host_sin = (struct sockaddr_in *)&host->saddr_in;
host_sin->sin_family = AF_INET;
host_sin->sin_addr.s_addr = sin->sin_addr.s_addr;
}
else {
host_sin6 = (struct sockaddr_in6 *)&host->saddr_in;
host_sin6->sin6_family = AF_INET6;
memcpy(host_sin6->sin6_addr.s6_addr, sin6->sin6_addr.s6_addr, sizeof host_sin6->sin6_addr.s6_addr);
}
host->rtmin = DBL_MAX;
@ -1160,31 +1328,67 @@ add_target_ip(char *arg, struct in_addr *in)
static int
add_target(char *arg)
{
int i;
struct hostent *he;
struct in_addr *in, ip;
int error, result;
struct sockaddr_storage ip;
struct addrinfo hints, *res, *p;
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
switch (address_family) {
case -1:
/* -4 and -6 are not specified on cmdline */
address_family = AF_INET;
sin = (struct sockaddr_in *)&ip;
result = inet_pton(address_family, arg, &sin->sin_addr);
#ifdef USE_IPV6
if( result != 1 ){
address_family = AF_INET6;
sin6 = (struct sockaddr_in6 *)&ip;
result = inet_pton(address_family, arg, &sin6->sin6_addr);
}
#endif
/* If we don't find any valid addresses, we still don't know the address_family */
if ( result != 1) {
address_family = -1;
}
break;
case AF_INET:
sin = (struct sockaddr_in *)&ip;
result = inet_pton(address_family, arg, &sin->sin_addr);
break;
case AF_INET6:
sin6 = (struct sockaddr_in6 *)&ip;
result = inet_pton(address_family, arg, &sin6->sin6_addr);
break;
default: crash("Address family not supported");
}
/* don't resolve if we don't have to */
if((ip.s_addr = inet_addr(arg)) != INADDR_NONE) {
if(result == 1) {
/* don't add all ip's if we were given a specific one */
return add_target_ip(arg, &ip);
/* he = gethostbyaddr((char *)in, sizeof(struct in_addr), AF_INET); */
/* if(!he) return add_target_ip(arg, in); */
}
else {
errno = 0;
he = gethostbyname(arg);
if(!he) {
memset(&hints, 0, sizeof(hints));
if (address_family == -1) {
hints.ai_family = AF_UNSPEC;
} else {
hints.ai_family = address_family == AF_INET ? PF_INET : PF_INET6;
}
hints.ai_socktype = SOCK_RAW;
if((error = getaddrinfo(arg, NULL, &hints, &res)) != 0) {
errno = 0;
crash("Failed to resolve %s", arg);
crash("Failed to resolve %s: %s", arg, gai_strerror(error));
return -1;
}
address_family = res->ai_family;
}
/* possibly add all the IP's as targets */
for(i = 0; he->h_addr_list[i]; i++) {
in = (struct in_addr *)he->h_addr_list[i];
add_target_ip(arg, in);
for(p = res; p != NULL; p = p->ai_next) {
memcpy(&ip, p->ai_addr, p->ai_addrlen);
add_target_ip(arg, &ip);
/* this is silly, but it works */
if(mode == MODE_HOSTCHECK || mode == MODE_ALL) {
@ -1193,6 +1397,7 @@ add_target(char *arg)
}
break;
}
freeaddrinfo(res);
return 0;
}
@ -1203,7 +1408,7 @@ set_source_ip(char *arg)
struct sockaddr_in src;
memset(&src, 0, sizeof(src));
src.sin_family = AF_INET;
src.sin_family = address_family;
if((src.sin_addr.s_addr = inet_addr(arg)) == INADDR_NONE)
src.sin_addr.s_addr = get_ip_address(arg);
if(bind(icmp_sock, (struct sockaddr *)&src, sizeof(src)) == -1)
@ -1311,12 +1516,12 @@ get_threshold(char *str, threshold *th)
unsigned short
icmp_checksum(unsigned short *p, int n)
{
register unsigned short cksum;
register long sum = 0;
unsigned short cksum;
long sum = 0;
while(n > 1) {
while(n > 2) {
sum += *p++;
n -= 2;
n -= sizeof(unsigned short);
}
/* mop up the occasional odd byte */
@ -1347,6 +1552,8 @@ print_help(void)
printf (" %s\n", "-H");
printf (" %s\n", _("specify a target"));
printf (" %s\n", "[-4|-6]");
printf (" %s\n", _("Use IPv4 (default) or IPv6 to communicate with the targets"));
printf (" %s\n", "-w");
printf (" %s", _("warning threshold (currently "));
printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000, warn.pl);

View file

@ -16,11 +16,13 @@ VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/
libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
check_log check_oracle check_rpc check_sensors check_wave \
check_ifstatus check_ifoperstatus check_mailq check_file_age \
check_uptime \
utils.sh utils.pm
EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \
check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
check_uptime.pl \
utils.sh.in utils.pm.in t
EDIT = sed \

View file

@ -53,8 +53,10 @@ subdir = plugins-scripts
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/utils.pm.in $(srcdir)/utils.sh.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -910,6 +912,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1035,6 +1042,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1252,6 +1260,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1262,6 +1275,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@ -1328,11 +1342,13 @@ SUFFIXES = .pl .sh
libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
check_log check_oracle check_rpc check_sensors check_wave \
check_ifstatus check_ifoperstatus check_mailq check_file_age \
check_uptime \
utils.sh utils.pm
EXTRA_DIST = check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \
check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
check_uptime.pl \
utils.sh.in utils.pm.in t
EDIT = sed \

View file

@ -19,7 +19,7 @@
#
require 5.004;
use POSIX;
use POSIX qw(setsid);
use strict;
use Getopt::Long;
use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose);
@ -28,6 +28,9 @@ use FindBin;
use lib "$FindBin::Bin";
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
# make us session leader which makes all childs exit if we do
setsid;
sub print_help ();
sub print_usage ();
@ -175,6 +178,8 @@ my @lines = undef;
# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print "No Answer from Client\n";
$SIG{'INT'} = 'IGNORE';
kill(-2, $$);
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);

View file

@ -43,8 +43,6 @@ $ENV{'ENV'}='';
$opt_w = 240;
$opt_c = 600;
$opt_W = 0;
$opt_C = 0;
$opt_f = "";
Getopt::Long::Configure('bundling');
@ -53,10 +51,10 @@ GetOptions(
"h" => \$opt_h, "help" => \$opt_h,
"i" => \$opt_i, "ignore-missing" => \$opt_i,
"f=s" => \$opt_f, "file" => \$opt_f,
"w=f" => \$opt_w, "warning-age=f" => \$opt_w,
"W=f" => \$opt_W, "warning-size=f" => \$opt_W,
"c=f" => \$opt_c, "critical-age=f" => \$opt_c,
"C=f" => \$opt_C, "critical-size=f" => \$opt_C);
"w=s" => \$opt_w, "warning-age=s" => \$opt_w,
"W=s" => \$opt_W, "warning-size=s" => \$opt_W,
"c=s" => \$opt_c, "critical-age=s" => \$opt_c,
"C=s" => \$opt_C, "critical-size=s" => \$opt_C);
if ($opt_V) {
print_revision($PROGNAME, '@NP_VERSION@');
@ -91,18 +89,47 @@ unless (-e $opt_f) {
$st = File::stat::stat($opt_f);
$age = time - $st->mtime;
$size = $st->size;
$perfdata = "age=${age}s;${opt_w};${opt_c} size=${size}B;${opt_W};${opt_C};0";
$result = 'OK';
if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) {
if ($opt_c !~ m/^\d+$/ or ($opt_C and $opt_C !~ m/^\d+$/)
or $opt_w !~ m/^\d+$/ or ($opt_W and $opt_W !~ m/^\d+$/)) {
# range has been specified so use M::P::R to process
require Monitoring::Plugin::Range;
# use permissive range defaults for size when none specified
$opt_W = "0:" unless ($opt_W);
$opt_C = "0:" unless ($opt_C);
if (Monitoring::Plugin::Range->parse_range_string($opt_c)
->check_range($age) == 1) { # 1 means it raises an alert because it's OUTSIDE the range
$result = 'CRITICAL';
}
elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) {
}
elsif (Monitoring::Plugin::Range->parse_range_string($opt_C)
->check_range($size) == 1) {
$result = 'CRITICAL';
}
elsif (Monitoring::Plugin::Range->parse_range_string($opt_w)
->check_range($age) == 1) {
$result = 'WARNING';
}
elsif (Monitoring::Plugin::Range->parse_range_string($opt_W)
->check_range($size) == 1) {
$result = 'WARNING';
}
}
else {
# use permissive defaults for size when none specified
$opt_W = 0 unless ($opt_W);
$opt_C = 0 unless ($opt_C);
if ($age > $opt_c or $size < $opt_C) {
$result = 'CRITICAL';
}
elsif ($age > $opt_w or $size < $opt_W) {
$result = 'WARNING';
}
}
$perfdata = "age=${age}s;${opt_w};${opt_c} size=${size}B;${opt_W};${opt_C};0";
print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes | $perfdata\n";
exit $ERRORS{$result};
@ -120,7 +147,15 @@ sub print_help () {
print "\n";
print " -i | --ignore-missing : return OK if the file does not exist\n";
print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n";
print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n";
print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n\n";
print " Both <secs> and <size> can specify a range using the standard plugin syntax\n";
print " If any of the warning and critical arguments are in range syntax (not just bare numbers)\n";
print " then all warning and critical arguments will be interpreted as ranges.\n";
print " To use range processing the perl module Monitoring::Plugin must be installed\n";
print " For range syntax see https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n";
print " It is strongly recommended when using range syntax that all four of -w, -W, -c and -C are specified\n";
print " otherwise it is unlikely that the size test will be doing what is desired\n";
print "\n";
support();
}

View file

@ -568,7 +568,9 @@ sub process_arguments(){
"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,
"s" => \$opt_s, "sudo" => \$opt_s
"s" => \$opt_s, "sudo" => \$opt_s,
"W=i" => \$opt_W, # warning if above this number
"C=i" => \$opt_C, # critical if above this number
);
if ($opt_V) {
@ -662,8 +664,8 @@ sub print_help () {
print " Feedback/patches to support non-sendmail mailqueue welcome\n\n";
print "-w (--warning) = Min. number of messages in queue to generate warning\n";
print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n";
print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n";
print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
print "-W = Min. number of messages for same domain in queue to generate warning\n";
print "-C = 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";

315
plugins-scripts/check_uptime.pl Executable file
View file

@ -0,0 +1,315 @@
#!@PERL@ -w
# check_uptime - check uptime to see how long the system is running.
#
# License Information:
# 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 2 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, write to the Free Software
# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
#
############################################################################
use POSIX;
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c
$opt_f $opt_s
$lower_warn_threshold $upper_warn_threshold
$lower_crit_threshold $upper_crit_threshold
$status $state $msg);
use FindBin;
use lib "$FindBin::Bin";
use utils qw(%ERRORS &print_revision &support &usage );
sub print_help ();
sub print_usage ();
sub process_arguments ();
$ENV{'PATH'}='@TRUSTED_PATH@';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
$PROGNAME = "check_uptime";
$state = $ERRORS{'UNKNOWN'};
my $uptime_file = "/proc/uptime";
# Process arguments
Getopt::Long::Configure('bundling');
$status = process_arguments();
if ($status){
print "ERROR: processing arguments\n";
exit $ERRORS{"UNKNOWN"};
}
# Get uptime info from file
if ( ! -r $uptime_file ) {
print "ERROR: file '$uptime_file' is not readable\n";
exit $ERRORS{"UNKNOWN"};
}
if ( ! open FILE, "<", $uptime_file ) {
print "ERROR: cannot read from file '$uptime_file'\n";
exit $ERRORS{"UNKNOWN"};
}
chomp( my $file_content = <FILE> );
close FILE;
print "$uptime_file: $file_content\n" if $verbose;
# Get first digit value (without fraction)
my ( $uptime_seconds ) = $file_content =~ /^([\d]+)/;
# Bail out if value is not numeric
if ( $uptime_seconds !~ /^\d+$/ ) {
print "ERROR: no numeric value: $uptime_seconds\n";
exit $ERRORS{"UNKNOWN"};
}
# Do calculations for a "pretty" format (2 weeks, 5 days, ...)
my ( $secs, $mins, $hours, $days, $weeks );
$secs = $uptime_seconds;
$mins = $hours = $days = $weeks = 0;
if ( $secs > 100 ) {
$mins = int( $secs / 60 );
$secs -= $mins * 60;
}
if ( $mins > 100 ) {
$hours = int( $mins / 60 );
$mins -= $hours * 60;
}
if ( $hours > 48 ) {
$days = int( $hours / 24 );
$hours -= $days * 24;
}
if ( $days > 14 ) {
$weeks = int( $days / 7 );
$days -= $weeks * 7;
}
my $pretty_uptime = "";
$pretty_uptime .= sprintf( "%d week%s, ", $weeks, $weeks == 1 ? "" : "s" ) if $weeks;
$pretty_uptime .= sprintf( "%d day%s, ", $days, $days == 1 ? "" : "s" ) if $days;
$pretty_uptime .= sprintf( "%d hour%s, ", $hours, $hours == 1 ? "" : "s" ) if $hours;
$pretty_uptime .= sprintf( "%d minute%s, ", $mins, $mins == 1 ? "" : "s" ) if $mins;
# Replace last occurence of comma with "and"
$pretty_uptime =~ s/, $/ and /;
# Always print the seconds (though it may be 0 seconds)
$pretty_uptime .= sprintf( "%d second%s", $secs, $secs == 1 ? "" : "s" );
# Default to catch errors in program
my $state_str = "UNKNOWN";
# Check values
my $out_of_bounds_text = "";
if ( $uptime_seconds > $upper_crit_threshold ) {
$state_str = "CRITICAL";
$out_of_bounds_text = "upper crit";
} elsif ( $uptime_seconds < $lower_crit_threshold ) {
$state_str = "CRITICAL";
$out_of_bounds_text = "lower crit";
} elsif ( $uptime_seconds > $upper_warn_threshold ) {
$state_str = "WARNING";
$out_of_bounds_text = "upper warn";
} elsif ( $uptime_seconds < $lower_warn_threshold ) {
$state_str = "WARNING";
$out_of_bounds_text = "lower warn";
} else {
$state_str = "OK";
}
$msg = "$state_str: ";
$msg .= "uptime is $uptime_seconds seconds. ";
$msg .= "Exceeds $out_of_bounds_text threshold. " if $out_of_bounds_text;
$msg .= "Running for $pretty_uptime. " if $opt_f;
if ( $opt_s ) {
my $up_since = strftime( "%Y-%m-%d %H:%M:%S", localtime( time - $uptime_seconds ) );
$msg .= "Running since $up_since. ";
}
$state = $ERRORS{$state_str};
# Perfdata support
print "$msg|uptime=${uptime_seconds}s;$upper_warn_threshold;$upper_crit_threshold;0\n";
exit $state;
#####################################
#### subs
sub process_arguments(){
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"v" => \$opt_v, "verbose" => \$opt_v,
"h" => \$opt_h, "help" => \$opt_h,
"w=s" => \$opt_w, "warning=s" => \$opt_w, # warning if above this number
"c=s" => \$opt_c, "critical=s" => \$opt_c, # critical if above this number
"f" => \$opt_f, "for" => \$opt_f, # show "running for ..."
"s" => \$opt_s, "since" => \$opt_s, # show "running since ..."
);
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'UNKNOWN'};
}
if (defined $opt_v) {
$verbose = $opt_v;
}
unless ( defined $opt_w && defined $opt_c ) {
print_usage();
exit $ERRORS{'UNKNOWN'};
}
# Check if a range was supplied ("lowvalue:highvalue") for warning and critical
# Otherwise, set 0 as the lower threshold and the parameter value as upper threshold
# (the uptime should always be positive, so there should be no issue)
if ( $opt_w =~ /^(.+):(.+)$/ ) {
$lower_warn_threshold = $1;
$upper_warn_threshold = $2;
} else {
$lower_warn_threshold = 0;
$upper_warn_threshold = $opt_w;
}
if ( $opt_c =~ /^(.+):(.+)$/ ) {
$lower_crit_threshold = $1;
$upper_crit_threshold = $2;
} else {
$lower_crit_threshold = 0;
$upper_crit_threshold = $opt_c;
}
# Set as seconds (calculate if suffix present)
$lower_warn_threshold = calc_as_seconds( $lower_warn_threshold );
$lower_crit_threshold = calc_as_seconds( $lower_crit_threshold );
$upper_warn_threshold = calc_as_seconds( $upper_warn_threshold );
$upper_crit_threshold = calc_as_seconds( $upper_crit_threshold );
# Check for numeric value of warning parameter
if ( $lower_warn_threshold !~ /^\d+$/ ) {
print "Lower warning (-w) is not numeric\n";
exit $ERRORS{'UNKNOWN'};
}
if ( $upper_warn_threshold !~ /^\d+$/ ) {
print "Upper warning (-w) is not numeric\n";
exit $ERRORS{'UNKNOWN'};
}
# Check for numeric value of critical parameter
if ( $lower_crit_threshold !~ /^\d+$/ ) {
print "Lower critical (-c) is not numeric\n";
exit $ERRORS{'UNKNOWN'};
}
if ( $upper_crit_threshold !~ /^\d+$/ ) {
print "Upper critical (-c) is not numeric\n";
exit $ERRORS{'UNKNOWN'};
}
# Check boundaries
if ( $upper_warn_threshold >= $upper_crit_threshold ) {
print "Upper Warning (-w) cannot be greater than Critical (-c)!\n";
exit $ERRORS{'UNKNOWN'};
}
# No "<=" since both values are zero if no range (only upper threshold values) is given
if ( $lower_warn_threshold < $lower_crit_threshold ) {
print "Lower Warning (-w) cannot be less than Critical (-c)!\n";
exit $ERRORS{'UNKNOWN'};
}
return $ERRORS{'OK'};
}
sub print_usage () {
print "Usage: $PROGNAME -w <warn> -c <crit> [-v]\n";
}
sub print_help () {
print_revision($PROGNAME,'@NP_VERSION@');
print "Copyright (c) 2002 Subhendu Ghosh/Carlos Canau/Benjamin Schmid\n";
print "Copyright (c) 2018 Bernd Arnold\n";
print "\n";
print_usage();
print "\n";
print " Checks the uptime of the system using $uptime_file\n";
print "\n";
print "-w (--warning) = Min. number of uptime to generate warning\n";
print "-c (--critical) = Min. number of uptime to generate critical alert ( w < c )\n";
print "-f (--for) = Show uptime in a pretty format (Running for x weeks, x days, ...)\n";
print "-s (--since) = Show last boot in yyyy-mm-dd HH:MM:SS format (output from 'uptime -s')\n";
print "-h (--help)\n";
print "-V (--version)\n";
print "-v (--verbose) = debugging output\n";
print "\n\n";
print "Note: -w and -c are required arguments.\n";
print " You can suffix both values with s for seconds (default), m (minutes), h (hours), d (days) or w (weeks).\n";
print "\n";
print "Range support: You may specify a range for both warning and critical thresholds.\n";
print " This works without additional Perl modules.\n";
print "Example: ./check_uptime -w 10m:4w -c 1m:8w\n";
print " Results in a critical state when uptime is below 60 seconds or higher than 8 weeks,\n";
print " and in a warning state when uptime is below 10 minutes or above 4 weeks.\n";
print "\n\n";
support();
}
sub calc_as_seconds () {
my $parameter = shift;
# Check if suffix is present
# Calculate parameter to seconds (to get an integer value finally)
# If no suffix is present, just return the value
# Possible suffixes:
# s = seconds
# m = minutes
# h = hours
# d = days
# w = weeks
my %factor = ( "s" => 1,
"m" => 60,
"h" => 60 * 60,
"d" => 60 * 60 * 24,
"w" => 60 * 60 * 24 * 7,
);
if ( $parameter =~ /^(\d+)([a-z])$/ ) {
my $value = $1;
my $suffix = $2;
print "detected: value=$value, suffix=$suffix\n" if $verbose;
if ( ! defined $factor{$suffix} ) {
print "Error: wrong suffix ($suffix) for value '$parameter'";
exit $ERRORS{'UNKNOWN'};
}
$parameter = $value * $factor{$suffix};
}
return $parameter;
}

View file

@ -5,14 +5,14 @@
#
use strict;
use Test::More tests => 17;
use Test::More tests => 27;
use NPTest;
my $successOutput = '/^FILE_AGE OK: /';
my $warningOutput = '/^FILE_AGE WARNING: /';
my $criticalOutput = '/^FILE_AGE CRITICAL: /';
my $unknownOutput = '/^FILE_AGE UNKNOWN: /';
my $performanceOutput = '/ \| age=[0-9]+s;[0-9]+;[0-9]+ size=[0-9]+B;[0-9]+;[0-9]+;0$/';
my $performanceOutput = '/ \| age=[0-9]+s;[0-9:]+;[0-9:]+ size=[0-9]+B;[0-9:]+;[0-9:]+;0$/';
my $result;
my $temp_file = "/tmp/check_file_age.tmp";
@ -20,64 +20,75 @@ my $temp_link = "/tmp/check_file_age.link.tmp";
unlink $temp_file, $temp_link;
$result = NPTest->testCmd(
"./check_file_age"
);
$result = NPTest->testCmd("./check_file_age");
cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
like ( $result->output, $unknownOutput, "Output for unknown correct" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file");
cmp_ok( $result->return_code, '==', 2, "File not exists" );
like ( $result->output, $criticalOutput, "Output for file missing correct" );
write_chars(100);
$result = NPTest->testCmd(
"./check_file_age -f $temp_file"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file");
cmp_ok( $result->return_code, '==', 0, "File is new enough" );
like ( $result->output, $successOutput, "Output for success correct" );
sleep 2;
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -w 1"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file -w 1");
cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" );
like ( $result->output, $warningOutput, "Output for warning correct" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1");
cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" );
like ( $result->output, $criticalOutput, "Output for critical correct" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1000 -W 100"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
cmp_ok( $result->return_code, '==', 0, "Checking file size" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1000 -W 100"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
like( $result->output, $performanceOutput, "Checking for performance Output" );
$result = NPTest->testCmd(
"./check_file_age -f /non/existent --ignore-missing"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
like( $result->output, $performanceOutput, "Checking for performance Output from range" );
$result = NPTest->testCmd("./check_file_age -f /non/existent --ignore-missing");
cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1000 -W 101"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101");
cmp_ok( $result->return_code, '==', 1, "One byte too short" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1000 -C 101"
);
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101");
cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" );
SKIP: {
eval 'use Monitoring::Plugin::Range';
skip "Monitoring::Plugin::Range module require", 9 if $@;
$result = NPTest->testCmd("./check_file_age -f $temp_file -w 0:1");
cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" );
like ( $result->output, $warningOutput, "Output for warning by range correct" );
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1");
cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" );
like ( $result->output, $criticalOutput, "Output for critical by range correct" );
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1000 -W 0:100");
cmp_ok( $result->return_code, '==', 0, "Checking file size by range" );
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101:");
cmp_ok( $result->return_code, '==', 1, "One byte too short by range" );
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 0:99");
cmp_ok( $result->return_code, '==', 1, "One byte too long by range" );
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101:");
cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" );
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 0:99");
cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" );
};
symlink $temp_file, $temp_link or die "Cannot create symlink";
$result = NPTest->testCmd("./check_file_age -f $temp_link -c 10");
cmp_ok( $result->return_code, '==', 0, "Works for symlinks" );

View file

@ -0,0 +1,129 @@
#!/usr/bin/perl -w -I ..
#
# check_uptime tests
#
#
use strict;
use Test::More tests => 40;
use NPTest;
my $result;
$result = NPTest->testCmd(
"./check_uptime"
);
cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
like ( $result->output, '/^Usage: check_uptime -w/', "Output for missing parameters correct" );
$result = NPTest->testCmd(
"./check_uptime --help"
);
cmp_ok( $result->return_code, '==', 3, "Help output requested" );
like ( $result->output, '/ABSOLUTELY NO WARRANTY/', "Output for help correct" );
$result = NPTest->testCmd(
"./check_uptime -w 5 -c 2"
);
cmp_ok( $result->return_code, '==', 3, "Warning greater than critical" );
like ( $result->output, '/^Upper Warning .*cannot be greater than Critical/', "Output for warning greater than critical correct" );
$result = NPTest->testCmd(
"./check_uptime -c 1000 -W 100 2>&1"
);
like ( $result->output, '/^Unknown option: W/', "Output with wrong parameter is correct" );
$result = NPTest->testCmd(
"./check_uptime -f -w 1 -c 2"
);
cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
like ( $result->output, '/Running for \d+/', "Output for the f parameter correct" );
$result = NPTest->testCmd(
"./check_uptime -s -w 1 -c 2"
);
cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
like ( $result->output, '/Running since \d+/', "Output for the s parameter correct" );
$result = NPTest->testCmd(
"./check_uptime -w 1 -c 2"
);
cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
like ( $result->output, '/^CRITICAL: uptime is \d+ seconds/', "Output for uptime higher than 2 seconds correct" );
$result = NPTest->testCmd(
"./check_uptime -w 1 -c 9999w"
);
cmp_ok( $result->return_code, '==', 1, "Uptime lower than 9999 weeks" );
like ( $result->output, '/^WARNING: uptime is \d+ seconds/', "Output for uptime lower than 9999 weeks correct" );
$result = NPTest->testCmd(
"./check_uptime -w 9998w -c 9999w"
);
cmp_ok( $result->return_code, '==', 0, "Uptime lower than 9998 weeks" );
like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 9998 weeks correct" );
like ( $result->output, '/\|uptime=[0-9]+s;6046790400;6047395200;/', "Checking for performance output" );
$result = NPTest->testCmd(
"./check_uptime -w 111222d -c 222333d"
);
cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days" );
like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" );
like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
# Same as before, hopefully uptime is higher than 2 seconds so no warning
$result = NPTest->testCmd(
"./check_uptime -w 2:111222d -c 1:222333d"
);
cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days, and higher 2 seconds" );
like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days, and higher 2 seconds correct" );
like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
# Same as before, now the low warning should trigger
$result = NPTest->testCmd(
"./check_uptime -w 111221d:111222d -c 1:222333d"
);
cmp_ok( $result->return_code, '==', 1, "Uptime lower than 111221 days raises warning" );
like ( $result->output, '/^WARNING: uptime is \d+ seconds/', "Output for uptime lower than 111221 days correct" );
like ( $result->output, '/Exceeds lower warn threshold/', "Exceeds text correct" );
like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
# Same as before, now the low critical should trigger
$result = NPTest->testCmd(
"./check_uptime -w 111221d:111222d -c 111220d:222333d"
);
cmp_ok( $result->return_code, '==', 2, "Uptime lower than 111220 days raises critical" );
like ( $result->output, '/^CRITICAL: uptime is \d+ seconds/', "Output for uptime lower than 111220 days correct" );
like ( $result->output, '/Exceeds lower crit threshold/', "Exceeds text correct" );
like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
#
# Range values using ":" without two parts ("a:b") is invalid
# Strings without two parts are always considered as upper threshold
#
$result = NPTest->testCmd(
"./check_uptime -w 2: -c 1:4"
);
cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" );
like ( $result->output, '/^Upper warning .* is not numeric/', "Output for wrong parameter format correct" );
$result = NPTest->testCmd(
"./check_uptime -w 2:3 -c 1:"
);
cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" );
like ( $result->output, '/^Upper critical .* is not numeric/', "Output for wrong parameter format correct" );
$result = NPTest->testCmd(
"./check_uptime -w :3 -c 1:4"
);
cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" );
like ( $result->output, '/^Upper warning .* is not numeric/', "Output for wrong parameter format correct" );
$result = NPTest->testCmd(
"./check_uptime -w 2:3 -c :4"
);
cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" );
like ( $result->output, '/^Upper critical .* is not numeric/', "Output for wrong parameter format correct" );

View file

@ -10,6 +10,7 @@ use strict;
use Test::More;
use NPTest;
use lib ".";
use lib "..";
use utils;

View file

@ -38,7 +38,9 @@ check_tcp_programs = check_ftp check_imap check_nntp check_pop \
EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
check_swap check_fping check_ldap check_game check_dig \
check_nagios check_by_ssh check_dns check_nt check_ide_smart \
check_procs check_mysql_query check_apt check_dbi
check_procs check_mysql_query check_apt check_dbi check_curl
SUBDIRS = picohttpparser
EXTRA_DIST = t tests
@ -69,6 +71,9 @@ test-debug:
check_apt_LDADD = $(BASEOBJS)
check_cluster_LDADD = $(BASEOBJS)
check_curl_CFLAGS = $(AM_CFLAGS) $(LIBCURLCFLAGS) $(URIPARSERCFLAGS) $(LIBCURLINCLUDE) $(URIPARSERINCLUDE) -Ipicohttpparser
check_curl_CPPFLAGS = $(AM_CPPFLAGS) $(LIBCURLCFLAGS) $(URIPARSERCFLAGS) $(LIBCURLINCLUDE) $(URIPARSERINCLUDE) -Ipicohttpparser
check_curl_LDADD = $(NETLIBS) $(LIBCURLLIBS) $(SSLOBJS) $(URIPARSERLIBS) picohttpparser/libpicohttpparser.a
check_dbi_LDADD = $(NETLIBS) $(DBILIBS)
check_dig_LDADD = $(NETLIBS)
check_disk_LDADD = $(BASEOBJS)

View file

@ -66,13 +66,15 @@ EXTRA_PROGRAMS = check_mysql$(EXEEXT) check_radius$(EXEEXT) \
check_by_ssh$(EXEEXT) check_dns$(EXEEXT) check_nt$(EXEEXT) \
check_ide_smart$(EXEEXT) check_procs$(EXEEXT) \
check_mysql_query$(EXEEXT) check_apt$(EXEEXT) \
check_dbi$(EXEEXT)
check_dbi$(EXEEXT) check_curl$(EXEEXT)
@HAVE_UTMPX_FALSE@am__append_1 = popen.o
subdir = plugins
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -194,9 +196,19 @@ check_by_ssh_DEPENDENCIES = $(am__DEPENDENCIES_2)
check_cluster_SOURCES = check_cluster.c
check_cluster_OBJECTS = check_cluster.$(OBJEXT)
check_cluster_DEPENDENCIES = $(BASEOBJS)
check_curl_SOURCES = check_curl.c
check_curl_OBJECTS = check_curl-check_curl.$(OBJEXT)
am__DEPENDENCIES_3 = $(check_cluster_LDADD) $(am__DEPENDENCIES_1)
am__DEPENDENCIES_4 = $(BASEOBJS) $(am__DEPENDENCIES_3) \
$(am__DEPENDENCIES_1)
check_curl_DEPENDENCIES = $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_4) $(am__DEPENDENCIES_1) \
picohttpparser/libpicohttpparser.a
check_curl_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(check_curl_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
check_dbi_SOURCES = check_dbi.c
check_dbi_OBJECTS = check_dbi.$(OBJEXT)
am__DEPENDENCIES_3 = $(check_cluster_LDADD) $(am__DEPENDENCIES_1)
check_dbi_DEPENDENCIES = $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_1)
check_dig_SOURCES = check_dig.c
check_dig_OBJECTS = check_dig.$(OBJEXT)
@ -206,34 +218,34 @@ check_disk_OBJECTS = check_disk.$(OBJEXT)
check_disk_DEPENDENCIES = $(BASEOBJS)
check_dns_SOURCES = check_dns.c
check_dns_OBJECTS = check_dns.$(OBJEXT)
am__DEPENDENCIES_4 = $(check_disk_LDADD) $(am__DEPENDENCIES_1)
check_dns_DEPENDENCIES = $(am__DEPENDENCIES_4)
am__DEPENDENCIES_5 = $(check_disk_LDADD) $(am__DEPENDENCIES_1)
check_dns_DEPENDENCIES = $(am__DEPENDENCIES_5)
check_dummy_SOURCES = check_dummy.c
check_dummy_OBJECTS = check_dummy.$(OBJEXT)
check_dummy_DEPENDENCIES = $(BASEOBJS)
check_fping_SOURCES = check_fping.c
check_fping_OBJECTS = check_fping.$(OBJEXT)
am__DEPENDENCIES_5 = $(check_dummy_LDADD) $(am__DEPENDENCIES_1)
check_fping_DEPENDENCIES = $(am__DEPENDENCIES_5)
am__DEPENDENCIES_6 = $(check_dummy_LDADD) $(am__DEPENDENCIES_1)
check_fping_DEPENDENCIES = $(am__DEPENDENCIES_6)
check_game_SOURCES = check_game.c
check_game_OBJECTS = check_game.$(OBJEXT)
check_game_DEPENDENCIES = $(BASEOBJS)
check_hpjd_SOURCES = check_hpjd.c
check_hpjd_OBJECTS = check_hpjd.$(OBJEXT)
am__DEPENDENCIES_6 = $(check_game_LDADD) $(am__DEPENDENCIES_1)
check_hpjd_DEPENDENCIES = $(am__DEPENDENCIES_6)
am__DEPENDENCIES_7 = $(check_game_LDADD) $(am__DEPENDENCIES_1)
check_hpjd_DEPENDENCIES = $(am__DEPENDENCIES_7)
check_http_SOURCES = check_http.c
check_http_OBJECTS = check_http.$(OBJEXT)
am__DEPENDENCIES_7 = $(BASEOBJS) $(am__DEPENDENCIES_6) \
am__DEPENDENCIES_8 = $(BASEOBJS) $(am__DEPENDENCIES_7) \
$(am__DEPENDENCIES_1)
check_http_DEPENDENCIES = $(am__DEPENDENCIES_7)
check_http_DEPENDENCIES = $(am__DEPENDENCIES_8)
check_ide_smart_SOURCES = check_ide_smart.c
check_ide_smart_OBJECTS = check_ide_smart.$(OBJEXT)
check_ide_smart_DEPENDENCIES = $(BASEOBJS)
check_ldap_SOURCES = check_ldap.c
check_ldap_OBJECTS = check_ldap.$(OBJEXT)
am__DEPENDENCIES_8 = $(check_ide_smart_LDADD) $(am__DEPENDENCIES_1)
check_ldap_DEPENDENCIES = $(am__DEPENDENCIES_8) $(am__DEPENDENCIES_1)
am__DEPENDENCIES_9 = $(check_ide_smart_LDADD) $(am__DEPENDENCIES_1)
check_ldap_DEPENDENCIES = $(am__DEPENDENCIES_9) $(am__DEPENDENCIES_1)
check_load_SOURCES = check_load.c
check_load_OBJECTS = check_load.$(OBJEXT)
check_load_DEPENDENCIES = $(BASEOBJS)
@ -245,15 +257,16 @@ check_mrtgtraf_OBJECTS = check_mrtgtraf.$(OBJEXT)
check_mrtgtraf_DEPENDENCIES = $(BASEOBJS)
check_mysql_SOURCES = check_mysql.c
check_mysql_OBJECTS = check_mysql-check_mysql.$(OBJEXT)
am__DEPENDENCIES_9 = $(check_mrtgtraf_LDADD) $(am__DEPENDENCIES_1)
check_mysql_DEPENDENCIES = $(am__DEPENDENCIES_9) $(am__DEPENDENCIES_1)
am__DEPENDENCIES_10 = $(check_mrtgtraf_LDADD) $(am__DEPENDENCIES_1)
check_mysql_DEPENDENCIES = $(am__DEPENDENCIES_10) \
$(am__DEPENDENCIES_1)
check_mysql_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(check_mysql_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
check_mysql_query_SOURCES = check_mysql_query.c
check_mysql_query_OBJECTS = \
check_mysql_query-check_mysql_query.$(OBJEXT)
check_mysql_query_DEPENDENCIES = $(am__DEPENDENCIES_9) \
check_mysql_query_DEPENDENCIES = $(am__DEPENDENCIES_10) \
$(am__DEPENDENCIES_1)
check_mysql_query_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) \
@ -264,69 +277,69 @@ check_nagios_OBJECTS = check_nagios.$(OBJEXT)
check_nagios_DEPENDENCIES = $(BASEOBJS)
check_nt_SOURCES = check_nt.c
check_nt_OBJECTS = check_nt.$(OBJEXT)
am__DEPENDENCIES_10 = $(check_nagios_LDADD) $(am__DEPENDENCIES_1)
check_nt_DEPENDENCIES = $(am__DEPENDENCIES_10)
am__DEPENDENCIES_11 = $(check_nagios_LDADD) $(am__DEPENDENCIES_1)
check_nt_DEPENDENCIES = $(am__DEPENDENCIES_11)
check_ntp_SOURCES = check_ntp.c
check_ntp_OBJECTS = check_ntp.$(OBJEXT)
check_ntp_DEPENDENCIES = $(am__DEPENDENCIES_10) $(am__DEPENDENCIES_1)
check_ntp_DEPENDENCIES = $(am__DEPENDENCIES_11) $(am__DEPENDENCIES_1)
check_ntp_peer_SOURCES = check_ntp_peer.c
check_ntp_peer_OBJECTS = check_ntp_peer.$(OBJEXT)
check_ntp_peer_DEPENDENCIES = $(am__DEPENDENCIES_10) \
check_ntp_peer_DEPENDENCIES = $(am__DEPENDENCIES_11) \
$(am__DEPENDENCIES_1)
check_ntp_time_SOURCES = check_ntp_time.c
check_ntp_time_OBJECTS = check_ntp_time.$(OBJEXT)
check_ntp_time_DEPENDENCIES = $(am__DEPENDENCIES_10) \
check_ntp_time_DEPENDENCIES = $(am__DEPENDENCIES_11) \
$(am__DEPENDENCIES_1)
check_nwstat_SOURCES = check_nwstat.c
check_nwstat_OBJECTS = check_nwstat.$(OBJEXT)
check_nwstat_DEPENDENCIES = $(am__DEPENDENCIES_10)
check_nwstat_DEPENDENCIES = $(am__DEPENDENCIES_11)
check_overcr_SOURCES = check_overcr.c
check_overcr_OBJECTS = check_overcr.$(OBJEXT)
check_overcr_DEPENDENCIES = $(am__DEPENDENCIES_10)
check_overcr_DEPENDENCIES = $(am__DEPENDENCIES_11)
check_pgsql_SOURCES = check_pgsql.c
check_pgsql_OBJECTS = check_pgsql.$(OBJEXT)
check_pgsql_DEPENDENCIES = $(am__DEPENDENCIES_10) \
check_pgsql_DEPENDENCIES = $(am__DEPENDENCIES_11) \
$(am__DEPENDENCIES_1)
check_ping_SOURCES = check_ping.c
check_ping_OBJECTS = check_ping.$(OBJEXT)
check_ping_DEPENDENCIES = $(am__DEPENDENCIES_10)
check_ping_DEPENDENCIES = $(am__DEPENDENCIES_11)
check_procs_SOURCES = check_procs.c
check_procs_OBJECTS = check_procs.$(OBJEXT)
check_procs_DEPENDENCIES = $(BASEOBJS)
check_radius_SOURCES = check_radius.c
check_radius_OBJECTS = check_radius.$(OBJEXT)
am__DEPENDENCIES_11 = $(check_procs_LDADD) $(am__DEPENDENCIES_1)
check_radius_DEPENDENCIES = $(am__DEPENDENCIES_11) \
am__DEPENDENCIES_12 = $(check_procs_LDADD) $(am__DEPENDENCIES_1)
check_radius_DEPENDENCIES = $(am__DEPENDENCIES_12) \
$(am__DEPENDENCIES_1)
check_real_SOURCES = check_real.c
check_real_OBJECTS = check_real.$(OBJEXT)
check_real_DEPENDENCIES = $(am__DEPENDENCIES_11)
check_real_DEPENDENCIES = $(am__DEPENDENCIES_12)
check_smtp_SOURCES = check_smtp.c
check_smtp_OBJECTS = check_smtp.$(OBJEXT)
am__DEPENDENCIES_12 = $(BASEOBJS) $(am__DEPENDENCIES_11) \
am__DEPENDENCIES_13 = $(BASEOBJS) $(am__DEPENDENCIES_12) \
$(am__DEPENDENCIES_1)
check_smtp_DEPENDENCIES = $(am__DEPENDENCIES_12)
check_smtp_DEPENDENCIES = $(am__DEPENDENCIES_13)
check_snmp_SOURCES = check_snmp.c
check_snmp_OBJECTS = check_snmp.$(OBJEXT)
check_snmp_DEPENDENCIES = $(BASEOBJS)
check_ssh_SOURCES = check_ssh.c
check_ssh_OBJECTS = check_ssh.$(OBJEXT)
am__DEPENDENCIES_13 = $(check_snmp_LDADD) $(am__DEPENDENCIES_1)
check_ssh_DEPENDENCIES = $(am__DEPENDENCIES_13)
am__DEPENDENCIES_14 = $(check_snmp_LDADD) $(am__DEPENDENCIES_1)
check_ssh_DEPENDENCIES = $(am__DEPENDENCIES_14)
check_swap_SOURCES = check_swap.c
check_swap_OBJECTS = check_swap.$(OBJEXT)
check_swap_DEPENDENCIES = $(am__DEPENDENCIES_1) $(BASEOBJS)
check_tcp_SOURCES = check_tcp.c
check_tcp_OBJECTS = check_tcp.$(OBJEXT)
am__DEPENDENCIES_14 = $(BASEOBJS) $(am__DEPENDENCIES_13) \
am__DEPENDENCIES_15 = $(BASEOBJS) $(am__DEPENDENCIES_14) \
$(am__DEPENDENCIES_1)
check_tcp_DEPENDENCIES = $(am__DEPENDENCIES_14)
check_tcp_DEPENDENCIES = $(am__DEPENDENCIES_15)
check_time_SOURCES = check_time.c
check_time_OBJECTS = check_time.$(OBJEXT)
check_time_DEPENDENCIES = $(am__DEPENDENCIES_13)
check_time_DEPENDENCIES = $(am__DEPENDENCIES_14)
check_ups_SOURCES = check_ups.c
check_ups_OBJECTS = check_ups.$(OBJEXT)
check_ups_DEPENDENCIES = $(am__DEPENDENCIES_13)
check_ups_DEPENDENCIES = $(am__DEPENDENCIES_14)
check_users_SOURCES = check_users.c
check_users_OBJECTS = check_users.$(OBJEXT)
check_users_DEPENDENCIES = $(BASEOBJS) $(am__DEPENDENCIES_1) \
@ -351,37 +364,75 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libnpcommon_a_SOURCES) check_apt.c check_by_ssh.c \
check_cluster.c check_dbi.c check_dig.c check_disk.c \
check_dns.c check_dummy.c check_fping.c check_game.c \
check_hpjd.c check_http.c check_ide_smart.c check_ldap.c \
check_load.c check_mrtg.c check_mrtgtraf.c check_mysql.c \
check_mysql_query.c check_nagios.c check_nt.c check_ntp.c \
check_ntp_peer.c check_ntp_time.c check_nwstat.c \
check_cluster.c check_curl.c check_dbi.c check_dig.c \
check_disk.c check_dns.c check_dummy.c check_fping.c \
check_game.c check_hpjd.c check_http.c check_ide_smart.c \
check_ldap.c check_load.c check_mrtg.c check_mrtgtraf.c \
check_mysql.c check_mysql_query.c check_nagios.c check_nt.c \
check_ntp.c check_ntp_peer.c check_ntp_time.c check_nwstat.c \
check_overcr.c check_pgsql.c check_ping.c check_procs.c \
check_radius.c check_real.c check_smtp.c check_snmp.c \
check_ssh.c check_swap.c check_tcp.c check_time.c check_ups.c \
check_users.c negate.c urlize.c
DIST_SOURCES = $(libnpcommon_a_SOURCES) check_apt.c check_by_ssh.c \
check_cluster.c check_dbi.c check_dig.c check_disk.c \
check_dns.c check_dummy.c check_fping.c check_game.c \
check_hpjd.c check_http.c check_ide_smart.c check_ldap.c \
check_load.c check_mrtg.c check_mrtgtraf.c check_mysql.c \
check_mysql_query.c check_nagios.c check_nt.c check_ntp.c \
check_ntp_peer.c check_ntp_time.c check_nwstat.c \
check_cluster.c check_curl.c check_dbi.c check_dig.c \
check_disk.c check_dns.c check_dummy.c check_fping.c \
check_game.c check_hpjd.c check_http.c check_ide_smart.c \
check_ldap.c check_load.c check_mrtg.c check_mrtgtraf.c \
check_mysql.c check_mysql_query.c check_nagios.c check_nt.c \
check_ntp.c check_ntp_peer.c check_ntp_time.c check_nwstat.c \
check_overcr.c check_pgsql.c check_ping.c check_procs.c \
check_radius.c check_real.c check_smtp.c check_snmp.c \
check_ssh.c check_swap.c check_tcp.c check_time.c check_ups.c \
check_users.c negate.c urlize.c
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
distdir
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
red=; grn=; lgn=; blu=; std=
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t
pkglibexecdir = @pkglibexecdir@
ACLOCAL = @ACLOCAL@
@ -1098,6 +1149,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1224,6 +1280,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1441,6 +1498,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1451,6 +1513,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@ -1520,6 +1583,7 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl \
check_tcp_programs = check_ftp check_imap check_nntp check_pop \
check_udp check_clamd @check_tcp_ssl@
SUBDIRS = picohttpparser
EXTRA_DIST = t tests
PLUGINHDRS = common.h
noinst_LIBRARIES = libnpcommon.a
@ -1537,6 +1601,9 @@ TESTS = @PLUGIN_TEST@
# the actual targets
check_apt_LDADD = $(BASEOBJS)
check_cluster_LDADD = $(BASEOBJS)
check_curl_CFLAGS = $(AM_CFLAGS) $(LIBCURLCFLAGS) $(URIPARSERCFLAGS) $(LIBCURLINCLUDE) $(URIPARSERINCLUDE) -Ipicohttpparser
check_curl_CPPFLAGS = $(AM_CPPFLAGS) $(LIBCURLCFLAGS) $(URIPARSERCFLAGS) $(LIBCURLINCLUDE) $(URIPARSERINCLUDE) -Ipicohttpparser
check_curl_LDADD = $(NETLIBS) $(LIBCURLLIBS) $(SSLOBJS) $(URIPARSERLIBS) picohttpparser/libpicohttpparser.a
check_dbi_LDADD = $(NETLIBS) $(DBILIBS)
check_dig_LDADD = $(NETLIBS)
check_disk_LDADD = $(BASEOBJS)
@ -1580,7 +1647,7 @@ check_by_ssh_LDADD = $(NETLIBS)
check_ide_smart_LDADD = $(BASEOBJS)
negate_LDADD = $(BASEOBJS)
urlize_LDADD = $(BASEOBJS)
all: all-am
all: all-recursive
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
@ -1676,6 +1743,9 @@ check_by_ssh$(EXEEXT): $(check_by_ssh_OBJECTS) $(check_by_ssh_DEPENDENCIES) $(EX
check_cluster$(EXEEXT): $(check_cluster_OBJECTS) $(check_cluster_DEPENDENCIES) $(EXTRA_check_cluster_DEPENDENCIES)
@rm -f check_cluster$(EXEEXT)
$(LINK) $(check_cluster_OBJECTS) $(check_cluster_LDADD) $(LIBS)
check_curl$(EXEEXT): $(check_curl_OBJECTS) $(check_curl_DEPENDENCIES) $(EXTRA_check_curl_DEPENDENCIES)
@rm -f check_curl$(EXEEXT)
$(check_curl_LINK) $(check_curl_OBJECTS) $(check_curl_LDADD) $(LIBS)
check_dbi$(EXEEXT): $(check_dbi_OBJECTS) $(check_dbi_DEPENDENCIES) $(EXTRA_check_dbi_DEPENDENCIES)
@rm -f check_dbi$(EXEEXT)
$(LINK) $(check_dbi_OBJECTS) $(check_dbi_LDADD) $(LIBS)
@ -1800,6 +1870,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_apt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_by_ssh.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_cluster.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_curl-check_curl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_dbi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_dig.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_disk.Po@am__quote@
@ -1865,6 +1936,20 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
check_curl-check_curl.o: check_curl.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(check_curl_CPPFLAGS) $(CPPFLAGS) $(check_curl_CFLAGS) $(CFLAGS) -MT check_curl-check_curl.o -MD -MP -MF $(DEPDIR)/check_curl-check_curl.Tpo -c -o check_curl-check_curl.o `test -f 'check_curl.c' || echo '$(srcdir)/'`check_curl.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/check_curl-check_curl.Tpo $(DEPDIR)/check_curl-check_curl.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='check_curl.c' object='check_curl-check_curl.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(check_curl_CPPFLAGS) $(CPPFLAGS) $(check_curl_CFLAGS) $(CFLAGS) -c -o check_curl-check_curl.o `test -f 'check_curl.c' || echo '$(srcdir)/'`check_curl.c
check_curl-check_curl.obj: check_curl.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(check_curl_CPPFLAGS) $(CPPFLAGS) $(check_curl_CFLAGS) $(CFLAGS) -MT check_curl-check_curl.obj -MD -MP -MF $(DEPDIR)/check_curl-check_curl.Tpo -c -o check_curl-check_curl.obj `if test -f 'check_curl.c'; then $(CYGPATH_W) 'check_curl.c'; else $(CYGPATH_W) '$(srcdir)/check_curl.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/check_curl-check_curl.Tpo $(DEPDIR)/check_curl-check_curl.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='check_curl.c' object='check_curl-check_curl.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(check_curl_CPPFLAGS) $(CPPFLAGS) $(check_curl_CFLAGS) $(CFLAGS) -c -o check_curl-check_curl.obj `if test -f 'check_curl.c'; then $(CYGPATH_W) 'check_curl.c'; else $(CYGPATH_W) '$(srcdir)/check_curl.c'; fi`
check_mysql-check_mysql.o: check_mysql.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(check_mysql_CPPFLAGS) $(CPPFLAGS) $(check_mysql_CFLAGS) $(CFLAGS) -MT check_mysql-check_mysql.o -MD -MP -MF $(DEPDIR)/check_mysql-check_mysql.Tpo -c -o check_mysql-check_mysql.o `test -f 'check_mysql.c' || echo '$(srcdir)/'`check_mysql.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/check_mysql-check_mysql.Tpo $(DEPDIR)/check_mysql-check_mysql.Po
@ -1899,6 +1984,76 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@ -1909,10 +2064,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
@ -1931,7 +2099,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@ -2074,23 +2242,49 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
check: check-recursive
all-am: Makefile $(LIBRARIES) $(PROGRAMS) all-local
installdirs:
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(libexecdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
@ -2112,83 +2306,86 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean: clean-recursive
clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \
clean-local clean-noinstLIBRARIES mostlyclean-am
distclean: distclean-am
distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi: dvi-recursive
dvi-am:
html: html-am
html: html-recursive
html-am:
info: info-am
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am: install-libexecPROGRAMS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
install-html: install-html-am
install-html: install-html-recursive
install-html-am:
install-info: install-info-am
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-am
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf: pdf-recursive
pdf-am:
ps: ps-am
ps: ps-recursive
ps-am:
uninstall-am: uninstall-libexecPROGRAMS uninstall-local
.MAKE: check-am install-am install-exec-am install-strip
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) check-am \
ctags-recursive install-am install-exec-am install-strip \
tags-recursive
.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \
clean clean-generic clean-libexecPROGRAMS clean-libtool \
clean-local clean-noinstLIBRARIES ctags distclean \
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am all-local check check-TESTS check-am clean \
clean-generic clean-libexecPROGRAMS clean-libtool clean-local \
clean-noinstLIBRARIES ctags ctags-recursive distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
@ -2196,11 +2393,11 @@ uninstall-am: uninstall-libexecPROGRAMS uninstall-local
install-html install-html-am install-info install-info-am \
install-libexecPROGRAMS install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-libexecPROGRAMS \
uninstall-local
tags tags-recursive uninstall uninstall-am \
uninstall-libexecPROGRAMS uninstall-local
@RELEASE_PRESENT_FALSE@NP-VERSION-FILE: .FORCE-NP-VERSION-FILE
@RELEASE_PRESENT_FALSE@ @$(SHELL_PATH) $(top_srcdir)/NP-VERSION-GEN

View file

@ -66,13 +66,19 @@ char* construct_cmdline(upgrade_type u, const char *opts);
/* run an apt-get update */
int run_update(void);
/* run an apt-get upgrade */
int run_upgrade(int *pkgcount, int *secpkgcount);
int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist);
/* add another clause to a regexp */
char* add_to_regexp(char *expr, const char *next);
/* extract package name from Inst line */
char* pkg_name(char *line);
/* string comparison function for qsort */
int cmpstringp(const void *p1, const void *p2);
/* configuration variables */
static int verbose = 0; /* -v */
static int list = 0; /* list packages available for upgrade */
static int do_update = 0; /* whether to call apt-get update */
static int only_critical = 0; /* whether to warn about non-critical updates */
static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */
static char *upgrade_opts = NULL; /* options to override defaults for upgrade */
static char *update_opts = NULL; /* options to override defaults for update */
@ -80,13 +86,16 @@ static char *do_include = NULL; /* regexp to only include certain packages */
static char *do_exclude = NULL; /* regexp to only exclude certain packages */
static char *do_critical = NULL; /* regexp specifying critical packages */
static char *input_filename = NULL; /* input filename for testing */
/* number of packages available for upgrade to return WARNING status */
static int packages_warning = 1;
/* other global variables */
static int stderr_warning = 0; /* if a cmd issued output on stderr */
static int exec_warning = 0; /* if a cmd exited non-zero */
int main (int argc, char **argv) {
int result=STATE_UNKNOWN, packages_available=0, sec_count=0;
int result=STATE_UNKNOWN, packages_available=0, sec_count=0, i=0;
char **packages_list=NULL, **secpackages_list=NULL;
/* Parse extra opts if any */
argv=np_extra_opts(&argc, argv, progname);
@ -106,11 +115,11 @@ int main (int argc, char **argv) {
if(do_update) result = run_update();
/* apt-get upgrade */
result = max_state(result, run_upgrade(&packages_available, &sec_count));
result = max_state(result, run_upgrade(&packages_available, &sec_count, &packages_list, &secpackages_list));
if(sec_count > 0){
result = max_state(result, STATE_CRITICAL);
} else if(packages_available > 0){
} else if(packages_available >= packages_warning && only_critical == 0){
result = max_state(result, STATE_WARNING);
} else if(result > STATE_UNKNOWN){
result = STATE_UNKNOWN;
@ -129,6 +138,18 @@ int main (int argc, char **argv) {
sec_count
);
if(list) {
qsort(secpackages_list, sec_count, sizeof(char*), cmpstringp);
qsort(packages_list, packages_available-sec_count, sizeof(char*), cmpstringp);
for(i = 0; i < sec_count; i++)
printf("%s (security)\n", secpackages_list[i]);
if (only_critical == 0) {
for(i = 0; i < packages_available - sec_count; i++)
printf("%s\n", packages_list[i]);
}
}
return result;
}
@ -145,15 +166,18 @@ int process_arguments (int argc, char **argv) {
{"upgrade", optional_argument, 0, 'U'},
{"no-upgrade", no_argument, 0, 'n'},
{"dist-upgrade", optional_argument, 0, 'd'},
{"list", no_argument, 0, 'l'},
{"include", required_argument, 0, 'i'},
{"exclude", required_argument, 0, 'e'},
{"critical", required_argument, 0, 'c'},
{"only-critical", no_argument, 0, 'o'},
{"input-file", required_argument, 0, INPUT_FILE_OPT},
{"packages-warning", required_argument, 0, 'w'},
{0, 0, 0, 0}
};
while(1) {
c = getopt_long(argc, argv, "hVvt:u::U::d::ni:e:c:", longopts, NULL);
c = getopt_long(argc, argv, "hVvt:u::U::d::nli:e:c:ow:", longopts, NULL);
if(c == -1 || c == EOF || c == 1) break;
@ -194,6 +218,9 @@ int process_arguments (int argc, char **argv) {
if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
}
break;
case 'l':
list=1;
break;
case 'i':
do_include=add_to_regexp(do_include, optarg);
break;
@ -203,9 +230,15 @@ int process_arguments (int argc, char **argv) {
case 'c':
do_critical=add_to_regexp(do_critical, optarg);
break;
case 'o':
only_critical=1;
break;
case INPUT_FILE_OPT:
input_filename = optarg;
break;
case 'w':
packages_warning = atoi(optarg);
break;
default:
/* print short usage statement if args not parsable */
usage5();
@ -217,7 +250,7 @@ int process_arguments (int argc, char **argv) {
/* run an apt-get upgrade */
int run_upgrade(int *pkgcount, int *secpkgcount){
int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist){
int i=0, result=STATE_UNKNOWN, regres=0, pc=0, spc=0;
struct output chld_out, chld_err;
regex_t ireg, ereg, sreg;
@ -273,6 +306,11 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
cmdline);
}
*pkglist=malloc(sizeof(char *) * chld_out.lines);
if(!pkglist) die(STATE_UNKNOWN, "malloc failed!\n");
*secpkglist=malloc(sizeof(char *) * chld_out.lines);
if(!secpkglist) die(STATE_UNKNOWN, "malloc failed!\n");
/* parse the output, which should only consist of lines like
*
* Inst package ....
@ -297,6 +335,9 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
if(regexec(&sreg, chld_out.line[i], 0, NULL, 0)==0){
spc++;
if(verbose) printf("*");
(*secpkglist)[spc-1] = pkg_name(chld_out.line[i]);
} else {
(*pkglist)[pc-spc-1] = pkg_name(chld_out.line[i]);
}
if(verbose){
printf("*%s\n", chld_out.line[i]);
@ -363,6 +404,31 @@ int run_update(void){
return result;
}
char* pkg_name(char *line){
char *start=NULL, *space=NULL, *pkg=NULL;
int len=0;
start = line + strlen(PKGINST_PREFIX);
len = strlen(start);
space = index(start, ' ');
if(space!=NULL){
len = space - start;
}
pkg=malloc(sizeof(char)*(len+1));
if(!pkg) die(STATE_UNKNOWN, "malloc failed!\n");
strncpy(pkg, start, len);
pkg[len]='\0';
return pkg;
}
int cmpstringp(const void *p1, const void *p2){
return strcmp(* (char * const *) p1, * (char * const *) p2);
}
char* add_to_regexp(char *expr, const char *next){
char *re=NULL;
@ -445,8 +511,11 @@ print_help (void)
printf (" %s\n", "-d, --dist-upgrade=OPTS");
printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
printf (" %s\n", _("can be provided to override the default options."));
printf (" %s\n", " -n, --no-upgrade");
printf (" %s\n", "-n, --no-upgrade");
printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
printf (" %s\n", "-l, --list");
printf (" %s\n", _("List packages available for upgrade. Packages are printed sorted by"));
printf (" %s\n", _("name with security packages listed first."));
printf (" %s\n", "-i, --include=REGEXP");
printf (" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times"));
printf (" %s\n", _("the values will be combined together. Any packages matching this list"));
@ -463,7 +532,14 @@ print_help (void)
printf (" %s\n", _("upgrades for Debian and Ubuntu:"));
printf (" \t\%s\n", SECURITY_RE);
printf (" %s\n", _("Note that the package must first match the include list before its"));
printf (" %s\n\n", _("information is compared against the critical list."));
printf (" %s\n", _("information is compared against the critical list."));
printf (" %s\n", "-o, --only-critical");
printf (" %s\n", _("Only warn about upgrades matching the critical list. The total number"));
printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause"));
printf (" %s\n", _("the plugin to return WARNING status."));
printf (" %s\n", "-w, --packages-warning");
printf (" %s\n", _("Minumum number of packages available for upgrade to return WARNING status."));
printf (" %s\n\n", _("Default is 1 package."));
printf ("%s\n\n", _("The following options require root privileges and should be used with care:"));
printf (" %s\n", "-u, --update=OPTS");
@ -481,5 +557,5 @@ void
print_usage(void)
{
printf ("%s\n", _("Usage:"));
printf ("%s [[-d|-u|-U]opts] [-n] [-t timeout]\n", progname);
printf ("%s [[-d|-u|-U]opts] [-n] [-l] [-t timeout] [-w packages-warning]\n", progname);
}

View file

@ -143,6 +143,7 @@ int main(int argc, char **argv){
int process_arguments(int argc, char **argv){
int c;
char *ptr;
int option=0;
static struct option longopts[]={
{"data", required_argument,0,'d'},
@ -188,6 +189,15 @@ int process_arguments(int argc, char **argv){
case 'd': /* data values */
data_vals=(char *)strdup(optarg);
/* validate data */
for (ptr=data_vals;ptr!=NULL;ptr+=2){
if (ptr[0]<'0' || ptr[0]>'3')
return ERROR;
if (ptr[1]=='\0')
break;
if (ptr[1]!=',')
return ERROR;
}
break;
case 'l': /* text label */

2335
plugins/check_curl.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -35,6 +35,7 @@ const char *email = "devel@monitoring-plugins.org";
#include "common.h"
#include "utils.h"
#include "utils_cmd.h"
#include "netutils.h"

View file

@ -331,7 +331,7 @@ print_help (void)
printf ("Copyright (c) 2000 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n");
printf (COPYRIGHT, copyright, email);
printf (_("This plugin test the DNS service on the specified host using dig"));
printf (_("This plugin tests the DNS service on the specified host using dig"));
printf ("\n\n");

View file

@ -141,6 +141,7 @@ int erronly = FALSE;
int display_mntp = FALSE;
int exact_match = FALSE;
int freespace_ignore_reserved = FALSE;
int display_inodes_perfdata = FALSE;
char *warn_freespace_units = NULL;
char *crit_freespace_units = NULL;
char *warn_freespace_percent = NULL;
@ -167,6 +168,7 @@ main (int argc, char **argv)
char *output;
char *details;
char *perf;
char *perf_ilabel;
char *preamble;
char *flag_header;
double inode_space_pct;
@ -186,6 +188,7 @@ main (int argc, char **argv)
output = strdup ("");
details = strdup ("");
perf = strdup ("");
perf_ilabel = strdup ("");
stat_buf = malloc(sizeof *stat_buf);
setlocale (LC_ALL, "");
@ -348,6 +351,29 @@ main (int argc, char **argv)
TRUE, 0,
TRUE, path->dtotal_units));
if (display_inodes_perfdata) {
/* *_high_tide must be reinitialized at each run */
warning_high_tide = UINT_MAX;
critical_high_tide = UINT_MAX;
if (path->freeinodes_percent->warning != NULL) {
warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total ));
}
if (path->freeinodes_percent->critical != NULL) {
critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total ));
}
xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
/* Nb: *_high_tide are unset when == UINT_MAX */
xasprintf (&perf, "%s %s", perf,
perfdata (perf_ilabel,
path->inodes_used, "",
(warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide,
(critical_high_tide != UINT_MAX ? TRUE : FALSE), critical_high_tide,
TRUE, 0,
TRUE, path->inodes_total));
}
if (disk_result==STATE_OK && erronly && !verbose)
continue;
@ -455,6 +481,7 @@ process_arguments (int argc, char **argv)
{"ignore-eregi-partition", required_argument, 0, 'I'},
{"local", no_argument, 0, 'l'},
{"stat-remote-fs", no_argument, 0, 'L'},
{"iperfdata", no_argument, 0, 'P'},
{"mountpoint", no_argument, 0, 'M'},
{"errors-only", no_argument, 0, 'e'},
{"exact-match", no_argument, 0, 'E'},
@ -477,7 +504,7 @@ process_arguments (int argc, char **argv)
strcpy (argv[c], "-t");
while (1) {
c = getopt_long (argc, argv, "+?VqhvefCt:c:w:K:W:u:p:x:X:N:mklLg:R:r:i:I:MEA", longopts, &option);
c = getopt_long (argc, argv, "+?VqhvefCt:c:w:K:W:u:p:x:X:N:mklLPg:R:r:i:I:MEA", longopts, &option);
if (c == -1 || c == EOF)
break;
@ -582,9 +609,13 @@ process_arguments (int argc, char **argv)
break;
case 'L':
stat_remote_fs = 1;
/* fallthrough */
case 'l':
show_local_fs = 1;
break;
case 'P':
display_inodes_perfdata = 1;
break;
case 'p': /* select path */
if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
crit_freespace_percent || warn_usedspace_units || crit_usedspace_units ||
@ -904,6 +935,8 @@ print_help (void)
printf (" %s\n", _("Display only devices/mountpoints with errors"));
printf (" %s\n", "-f, --freespace-ignore-reserved");
printf (" %s\n", _("Don't account root-reserved blocks into freespace in perfdata"));
printf (" %s\n", "-P, --iperfdata");
printf (" %s\n", _("Display inode usage in perfdata"));
printf (" %s\n", "-g, --group=NAME");
printf (" %s\n", _("Group paths. Thresholds apply to (free-)space of all partitions together"));
printf (" %s\n", "-k, --kilobytes");
@ -1012,6 +1045,8 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
p->dtotal_units += p_list->dtotal_units;
p->inodes_total += p_list->inodes_total;
p->inodes_free += p_list->inodes_free;
p->inodes_free_to_root += p_list->inodes_free_to_root;
p->inodes_used += p_list->inodes_used;
}
first = 0;
}
@ -1050,7 +1085,18 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
p->dused_units = p->used*fsp->fsu_blocksize/mult;
p->dfree_units = p->available*fsp->fsu_blocksize/mult;
p->dtotal_units = p->total*fsp->fsu_blocksize/mult;
p->inodes_total = fsp->fsu_files; /* Total file nodes. */
p->inodes_free = fsp->fsu_ffree; /* Free file nodes. */
/* Free file nodes. Not sure the workaround is required, but in case...*/
p->inodes_free = fsp->fsu_favail > fsp->fsu_ffree ? 0 : fsp->fsu_favail;
p->inodes_free_to_root = fsp->fsu_ffree; /* Free file nodes for root. */
p->inodes_used = fsp->fsu_files - fsp->fsu_ffree;
if (freespace_ignore_reserved) {
/* option activated : we substract the root-reserved inodes from the total */
/* not all OS report fsp->fsu_favail, only the ones with statvfs syscall */
/* for others, fsp->fsu_ffree == fsp->fsu_favail */
p->inodes_total = fsp->fsu_files - p->inodes_free_to_root + p->inodes_free;
} else {
/* default behaviour : take all the inodes into account */
p->inodes_total = fsp->fsu_files;
}
np_add_name(&seen, p->best_match->me_mountdir);
}

View file

@ -42,6 +42,8 @@ const char *email = "devel@monitoring-plugins.org";
int process_arguments (int, char **);
int validate_arguments (void);
int error_scan (char *);
int ip_match_cidr(const char *, const char *);
unsigned long ip2long(const char *);
void print_help (void);
void print_usage (void);
@ -54,6 +56,7 @@ char **expected_address = NULL;
int expected_address_cnt = 0;
int expect_authority = FALSE;
int all_match = FALSE;
thresholds *time_thresholds = NULL;
static int
@ -126,7 +129,7 @@ main (int argc, char **argv)
if (verbose)
puts(chld_out.line[i]);
if (strcasestr (chld_out.line[i], ".in-addr.arpa")) {
if (strcasestr (chld_out.line[i], ".in-addr.arpa") || strcasestr (chld_out.line[i], ".ip6.arpa")) {
if ((temp_buffer = strstr (chld_out.line[i], "name = ")))
addresses[n_addresses++] = strdup (temp_buffer + 7);
else {
@ -166,8 +169,8 @@ main (int argc, char **argv)
temp_buffer++;
/* Strip leading spaces */
for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
/* NOOP */;
while (*temp_buffer == ' ')
temp_buffer++;
strip(temp_buffer);
if (temp_buffer==NULL || strlen(temp_buffer)==0) {
@ -199,7 +202,10 @@ main (int argc, char **argv)
if (error_scan (chld_err.line[i]) != STATE_OK) {
result = max_state (result, error_scan (chld_err.line[i]));
msg = strchr(input_buffer, ':');
if(msg) msg++;
if(msg)
msg++;
else
msg = input_buffer;
}
}
@ -226,11 +232,27 @@ main (int argc, char **argv)
if (result == STATE_OK && expected_address_cnt > 0) {
result = STATE_CRITICAL;
temp_buffer = "";
unsigned long expect_match = (1 << expected_address_cnt) - 1;
unsigned long addr_match = (1 << n_addresses) - 1;
for (i=0; i<expected_address_cnt; i++) {
/* check if we get a match and prepare an error string */
if (strcmp(address, expected_address[i]) == 0) result = STATE_OK;
int j;
/* check if we get a match on 'raw' ip or cidr */
for (j=0; j<n_addresses; j++) {
if ( strcmp(addresses[j], expected_address[i]) == 0
|| ip_match_cidr(addresses[j], expected_address[i]) ) {
result = STATE_OK;
addr_match &= ~(1 << j);
expect_match &= ~(1 << i);
}
}
/* prepare an error string */
xasprintf(&temp_buffer, "%s%s; ", temp_buffer, expected_address[i]);
}
/* check if expected_address must cover all in addresses and none may be missing */
if (all_match && (expect_match != 0 || addr_match != 0))
result = STATE_CRITICAL;
if (result == STATE_CRITICAL) {
/* Strip off last semicolon... */
temp_buffer[strlen(temp_buffer)-2] = '\0';
@ -289,7 +311,32 @@ main (int argc, char **argv)
return result;
}
int
ip_match_cidr(const char *addr, const char *cidr_ro)
{
char *subnet, *mask_c, *cidr = strdup(cidr_ro);
int mask;
subnet = strtok(cidr, "/");
mask_c = strtok(NULL, "\0");
if (!subnet || !mask_c)
return FALSE;
mask = atoi(mask_c);
/* https://www.cryptobells.com/verifying-ips-in-a-subnet-in-php/ */
return (ip2long(addr) & ~((1 << (32 - mask)) - 1)) == (ip2long(subnet) >> (32 - mask)) << (32 - mask);
}
unsigned long
ip2long(const char* src) {
unsigned long ip[4];
/* http://computer-programming-forum.com/47-c-language/1376ffb92a12c471.htm */
return (sscanf(src, "%3lu.%3lu.%3lu.%3lu",
&ip[0], &ip[1], &ip[2], &ip[3]) == 4 &&
ip[0] < 256 && ip[1] < 256 &&
ip[2] < 256 && ip[3] < 256)
? ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3]
: 0;
}
int
error_scan (char *input_buffer)
@ -304,6 +351,8 @@ error_scan (char *input_buffer)
/* DNS server is not running... */
else if (strstr (input_buffer, "No response from server"))
die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
else if (strstr (input_buffer, "no servers could be reached"))
die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
/* Host name is valid, but server doesn't have records... */
else if (strstr (input_buffer, "No records"))
@ -328,6 +377,7 @@ error_scan (char *input_buffer)
/* Host or domain name does not exist */
else if (strstr (input_buffer, "Non-existent") ||
strstr (input_buffer, "** server can't find") ||
strstr (input_buffer, "** Can't find") ||
strstr (input_buffer,"NXDOMAIN"))
die (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address);
@ -368,6 +418,7 @@ process_arguments (int argc, char **argv)
{"reverse-server", required_argument, 0, 'r'},
{"expected-address", required_argument, 0, 'a'},
{"expect-authority", no_argument, 0, 'A'},
{"all", no_argument, 0, 'L'},
{"warning", required_argument, 0, 'w'},
{"critical", required_argument, 0, 'c'},
{0, 0, 0, 0}
@ -381,7 +432,7 @@ process_arguments (int argc, char **argv)
strcpy (argv[c], "-t");
while (1) {
c = getopt_long (argc, argv, "hVvAt:H:s:r:a:w:c:", long_opts, &opt_index);
c = getopt_long (argc, argv, "hVvALt:H:s:r:a:w:c:", long_opts, &opt_index);
if (c == -1 || c == EOF)
break;
@ -429,6 +480,9 @@ process_arguments (int argc, char **argv)
case 'A': /* expect authority */
expect_authority = TRUE;
break;
case 'L': /* all must match */
all_match = TRUE;
break;
case 'w':
warning = optarg;
break;
@ -494,17 +548,19 @@ print_help (void)
printf (" %s\n", _("The name or address you want to query"));
printf (" -s, --server=HOST\n");
printf (" %s\n", _("Optional DNS server you want to use for the lookup"));
printf (" -a, --expected-address=IP-ADDRESS|HOST\n");
printf (" %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with"));
printf (" %s\n", _("a dot (.). This option can be repeated multiple times (Returns OK if any"));
printf (" %s\n", _("value match). If multiple addresses are returned at once, you have to match"));
printf (" %s\n", _("the whole string of addresses separated with commas (sorted alphabetically)."));
printf (" -a, --expected-address=IP-ADDRESS|CIDR|HOST\n");
printf (" %s\n", _("Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"));
printf (" %s\n", _("with a dot (.). This option can be repeated multiple times (Returns OK if any"));
printf (" %s\n", _("value matches)."));
printf (" -A, --expect-authority\n");
printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
printf (" -w, --warning=seconds\n");
printf (" %s\n", _("Return warning if elapsed time exceeds value. Default off"));
printf (" -c, --critical=seconds\n");
printf (" %s\n", _("Return critical if elapsed time exceeds value. Default off"));
printf (" -L, --all\n");
printf (" %s\n", _("Return critical if the list of expected addresses does not match all addresses"));
printf (" %s\n", _("returned. Default off"));
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
@ -516,5 +572,5 @@ void
print_usage (void)
{
printf ("%s\n", _("Usage:"));
printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit]\n", progname);
printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit] [-L]\n", progname);
}

View file

@ -184,7 +184,7 @@ textscan (char *buf)
int status = STATE_UNKNOWN;
if (strstr (buf, "not found")) {
die (STATE_CRITICAL, _("FPING UNKNOW - %s not found\n"), server_name);
die (STATE_CRITICAL, _("FPING UNKNOWN - %s not found\n"), server_name);
}
else if (strstr (buf, "is unreachable") || strstr (buf, "Unreachable")) {

View file

@ -67,6 +67,7 @@ void print_usage (void);
char *community = NULL;
char *address = NULL;
char *port = NULL;
int check_paper_out = 1;
int
main (int argc, char **argv)
@ -240,6 +241,7 @@ main (int argc, char **argv)
strcpy (errmsg, _("Paper Jam"));
}
else if (paper_out) {
if (check_paper_out)
result = STATE_WARNING;
strcpy (errmsg, _("Out of Paper"));
}
@ -325,7 +327,7 @@ process_arguments (int argc, char **argv)
while (1) {
c = getopt_long (argc, argv, "+hVH:C:p:", longopts, &option);
c = getopt_long (argc, argv, "+hVH:C:p:D", longopts, &option);
if (c == -1 || c == EOF || c == 1)
break;
@ -347,6 +349,8 @@ process_arguments (int argc, char **argv)
usage2 (_("Port must be a positive short integer"), optarg);
else
port = atoi(optarg);
case 'D': /* disable paper out check*/
check_paper_out = 0;
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);
@ -420,6 +424,8 @@ print_help (void)
printf (" %s", _("Specify the port to check "));
printf (_("(default=%s)"), DEFAULT_PORT);
printf ("\n");
printf (" %s\n", "-D");
printf (" %s", _("Disable paper check "));
printf (UT_SUPPORT);
}
@ -430,5 +436,5 @@ void
print_usage (void)
{
printf ("%s\n", _("Usage:"));
printf ("%s -H host [-C community] [-p port]\n", progname);
printf ("%s -H host [-C community] [-p port] [-D]\n", progname);
}

View file

@ -120,12 +120,14 @@ int use_ssl = FALSE;
int use_sni = FALSE;
int verbose = FALSE;
int show_extended_perfdata = FALSE;
int show_body = FALSE;
int sd;
int min_page_len = 0;
int max_page_len = 0;
int redir_depth = 0;
int max_depth = 15;
char *http_method;
char *http_method_proxy;
char *http_post_data;
char *http_content_type;
char buffer[MAX_INPUT_BUFFER];
@ -239,6 +241,7 @@ process_arguments (int argc, char **argv)
{"use-ipv4", no_argument, 0, '4'},
{"use-ipv6", no_argument, 0, '6'},
{"extended-perfdata", no_argument, 0, 'E'},
{"show-body", no_argument, 0, 'B'},
{0, 0, 0, 0}
};
@ -259,7 +262,7 @@ process_arguments (int argc, char **argv)
}
while (1) {
c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NE", longopts, &option);
c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NEB", longopts, &option);
if (c == -1 || c == EOF)
break;
@ -446,6 +449,12 @@ process_arguments (int argc, char **argv)
if (http_method)
free(http_method);
http_method = strdup (optarg);
char *tmp;
if ((tmp = strstr(http_method, ":")) > 0) {
tmp[0] = '\0';
http_method = http_method;
http_method_proxy = ++tmp;
}
break;
case 'd': /* string or substring */
strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1);
@ -540,6 +549,9 @@ process_arguments (int argc, char **argv)
case 'E': /* show extended perfdata */
show_extended_perfdata = TRUE;
break;
case 'B': /* print body content after status line */
show_body = TRUE;
break;
}
}
@ -566,6 +578,9 @@ process_arguments (int argc, char **argv)
if (http_method == NULL)
http_method = strdup ("GET");
if (http_method_proxy == NULL)
http_method_proxy = strdup ("GET");
if (client_cert && !client_privkey)
usage4 (_("If you use a client certificate you must also specify a private key file"));
@ -916,6 +931,21 @@ check_http (void)
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);
if (strlen(proxy_auth)) {
base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth);
xasprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth);
}
/* optionally send any other header tag */
if (http_opt_headers_count) {
for (i = 0; i < http_opt_headers_count ; 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 */
/* free(http_opt_headers); */
}
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 */
@ -950,7 +980,7 @@ check_http (void)
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);
asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method_proxy, 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);
@ -1140,6 +1170,8 @@ check_http (void)
xasprintf (&msg,
_("Invalid HTTP response received from host on port %d: %s\n"),
server_port, status_line);
if (show_body)
xasprintf (&msg, _("%s\n%s"), msg, page);
die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg);
}
@ -1290,6 +1322,9 @@ check_http (void)
perfd_time (elapsed_time),
perfd_size (page_len));
if (show_body)
xasprintf (&msg, _("%s\n%s"), msg, page);
result = max_state_alt(get_status(elapsed_time, thlds), result);
die (result, "HTTP %s: %s\n", state_text(result), msg);
@ -1581,7 +1616,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, CONNECT)");
printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT, CONNECT:POST)");
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."));
@ -1611,6 +1646,8 @@ print_help (void)
printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers"));
printf (" %s\n", "-E, --extended-perfdata");
printf (" %s\n", _("Print additional performance data"));
printf (" %s\n", "-B, --show-body");
printf (" %s\n", _("Print body content below status line"));
printf (" %s\n", "-L, --link");
printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)"));
printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>");
@ -1629,7 +1666,7 @@ print_help (void)
printf ("%s\n", _("Notes:"));
printf (" %s\n", _("This plugin will attempt to open an HTTP connection with the host."));
printf (" %s\n", _("Successful connects return STATE_OK, refusals and timeouts return STATE_CRITICAL"));
printf (" %s\n", _("other errors return STATE_UNKNOWN. Successful connects, but incorrect reponse"));
printf (" %s\n", _("other errors return STATE_UNKNOWN. Successful connects, but incorrect response"));
printf (" %s\n", _("messages from the host result in STATE_WARNING return values. If you are"));
printf (" %s\n", _("checking a virtual server that uses 'host headers' you must supply the FQDN"));
printf (" %s\n", _("(fully qualified domain name) as the [host_name] argument."));
@ -1668,7 +1705,8 @@ print_help (void)
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."));
printf (" %s\n", _("a STATE_CRITICAL will be returned. By adding a colon to the method you can set the method used"));
printf (" %s\n", _("inside the proxied connection: -j CONNECT:POST"));
#endif

View file

@ -283,7 +283,7 @@ get_offline_text (int status)
return offline_status_text[i].text;
}
}
return "UNKNOW";
return "UNKNOWN";
}

View file

@ -237,7 +237,7 @@ main (int argc, char *argv[])
if(entries_thresholds != NULL) {
if (verbose) {
printf ("entries found: %d\n", num_entries);
print_thresholds("entry threasholds", entries_thresholds);
print_thresholds("entry thresholds", entries_thresholds);
}
status_entries = get_status(num_entries, entries_thresholds);
if (status_entries == STATE_CRITICAL) {

View file

@ -33,6 +33,7 @@ const char *copyright = "1999-2007";
const char *email = "devel@monitoring-plugins.org";
#include "common.h"
#include "runcmd.h"
#include "utils.h"
#include "popen.h"
@ -52,6 +53,9 @@ static int process_arguments (int argc, char **argv);
static int validate_arguments (void);
void print_help (void);
void print_usage (void);
static int print_top_consuming_processes();
static int n_procs_to_show = 0;
/* strictly for pretty-print usage in loops */
static const int nums[3] = { 1, 5, 15 };
@ -210,6 +214,9 @@ main (int argc, char **argv)
printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]);
putchar('\n');
if (n_procs_to_show > 0) {
print_top_consuming_processes();
}
return result;
}
@ -227,6 +234,7 @@ process_arguments (int argc, char **argv)
{"percpu", no_argument, 0, 'r'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{"procs-to-show", required_argument, 0, 'n'},
{0, 0, 0, 0}
};
@ -234,7 +242,7 @@ process_arguments (int argc, char **argv)
return ERROR;
while (1) {
c = getopt_long (argc, argv, "Vhrc:w:", longopts, &option);
c = getopt_long (argc, argv, "Vhrc:w:n:", longopts, &option);
if (c == -1 || c == EOF)
break;
@ -255,6 +263,9 @@ process_arguments (int argc, char **argv)
case 'h': /* help */
print_help ();
exit (STATE_UNKNOWN);
case 'n':
n_procs_to_show = atoi(optarg);
break;
case '?': /* help */
usage5 ();
}
@ -324,6 +335,9 @@ print_help (void)
printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\""));
printf (" %s\n", "-r, --percpu");
printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)"));
printf (" %s\n", "-n, --procs-to-show=NUMBER_OF_PROCS");
printf (" %s\n", _("Number of processes to show when printing the top consuming processes."));
printf (" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0"));
printf (UT_SUPPORT);
}
@ -332,5 +346,48 @@ void
print_usage (void)
{
printf ("%s\n", _("Usage:"));
printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n", progname);
printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 [-n NUMBER_OF_PROCS]\n", progname);
}
#ifdef PS_USES_PROCPCPU
int cmpstringp(const void *p1, const void *p2) {
int procuid = 0;
int procpid = 0;
int procppid = 0;
int procvsz = 0;
int procrss = 0;
float procpcpu = 0;
char procstat[8];
#ifdef PS_USES_PROCETIME
char procetime[MAX_INPUT_BUFFER];
#endif /* PS_USES_PROCETIME */
char procprog[MAX_INPUT_BUFFER];
int pos;
sscanf (* (char * const *) p1, PS_FORMAT, PS_VARLIST);
float procpcpu1 = procpcpu;
sscanf (* (char * const *) p2, PS_FORMAT, PS_VARLIST);
return procpcpu1 < procpcpu;
}
#endif /* PS_USES_PROCPCPU */
static int print_top_consuming_processes() {
int i = 0;
struct output chld_out, chld_err;
if(np_runcmd(PS_COMMAND, &chld_out, &chld_err, 0) != 0){
fprintf(stderr, _("'%s' exited with non-zero status.\n"), PS_COMMAND);
return STATE_UNKNOWN;
}
if (chld_out.lines < 2) {
fprintf(stderr, _("some error occurred getting procs list.\n"));
return STATE_UNKNOWN;
}
#ifdef PS_USES_PROCPCPU
qsort(chld_out.line + 1, chld_out.lines - 1, sizeof(char*), cmpstringp);
#endif /* PS_USES_PROCPCPU */
int lines_to_show = chld_out.lines < (n_procs_to_show + 1)
? chld_out.lines : n_procs_to_show + 1;
for (i = 0; i < lines_to_show; i += 1) {
printf("%s\n", chld_out.line[i]);
}
return OK;
}

View file

@ -379,6 +379,9 @@ process_arguments (int argc, char **argv)
if (is_host (optarg)) {
db_host = optarg;
}
else if (*optarg == '/') {
db_socket = optarg;
}
else {
usage2 (_("Invalid hostname/address"), optarg);
}

View file

@ -548,7 +548,7 @@ double jitter_request(const char *host, int *status){
DBG(print_ntp_control_message(&req));
/* Attempt to read the largest size packet possible */
req.count=htons(MAX_CM_SIZE);
DBG(printf("recieving READSTAT response"))
DBG(printf("receiving READSTAT response"))
read(conn, &req, SIZEOF_NTPCM(req));
DBG(print_ntp_control_message(&req));
/* Each peer identifier is 4 bytes in the data section, which
@ -608,7 +608,7 @@ double jitter_request(const char *host, int *status){
DBG(print_ntp_control_message(&req));
req.count = htons(MAX_CM_SIZE);
DBG(printf("recieving READVAR response...\n"));
DBG(printf("receiving READVAR response...\n"));
read(conn, &req, SIZEOF_NTPCM(req));
DBG(print_ntp_control_message(&req));

View file

@ -245,7 +245,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
do {
/* Attempt to read the largest size packet possible */
req.count=htons(MAX_CM_SIZE);
DBG(printf("recieving READSTAT response"))
DBG(printf("receiving READSTAT response"))
if(read(conn, &req, SIZEOF_NTPCM(req)) == -1)
die(STATE_CRITICAL, "NTP CRITICAL: No response from NTP server\n");
DBG(print_ntp_control_message(&req));

View file

@ -34,6 +34,7 @@ const char *email = "devel@monitoring-plugins.org";
#include "common.h"
#include "utils.h"
#include "utils_cmd.h"
#include "netutils.h"
#include <libpq-fe.h>
@ -565,7 +566,7 @@ print_help (void)
printf (" %s\n", _("Typically, the monitoring user (unless the --logname option is used) should be"));
printf (" %s\n", _("able to connect to the database without a password. The plugin can also send"));
printf (" %s\n", _("a password, but no effort is made to obsure or encrypt the password."));
printf (" %s\n", _("a password, but no effort is made to obscure or encrypt the password."));
printf (UT_SUPPORT);
}

View file

@ -764,6 +764,11 @@ be the total number of running processes\n\n"));
printf (" %s\n", "check_procs -w 2:2 -c 2:1024 -C portsentry");
printf (" %s\n", _("Warning if not two processes with command name portsentry."));
printf (" %s\n\n", _("Critical if < 2 or > 1024 processes"));
printf (" %s\n", "check_procs -c 1: -C sshd");
printf (" %s\n", _("Critical if not at least 1 process with command sshd"));
printf (" %s\n", "check_procs -w 1024 -c 1: -C sshd");
printf (" %s\n", _("Warning if > 1024 processes with command name sshd."));
printf (" %s\n\n", _("Critical if < 1 processes with command name sshd."));
printf (" %s\n", "check_procs -w 10 -a '/usr/local/bin/perl' -u root");
printf (" %s\n", _("Warning alert if > 10 processes with command arguments containing"));
printf (" %s\n\n", _("'/usr/local/bin/perl' and owned by root"));

View file

@ -360,7 +360,7 @@ print_help (void)
printf (" %s\n", "-u, --username=STRING");
printf (" %s\n", _("The user to authenticate"));
printf (" %s\n", "-p, --password=STRING");
printf (" %s\n", _("Password for autentication (SECURITY RISK)"));
printf (" %s\n", _("Password for authentication (SECURITY RISK)"));
printf (" %s\n", "-n, --nas-id=STRING");
printf (" %s\n", _("NAS identifier"));
printf (" %s\n", "-N, --nas-ip-address=STRING");

View file

@ -438,7 +438,7 @@ print_help (void)
printf ("%s\n", _("This plugin will attempt to open an RTSP connection with the host."));
printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return"));
printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"));
printf ("%s\n", _("but incorrect reponse messages from the host result in STATE_WARNING return"));
printf ("%s\n", _("but incorrect response messages from the host result in STATE_WARNING return"));
printf ("%s\n", _("values."));
printf (UT_SUPPORT);

View file

@ -293,6 +293,7 @@ main (int argc, char **argv)
printf("%s", buffer);
}
n = 0;
while (n < ncommands) {
xasprintf (&cmd_str, "%s%s", commands[n], "\r\n");
my_send(cmd_str, strlen(cmd_str));
@ -835,7 +836,7 @@ print_help (void)
printf("\n");
printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return"));
printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"));
printf ("%s\n", _("connects, but incorrect reponse messages from the host result in"));
printf ("%s\n", _("connects, but incorrect response messages from the host result in"));
printf ("%s\n", _("STATE_WARNING return values."));
printf (UT_SUPPORT);

View file

@ -1207,8 +1207,9 @@ print_help (void)
printf (" %s\n", _("Separates output on multiple OID requests"));
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5"));
printf (" %s\n", "-e, --retries=INTEGER");
printf (" %s\n", _("Number of retries to be used in the requests"));
printf (" %s%i\n", _("Number of retries to be used in the requests, default: "), DEFAULT_RETRIES);
printf (" %s\n", "-O, --perf-oids");
printf (" %s\n", _("Label performance data with OIDs instead of --label's"));

View file

@ -51,7 +51,7 @@ const char *email = "devel@monitoring-plugins.org";
# define SWAP_CONVERSION 1
#endif
int check_swap (int usp, float free_swap_mb);
int check_swap (int usp, float free_swap_mb, float total_swap_mb);
int process_arguments (int argc, char **argv);
int validate_arguments (void);
void print_usage (void);
@ -128,7 +128,7 @@ main (int argc, char **argv)
percent=100.0;
else
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
result = max_state (result, check_swap (percent, dskfree_mb));
result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb));
if (verbose)
xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
@ -227,7 +227,7 @@ main (int argc, char **argv)
free_swap_mb += dskfree_mb;
if (allswaps) {
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
result = max_state (result, check_swap (percent, dskfree_mb));
result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb));
if (verbose)
xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
@ -289,7 +289,7 @@ main (int argc, char **argv)
if(allswaps && dsktotal_mb > 0){
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
result = max_state (result, check_swap (percent, dskfree_mb));
result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb));
if (verbose) {
xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
@ -328,7 +328,7 @@ main (int argc, char **argv)
if(allswaps && dsktotal_mb > 0){
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
result = max_state (result, check_swap (percent, dskfree_mb));
result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb));
if (verbose) {
xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
@ -355,7 +355,7 @@ main (int argc, char **argv)
status = "- Swap is either disabled, not present, or of zero size. ";
}
result = max_state (result, check_swap (percent_used, free_swap_mb));
result = max_state (result, check_swap (percent_used, free_swap_mb, total_swap_mb));
printf (_("SWAP %s - %d%% free (%d MB out of %d MB) %s|"),
state_text (result),
(100 - percent_used), (int) free_swap_mb, (int) total_swap_mb, status);
@ -372,10 +372,10 @@ main (int argc, char **argv)
int
check_swap (int usp, float free_swap_mb)
check_swap (int usp, float free_swap_mb, float total_swap_mb)
{
if (!free_swap_mb) return no_swap_state;
if (!total_swap_mb) return no_swap_state;
int result = STATE_UNKNOWN;
float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */

View file

@ -86,6 +86,11 @@ static char buffer[MAXBUF];
static int expect_mismatch_state = STATE_WARNING;
static int match_flags = NP_MATCH_EXACT;
#ifdef HAVE_SSL
static char *sni = NULL;
static int sni_specified = FALSE;
#endif
#define FLAG_SSL 0x01
#define FLAG_VERBOSE 0x02
#define FLAG_TIME_WARN 0x04
@ -241,7 +246,7 @@ main (int argc, char **argv)
#ifdef HAVE_SSL
if (flags & FLAG_SSL){
result = np_net_ssl_init(sd);
result = np_net_ssl_init_with_hostname(sd, (sni_specified ? sni : NULL));
if (result == STATE_OK && check_cert == TRUE) {
result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
}
@ -401,6 +406,10 @@ process_arguments (int argc, char **argv)
int escape = 0;
char *temp;
enum {
SNI_OPTION = CHAR_MAX + 1
};
int option = 0;
static struct option longopts[] = {
{"hostname", required_argument, 0, 'H'},
@ -427,6 +436,7 @@ process_arguments (int argc, char **argv)
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{"ssl", no_argument, 0, 'S'},
{"sni", required_argument, 0, SNI_OPTION},
{"certificate", required_argument, 0, 'D'},
{0, 0, 0, 0}
};
@ -602,6 +612,15 @@ process_arguments (int argc, char **argv)
flags |= FLAG_SSL;
#else
die (STATE_UNKNOWN, _("Invalid option - SSL is not available"));
#endif
break;
case SNI_OPTION:
#ifdef HAVE_SSL
flags |= FLAG_SSL;
sni_specified = TRUE;
sni = optarg;
#else
die (STATE_UNKNOWN, _("Invalid option - SSL is not available"));
#endif
break;
case 'A':
@ -671,6 +690,8 @@ print_help (void)
printf (" %s\n", _("1st is #days for warning, 2nd is critical (if not specified - 0)."));
printf (" %s\n", "-S, --ssl");
printf (" %s\n", _("Use SSL for the connection."));
printf (" %s\n", "--sni=STRING");
printf (" %s\n", _("SSL server_name"));
#endif
printf (UT_WARN_CRIT);

View file

@ -174,6 +174,11 @@
*
*/
/* MariaDB 10.2 client does not set MYSQL_PORT */
#ifndef MYSQL_PORT
# define MYSQL_PORT 3306
#endif
enum {
OK = 0,
ERROR = -1
@ -220,4 +225,18 @@ enum {
# define __attribute__(x) /* do nothing */
#endif
/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
* 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 DEFAULT_MAXFD
#endif
#endif /* _COMMON_H_ */

View file

@ -86,11 +86,9 @@ main (int argc, char **argv)
result = cmd_run_array (command_line, &chld_out, &chld_err, 0);
}
if (chld_err.lines > 0) {
printf ("Error output from command:\n");
for (i = 0; i < chld_err.lines; i++) {
printf ("%s\n", chld_err.line[i]);
fprintf (stderr, "%s\n", chld_err.line[i]);
}
exit (STATE_WARNING);
}
/* Return UNKNOWN or worse if no output is returned */

View file

@ -0,0 +1,3 @@
noinst_LIBRARIES = libpicohttpparser.a
libpicohttpparser_a_SOURCES = picohttpparser.c picohttpparser.h

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,645 @@
/*
* Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase,
* Shigeo Mitsunari
*
* The software is licensed under either the MIT License (below) or the Perl
* license.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <assert.h>
#include <stddef.h>
#include <string.h>
#ifdef __SSE4_2__
#ifdef _MSC_VER
#include <nmmintrin.h>
#else
#include <x86intrin.h>
#endif
#endif
#include "picohttpparser.h"
#if __GNUC__ >= 3
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif
#ifdef _MSC_VER
#define ALIGNED(n) _declspec(align(n))
#else
#define ALIGNED(n) __attribute__((aligned(n)))
#endif
#define IS_PRINTABLE_ASCII(c) ((unsigned char)(c)-040u < 0137u)
#define CHECK_EOF() \
if (buf == buf_end) { \
*ret = -2; \
return NULL; \
}
#define EXPECT_CHAR_NO_CHECK(ch) \
if (*buf++ != ch) { \
*ret = -1; \
return NULL; \
}
#define EXPECT_CHAR(ch) \
CHECK_EOF(); \
EXPECT_CHAR_NO_CHECK(ch);
#define ADVANCE_TOKEN(tok, toklen) \
do { \
const char *tok_start = buf; \
static const char ALIGNED(16) ranges2[16] = "\000\040\177\177"; \
int found2; \
buf = findchar_fast(buf, buf_end, ranges2, 4, &found2); \
if (!found2) { \
CHECK_EOF(); \
} \
while (1) { \
if (*buf == ' ') { \
break; \
} else if (unlikely(!IS_PRINTABLE_ASCII(*buf))) { \
if ((unsigned char)*buf < '\040' || *buf == '\177') { \
*ret = -1; \
return NULL; \
} \
} \
++buf; \
CHECK_EOF(); \
} \
tok = tok_start; \
toklen = buf - tok_start; \
} while (0)
static const char *token_char_map = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\1\0\1\1\1\1\1\0\0\1\1\0\1\1\0\1\1\1\1\1\1\1\1\1\1\0\0\0\0\0\0"
"\0\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\0\0\1\1"
"\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\1\0\1\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
static const char *findchar_fast(const char *buf, const char *buf_end, const char *ranges, size_t ranges_size, int *found)
{
*found = 0;
#if __SSE4_2__
if (likely(buf_end - buf >= 16)) {
__m128i ranges16 = _mm_loadu_si128((const __m128i *)ranges);
size_t left = (buf_end - buf) & ~15;
do {
__m128i b16 = _mm_loadu_si128((const __m128i *)buf);
int r = _mm_cmpestri(ranges16, ranges_size, b16, 16, _SIDD_LEAST_SIGNIFICANT | _SIDD_CMP_RANGES | _SIDD_UBYTE_OPS);
if (unlikely(r != 16)) {
buf += r;
*found = 1;
break;
}
buf += 16;
left -= 16;
} while (likely(left != 0));
}
#else
/* suppress unused parameter warning */
(void)buf_end;
(void)ranges;
(void)ranges_size;
#endif
return buf;
}
static const char *get_token_to_eol(const char *buf, const char *buf_end, const char **token, size_t *token_len, int *ret)
{
const char *token_start = buf;
#ifdef __SSE4_2__
static const char ALIGNED(16) ranges1[16] = "\0\010" /* allow HT */
"\012\037" /* allow SP and up to but not including DEL */
"\177\177"; /* allow chars w. MSB set */
int found;
buf = findchar_fast(buf, buf_end, ranges1, 6, &found);
if (found)
goto FOUND_CTL;
#else
/* find non-printable char within the next 8 bytes, this is the hottest code; manually inlined */
while (likely(buf_end - buf >= 8)) {
#define DOIT() \
do { \
if (unlikely(!IS_PRINTABLE_ASCII(*buf))) \
goto NonPrintable; \
++buf; \
} while (0)
DOIT();
DOIT();
DOIT();
DOIT();
DOIT();
DOIT();
DOIT();
DOIT();
#undef DOIT
continue;
NonPrintable:
if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
goto FOUND_CTL;
}
++buf;
}
#endif
for (;; ++buf) {
CHECK_EOF();
if (unlikely(!IS_PRINTABLE_ASCII(*buf))) {
if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
goto FOUND_CTL;
}
}
}
FOUND_CTL:
if (likely(*buf == '\015')) {
++buf;
EXPECT_CHAR('\012');
*token_len = buf - 2 - token_start;
} else if (*buf == '\012') {
*token_len = buf - token_start;
++buf;
} else {
*ret = -1;
return NULL;
}
*token = token_start;
return buf;
}
static const char *is_complete(const char *buf, const char *buf_end, size_t last_len, int *ret)
{
int ret_cnt = 0;
buf = last_len < 3 ? buf : buf + last_len - 3;
while (1) {
CHECK_EOF();
if (*buf == '\015') {
++buf;
CHECK_EOF();
EXPECT_CHAR('\012');
++ret_cnt;
} else if (*buf == '\012') {
++buf;
++ret_cnt;
} else {
++buf;
ret_cnt = 0;
}
if (ret_cnt == 2) {
return buf;
}
}
*ret = -2;
return NULL;
}
#define PARSE_INT(valp_, mul_) \
if (*buf < '0' || '9' < *buf) { \
buf++; \
*ret = -1; \
return NULL; \
} \
*(valp_) = (mul_) * (*buf++ - '0');
#define PARSE_INT_3(valp_) \
do { \
int res_ = 0; \
PARSE_INT(&res_, 100) \
*valp_ = res_; \
PARSE_INT(&res_, 10) \
*valp_ += res_; \
PARSE_INT(&res_, 1) \
*valp_ += res_; \
} while (0)
/* returned pointer is always within [buf, buf_end), or null */
static const char *parse_http_version(const char *buf, const char *buf_end, int *minor_version, int *ret)
{
/* we want at least [HTTP/1.<two chars>] to try to parse */
if (buf_end - buf < 9) {
*ret = -2;
return NULL;
}
EXPECT_CHAR_NO_CHECK('H');
EXPECT_CHAR_NO_CHECK('T');
EXPECT_CHAR_NO_CHECK('T');
EXPECT_CHAR_NO_CHECK('P');
EXPECT_CHAR_NO_CHECK('/');
EXPECT_CHAR_NO_CHECK('1');
EXPECT_CHAR_NO_CHECK('.');
PARSE_INT(minor_version, 1);
return buf;
}
static const char *parse_headers(const char *buf, const char *buf_end, struct phr_header *headers, size_t *num_headers,
size_t max_headers, int *ret)
{
for (;; ++*num_headers) {
CHECK_EOF();
if (*buf == '\015') {
++buf;
EXPECT_CHAR('\012');
break;
} else if (*buf == '\012') {
++buf;
break;
}
if (*num_headers == max_headers) {
*ret = -1;
return NULL;
}
if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
/* parsing name, but do not discard SP before colon, see
* http://www.mozilla.org/security/announce/2006/mfsa2006-33.html */
headers[*num_headers].name = buf;
static const char ALIGNED(16) ranges1[] = "\x00 " /* control chars and up to SP */
"\"\"" /* 0x22 */
"()" /* 0x28,0x29 */
",," /* 0x2c */
"//" /* 0x2f */
":@" /* 0x3a-0x40 */
"[]" /* 0x5b-0x5d */
"{\377"; /* 0x7b-0xff */
int found;
buf = findchar_fast(buf, buf_end, ranges1, sizeof(ranges1) - 1, &found);
if (!found) {
CHECK_EOF();
}
while (1) {
if (*buf == ':') {
break;
} else if (!token_char_map[(unsigned char)*buf]) {
*ret = -1;
return NULL;
}
++buf;
CHECK_EOF();
}
if ((headers[*num_headers].name_len = buf - headers[*num_headers].name) == 0) {
*ret = -1;
return NULL;
}
++buf;
for (;; ++buf) {
CHECK_EOF();
if (!(*buf == ' ' || *buf == '\t')) {
break;
}
}
} else {
headers[*num_headers].name = NULL;
headers[*num_headers].name_len = 0;
}
const char *value;
size_t value_len;
if ((buf = get_token_to_eol(buf, buf_end, &value, &value_len, ret)) == NULL) {
return NULL;
}
/* remove trailing SPs and HTABs */
const char *value_end = value + value_len;
for (; value_end != value; --value_end) {
const char c = *(value_end - 1);
if (!(c == ' ' || c == '\t')) {
break;
}
}
headers[*num_headers].value = value;
headers[*num_headers].value_len = value_end - value;
}
return buf;
}
static const char *parse_request(const char *buf, const char *buf_end, const char **method, size_t *method_len, const char **path,
size_t *path_len, int *minor_version, struct phr_header *headers, size_t *num_headers,
size_t max_headers, int *ret)
{
/* skip first empty line (some clients add CRLF after POST content) */
CHECK_EOF();
if (*buf == '\015') {
++buf;
EXPECT_CHAR('\012');
} else if (*buf == '\012') {
++buf;
}
/* parse request line */
ADVANCE_TOKEN(*method, *method_len);
do {
++buf;
} while (*buf == ' ');
ADVANCE_TOKEN(*path, *path_len);
do {
++buf;
} while (*buf == ' ');
if (*method_len == 0 || *path_len == 0) {
*ret = -1;
return NULL;
}
if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
return NULL;
}
if (*buf == '\015') {
++buf;
EXPECT_CHAR('\012');
} else if (*buf == '\012') {
++buf;
} else {
*ret = -1;
return NULL;
}
return parse_headers(buf, buf_end, headers, num_headers, max_headers, ret);
}
int phr_parse_request(const char *buf_start, size_t len, const char **method, size_t *method_len, const char **path,
size_t *path_len, int *minor_version, struct phr_header *headers, size_t *num_headers, size_t last_len)
{
const char *buf = buf_start, *buf_end = buf_start + len;
size_t max_headers = *num_headers;
int r;
*method = NULL;
*method_len = 0;
*path = NULL;
*path_len = 0;
*minor_version = -1;
*num_headers = 0;
/* if last_len != 0, check if the request is complete (a fast countermeasure
againt slowloris */
if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
return r;
}
if ((buf = parse_request(buf, buf_end, method, method_len, path, path_len, minor_version, headers, num_headers, max_headers,
&r)) == NULL) {
return r;
}
return (int)(buf - buf_start);
}
static const char *parse_response(const char *buf, const char *buf_end, int *minor_version, int *status, const char **msg,
size_t *msg_len, struct phr_header *headers, size_t *num_headers, size_t max_headers, int *ret)
{
/* parse "HTTP/1.x" */
if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
return NULL;
}
/* skip space */
if (*buf != ' ') {
*ret = -1;
return NULL;
}
do {
++buf;
} while (*buf == ' ');
/* parse status code, we want at least [:digit:][:digit:][:digit:]<other char> to try to parse */
if (buf_end - buf < 4) {
*ret = -2;
return NULL;
}
PARSE_INT_3(status);
/* get message includig preceding space */
if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) {
return NULL;
}
if (*msg_len == 0) {
/* ok */
} else if (**msg == ' ') {
/* remove preceding space */
do {
++*msg;
--*msg_len;
} while (**msg == ' ');
} else {
/* garbage found after status code */
*ret = -1;
return NULL;
}
return parse_headers(buf, buf_end, headers, num_headers, max_headers, ret);
}
int phr_parse_response(const char *buf_start, size_t len, int *minor_version, int *status, const char **msg, size_t *msg_len,
struct phr_header *headers, size_t *num_headers, size_t last_len)
{
const char *buf = buf_start, *buf_end = buf + len;
size_t max_headers = *num_headers;
int r;
*minor_version = -1;
*status = 0;
*msg = NULL;
*msg_len = 0;
*num_headers = 0;
/* if last_len != 0, check if the response is complete (a fast countermeasure
against slowloris */
if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
return r;
}
if ((buf = parse_response(buf, buf_end, minor_version, status, msg, msg_len, headers, num_headers, max_headers, &r)) == NULL) {
return r;
}
return (int)(buf - buf_start);
}
int phr_parse_headers(const char *buf_start, size_t len, struct phr_header *headers, size_t *num_headers, size_t last_len)
{
const char *buf = buf_start, *buf_end = buf + len;
size_t max_headers = *num_headers;
int r;
*num_headers = 0;
/* if last_len != 0, check if the response is complete (a fast countermeasure
against slowloris */
if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
return r;
}
if ((buf = parse_headers(buf, buf_end, headers, num_headers, max_headers, &r)) == NULL) {
return r;
}
return (int)(buf - buf_start);
}
enum {
CHUNKED_IN_CHUNK_SIZE,
CHUNKED_IN_CHUNK_EXT,
CHUNKED_IN_CHUNK_DATA,
CHUNKED_IN_CHUNK_CRLF,
CHUNKED_IN_TRAILERS_LINE_HEAD,
CHUNKED_IN_TRAILERS_LINE_MIDDLE
};
static int decode_hex(int ch)
{
if ('0' <= ch && ch <= '9') {
return ch - '0';
} else if ('A' <= ch && ch <= 'F') {
return ch - 'A' + 0xa;
} else if ('a' <= ch && ch <= 'f') {
return ch - 'a' + 0xa;
} else {
return -1;
}
}
ssize_t phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, size_t *_bufsz)
{
size_t dst = 0, src = 0, bufsz = *_bufsz;
ssize_t ret = -2; /* incomplete */
while (1) {
switch (decoder->_state) {
case CHUNKED_IN_CHUNK_SIZE:
for (;; ++src) {
int v;
if (src == bufsz)
goto Exit;
if ((v = decode_hex(buf[src])) == -1) {
if (decoder->_hex_count == 0) {
ret = -1;
goto Exit;
}
break;
}
if (decoder->_hex_count == sizeof(size_t) * 2) {
ret = -1;
goto Exit;
}
decoder->bytes_left_in_chunk = decoder->bytes_left_in_chunk * 16 + v;
++decoder->_hex_count;
}
decoder->_hex_count = 0;
decoder->_state = CHUNKED_IN_CHUNK_EXT;
/* fallthru */
case CHUNKED_IN_CHUNK_EXT:
/* RFC 7230 A.2 "Line folding in chunk extensions is disallowed" */
for (;; ++src) {
if (src == bufsz)
goto Exit;
if (buf[src] == '\012')
break;
}
++src;
if (decoder->bytes_left_in_chunk == 0) {
if (decoder->consume_trailer) {
decoder->_state = CHUNKED_IN_TRAILERS_LINE_HEAD;
break;
} else {
goto Complete;
}
}
decoder->_state = CHUNKED_IN_CHUNK_DATA;
/* fallthru */
case CHUNKED_IN_CHUNK_DATA: {
size_t avail = bufsz - src;
if (avail < decoder->bytes_left_in_chunk) {
if (dst != src)
memmove(buf + dst, buf + src, avail);
src += avail;
dst += avail;
decoder->bytes_left_in_chunk -= avail;
goto Exit;
}
if (dst != src)
memmove(buf + dst, buf + src, decoder->bytes_left_in_chunk);
src += decoder->bytes_left_in_chunk;
dst += decoder->bytes_left_in_chunk;
decoder->bytes_left_in_chunk = 0;
decoder->_state = CHUNKED_IN_CHUNK_CRLF;
}
/* fallthru */
case CHUNKED_IN_CHUNK_CRLF:
for (;; ++src) {
if (src == bufsz)
goto Exit;
if (buf[src] != '\015')
break;
}
if (buf[src] != '\012') {
ret = -1;
goto Exit;
}
++src;
decoder->_state = CHUNKED_IN_CHUNK_SIZE;
break;
case CHUNKED_IN_TRAILERS_LINE_HEAD:
for (;; ++src) {
if (src == bufsz)
goto Exit;
if (buf[src] != '\015')
break;
}
if (buf[src++] == '\012')
goto Complete;
decoder->_state = CHUNKED_IN_TRAILERS_LINE_MIDDLE;
/* fallthru */
case CHUNKED_IN_TRAILERS_LINE_MIDDLE:
for (;; ++src) {
if (src == bufsz)
goto Exit;
if (buf[src] == '\012')
break;
}
++src;
decoder->_state = CHUNKED_IN_TRAILERS_LINE_HEAD;
break;
default:
assert(!"decoder is corrupt");
}
}
Complete:
ret = bufsz - src;
Exit:
if (dst != src)
memmove(buf + dst, buf + src, bufsz - src);
*_bufsz = dst;
return ret;
}
int phr_decode_chunked_is_in_data(struct phr_chunked_decoder *decoder)
{
return decoder->_state == CHUNKED_IN_CHUNK_DATA;
}
#undef CHECK_EOF
#undef EXPECT_CHAR
#undef ADVANCE_TOKEN

View file

@ -0,0 +1,87 @@
/*
* Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase,
* Shigeo Mitsunari
*
* The software is licensed under either the MIT License (below) or the Perl
* license.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef picohttpparser_h
#define picohttpparser_h
#include <sys/types.h>
#ifdef _MSC_VER
#define ssize_t intptr_t
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* contains name and value of a header (name == NULL if is a continuing line
* of a multiline header */
struct phr_header {
const char *name;
size_t name_len;
const char *value;
size_t value_len;
};
/* returns number of bytes consumed if successful, -2 if request is partial,
* -1 if failed */
int phr_parse_request(const char *buf, size_t len, const char **method, size_t *method_len, const char **path, size_t *path_len,
int *minor_version, struct phr_header *headers, size_t *num_headers, size_t last_len);
/* ditto */
int phr_parse_response(const char *_buf, size_t len, int *minor_version, int *status, const char **msg, size_t *msg_len,
struct phr_header *headers, size_t *num_headers, size_t last_len);
/* ditto */
int phr_parse_headers(const char *buf, size_t len, struct phr_header *headers, size_t *num_headers, size_t last_len);
/* should be zero-filled before start */
struct phr_chunked_decoder {
size_t bytes_left_in_chunk; /* number of bytes left in current chunk */
char consume_trailer; /* if trailing headers should be consumed */
char _hex_count;
char _state;
};
/* the function rewrites the buffer given as (buf, bufsz) removing the chunked-
* encoding headers. When the function returns without an error, bufsz is
* updated to the length of the decoded data available. Applications should
* repeatedly call the function while it returns -2 (incomplete) every time
* supplying newly arrived data. If the end of the chunked-encoded data is
* found, the function returns a non-negative number indicating the number of
* octets left undecoded at the tail of the supplied buffer. Returns -1 on
* error.
*/
ssize_t phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, size_t *bufsz);
/* returns if the chunked decoder is in middle of chunked data */
int phr_decode_chunked_is_in_data(struct phr_chunked_decoder *decoder);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -39,9 +39,9 @@
*****************************************************************************/
#include "common.h"
#include "utils.h"
/* extern so plugin has pid to kill exec'd process on timeouts */
extern int timeout_interval;
extern pid_t *childpid;
extern int *child_stderr_array;
extern FILE *child_process;
@ -76,18 +76,9 @@ RETSIGTYPE popen_timeout_alarm_handler (int);
#define SIG_ERR ((Sigfunc *)-1)
#endif
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
int open_max (void); /* {Prog openmax} */
static void err_sys (const char *, ...) __attribute__((noreturn,format(printf, 1, 2)));
char *rtrim (char *, const char *);
char *pname = NULL; /* caller can set this from argv[0] */
/*int *childerr = NULL;*//* ptr to array allocated at run-time */
/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
static int maxfd; /* from our open_max(), {Prog openmax} */
#ifdef REDHAT_SPOPEN_ERROR
static volatile int childtermd = 0;
#endif
@ -186,14 +177,15 @@ spopen (const char *cmdstring)
}
argv[i] = NULL;
if(maxfd == 0)
maxfd = open_max();
if (childpid == NULL) { /* first time through */
maxfd = open_max (); /* allocate zeroed out array for child pids */
if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
return (NULL);
}
if (child_stderr_array == NULL) { /* first time through */
maxfd = open_max (); /* allocate zeroed out array for child pids */
if ((child_stderr_array = calloc ((size_t)maxfd, sizeof (int))) == NULL)
return (NULL);
}
@ -273,15 +265,6 @@ spclose (FILE * fp)
return (1);
}
#ifdef OPEN_MAX
static int openmax = OPEN_MAX;
#else
static int openmax = 0;
#endif
#define OPEN_MAX_GUESS 256 /* if OPEN_MAX is indeterminate */
/* no guarantee this is adequate */
#ifdef REDHAT_SPOPEN_ERROR
RETSIGTYPE
popen_sigchld_handler (int signo)
@ -309,63 +292,3 @@ popen_timeout_alarm_handler (int signo)
exit (STATE_CRITICAL);
}
}
int
open_max (void)
{
if (openmax == 0) { /* first time through */
errno = 0;
if ((openmax = sysconf (_SC_OPEN_MAX)) < 0) {
if (errno == 0)
openmax = OPEN_MAX_GUESS; /* it's indeterminate */
else
err_sys (_("sysconf error for _SC_OPEN_MAX"));
}
}
return (openmax);
}
/* Fatal error related to a system call.
* Print a message and die. */
#define MAXLINE 2048
static void
err_sys (const char *fmt, ...)
{
int errnoflag = 1;
int errno_save;
char buf[MAXLINE];
va_list ap;
va_start (ap, fmt);
/* err_doit (1, fmt, ap); */
errno_save = errno; /* value caller might want printed */
vsprintf (buf, fmt, ap);
if (errnoflag)
sprintf (buf + strlen (buf), ": %s", strerror (errno_save));
strcat (buf, "\n");
fflush (stdout); /* in case stdout and stderr are the same */
fputs (buf, stderr);
fflush (NULL); /* flushes all stdio output streams */
va_end (ap);
exit (1);
}
char *
rtrim (char *str, const char *tok)
{
int i = 0;
int j = sizeof (str);
while (str != NULL && i < j) {
if (*(str + i) == *tok) {
sprintf (str + i, "%s", "\0");
return str;
}
i++;
}
return str;
}

View file

@ -7,7 +7,6 @@ FILE *spopen (const char *);
int spclose (FILE *);
RETSIGTYPE popen_timeout_alarm_handler (int);
extern unsigned int timeout_interval;
pid_t *childpid=NULL;
int *child_stderr_array=NULL;
FILE *child_process=NULL;

View file

@ -67,19 +67,6 @@
* occur in any number of threads simultaneously. */
static pid_t *np_pids = NULL;
/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
* 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. */
#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
#endif
/** prototypes **/
static int np_runcmd_open(const char *, int *, int *)
__attribute__((__nonnull__(1, 2, 3)));
@ -99,14 +86,8 @@ extern void die (int, const char *, ...)
* through this api and thus achieve async-safeness throughout the api */
void np_runcmd_init(void)
{
#ifndef maxfd
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;
}
#endif
if(maxfd == 0)
maxfd = open_max();
if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t));
}

View file

@ -193,7 +193,17 @@ int np_net_ssl_read(void *buf, int num) {
int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
# ifdef USE_OPENSSL
X509 *certificate=NULL;
X509 *certificate = NULL;
certificate=SSL_get_peer_certificate(s);
return(np_net_ssl_check_certificate(certificate, days_till_exp_warn, days_till_exp_crit));
# else /* ifndef USE_OPENSSL */
printf("%s\n", _("WARNING - Plugin does not support checking certificates."));
return STATE_WARNING;
# endif /* USE_OPENSSL */
}
int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit){
# ifdef USE_OPENSSL
X509_NAME *subj=NULL;
char timestamp[50] = "";
char cn[MAX_CN_LENGTH]= "";
@ -210,7 +220,6 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
int time_remaining;
time_t tm_t;
certificate=SSL_get_peer_certificate(s);
if (!certificate) {
printf("%s\n",_("CRITICAL - Cannot retrieve server certificate."));
return STATE_CRITICAL;

View file

@ -1,58 +1,54 @@
{
'MYSQL_LOGIN_DETAILS' => '-u root -d test',
'NP_ALLOW_SUDO' => 'yes',
'NP_DNS_SERVER' => '8.8.8.8',
'NP_GOOD_NTP_SERVICE' => '',
'NP_HOSTNAME_INVALID' => 'nosuchhost',
'NP_HOSTNAME_VALID' => 'monitoringplugins.org',
'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
'NP_HOST_DHCP_RESPONSIVE' => '',
'NP_HOST_HPJD_PORT_INVALID' => '161',
'NP_HOST_HPJD_PORT_VALID' => '',
'NP_HOSTNAME_INVALID_CIDR' => '130.133.8.39/30',
'NP_HOSTNAME_INVALID' => 'nosuchhost',
'NP_HOSTNAME_VALID_CIDR' => '130.133.8.41/30',
'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
'NP_HOSTNAME_VALID' => 'monitoring-plugins.org',
'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
'NP_HOST_RESPONSIVE' => 'localhost',
'NP_HOST_SMB' => '',
'NP_HOST_SNMP' => 'localhost',
'NP_HOST_SNMP' => '',
'NP_HOST_TCP_FTP' => '',
'NP_HOST_TCP_HPJD' => '',
'NP_HOST_HPJD_PORT_INVALID' => '161',
'NP_HOST_HPJD_PORT_VALID' => '',
'NP_HOST_TCP_HTTP' => 'localhost',
'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org',
'NP_HOST_TCP_HTTP' => 'localhost',
'NP_HOST_TCP_IMAP' => 'imap.web.de',
'NP_HOST_TCP_JABBER' => 'jabber.org',
'NP_HOST_TCP_LDAP' => 'localhost',
'NP_HOST_TCP_POP' => 'pop.web.de',
'NP_HOST_TCP_PROXY' => 'localhost',
'NP_HOST_TCP_SMTP' => 'localhost',
'NP_HOST_TCP_SMTP_NOTLS' => '',
'NP_HOST_TCP_SMTP_TLS' => '',
'NP_HOST_TLS_CERT' => 'localhost,
'NP_HOST_TLS_HTTP' => 'localhost',
'NP_HOST_UDP_TIME' => 'none',
'NP_INTERNET_ACCESS' => 'yes',
'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain',
'NP_MOUNTPOINT2_VALID' => '/media/ramdisk',
'NP_MOUNTPOINT_VALID' => '/',
'NP_MYSQL_LOGIN_DETAILS' => '-u root -d test',
'NP_MYSQL_SERVER' => 'localhost',
'NP_HOST_UDP_TIME' => 'localhost',
'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock',
'NP_MYSQL_WITH_SLAVE' => '',
'NP_MYSQL_WITH_SLAVE_LOGIN' => '',
'NP_NO_NTP_SERVICE' => 'localhost',
'NP_PORT_TCP_PROXY' => '3128',
'NP_SMB_SHARE' => '',
'NP_SMB_SHARE_DENY' => '',
'NP_SMB_SHARE_SPC' => '',
'NP_SMB_VALID_USER' => '',
'NP_SMB_VALID_USER_PASS' => '',
'NP_SNMP_COMMUNITY' => 'public',
'NP_SNMP_COMMUNITY' => '',
'NP_SNMP_USER' => '',
'NP_SSH_CONFIGFILE' => '~/.ssh/config',
'NP_SSH_HOST' => 'localhost',
'NP_SSH_IDENTITY' => '~/.ssh/id_dsa',
'NP_HOST_TCP_JABBER' => 'jabber.org',
'host_nonresponsive' => '10.0.0.1',
'host_responsive' => 'localhost',
'host_snmp' => '',
'host_tcp_ftp' => '',
'host_tcp_http' => 'localhost',
'host_tcp_imap' => 'imap.nierlein.de',
'host_tcp_smtp' => 'localhost',
'hostname_invalid' => 'nosuchhost',
'snmp_community' => '',
'user_snmp' => '',
'host_udp_time' => 'none',
'NP_SSH_IDENTITY' => '~/.ssh/id_rsa'
}

View file

@ -23,7 +23,7 @@ sub make_result_regexp {
}
if (-x "./check_apt") {
plan tests => 28;
plan tests => 36;
} else {
plan skip_all => "No check_apt compiled";
}
@ -40,10 +40,18 @@ $result = NPTest->testCmd( sprintf($testfile_command, "", "debian2") );
is( $result->return_code, 1, "Debian apt output, warning" );
like( $result->output, make_result_regexp(13, 0), "Output correct" );
$result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian2") );
is( $result->return_code, 0, "Debian apt output, no critical" );
like( $result->output, make_result_regexp(13, 0), "Output correct" );
$result = NPTest->testCmd( sprintf($testfile_command, "", "debian3") );
is( $result->return_code, 2, "Debian apt output, some critical" );
like( $result->output, make_result_regexp(19, 4), "Output correct" );
$result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian3") );
is( $result->return_code, 2, "Debian apt output, some critical" );
like( $result->output, make_result_regexp(19, 4), "Output correct" );
$result = NPTest->testCmd( sprintf($testfile_command, "-c '^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)'", "debian3") );
is( $result->return_code, 2, "Debian apt output - should have same result when default security regexp specified via -c" );
like( $result->output, make_result_regexp(19, 4), "Output correct" );
@ -52,6 +60,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") );
is( $result->return_code, 1, "Debian apt output, filter for libc6" );
like( $result->output, make_result_regexp(3, 0), "Output correct" );
$result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") );
is( $result->return_code, 1, "Debian apt output, filter for libc6, not critical" );
like( $result->output, make_result_regexp(3, 0), "Output correct" );
$result = NPTest->testCmd( sprintf($testfile_command, "-i libc6 -i xen", "debian3") );
is( $result->return_code, 2, "Debian apt output, filter for libc6 and xen" );
like( $result->output, make_result_regexp(9, 4), "Output correct" );
@ -64,6 +76,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6", "debian3") );
is( $result->return_code, 2, "Debian apt output, filter out libc6" );
like( $result->output, make_result_regexp(16, 4), "Output correct" );
$result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -o", "debian3") );
is( $result->return_code, 2, "Debian apt output, filter out libc6, critical" );
like( $result->output, make_result_regexp(16, 4), "Output correct" );
$result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -e xen", "debian3") );
is( $result->return_code, 1, "Debian apt output, filter out libc6 and xen" );
like( $result->output, make_result_regexp(10, 0), "Output correct" );

View file

@ -9,17 +9,9 @@ use Test::More;
use NPTest;
# Required parameters
my $ssh_service = getTestParameter( "NP_SSH_HOST",
"A host providing SSH service",
"localhost");
my $ssh_key = getTestParameter( "NP_SSH_IDENTITY",
"A key allowing access to NP_SSH_HOST",
"~/.ssh/id_dsa");
my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE",
"A config file with ssh settings",
"~/.ssh/config");
my $ssh_service = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost");
my $ssh_key = getTestParameter("NP_SSH_IDENTITY", "A key allowing access to NP_SSH_HOST", "~/.ssh/id_dsa");
my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", "A config file with ssh settings", "~/.ssh/config");
plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key);

199
plugins/t/check_curl.t Normal file
View file

@ -0,0 +1,199 @@
#! /usr/bin/perl -w -I ..
#
# HyperText Transfer Protocol (HTTP) Test via check_http
#
#
use strict;
use Test::More;
use POSIX qw/mktime strftime/;
use NPTest;
plan tests => 57;
my $successOutput = '/OK.*HTTP.*second/';
my $res;
my $plugin = 'check_http';
$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost");
my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes");
my $host_tcp_http2 = getTestParameter("NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org");
my $host_tcp_proxy = getTestParameter("NP_HOST_TCP_PROXY", "A host providing a HTTP proxy with CONNECT support", "localhost");
my $port_tcp_proxy = getTestParameter("NP_PORT_TCP_PROXY", "Port of the proxy with HTTP and CONNECT support", "3128");
my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
$res = NPTest->testCmd(
"./$plugin $host_tcp_http -wt 300 -ct 600"
);
cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
like( $res->output, $successOutput, "Output OK" );
$res = NPTest->testCmd(
"./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
);
like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
$res = NPTest->testCmd(
"./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
);
cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
cmp_ok( $res->output, 'eq', "HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Timeout was reached", "Output OK");
$res = NPTest->testCmd(
"./$plugin $hostname_invalid -wt 1 -ct 2"
);
cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
# The first part of the message comes from the OS catalogue, so cannot check this.
# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename
# Is also possible to get a socket timeout if DNS is not responding fast enough
# cURL gives us consistent strings from it's own 'lib/strerror.c'
like( $res->output, "/cURL returned 6 - Couldn't resolve host name/", "Output OK");
# host header checks
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http");
like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http -p 80");
like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80 -k 'Host: testhost:8001'");
like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" );
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
$res = NPTest->testCmd("./$plugin -v -I $host_tcp_http -p 80 -k 'Host: testhost:8001'");
like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" );
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
SKIP: {
skip "No internet access", 3 if $internet_access eq "no";
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S");
like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http:8080 -S -p 443");
like( $res->output, '/^Host: '.$host_tls_http.':8080\s*$/ms', "Host Header OK" );
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443");
like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
};
SKIP: {
skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring'" );
cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'");
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing'" );
cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'");
like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -R 'mONiTORing'" );
cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'");
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring' --invert-regex" );
cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" );
cmp_ok( $res->return_code, "==", 0, "And also when not found");
}
SKIP: {
skip "No internet access", 16 if $internet_access eq "no";
$res = NPTest->testCmd(
"./$plugin --ssl $host_tls_http"
);
cmp_ok( $res->return_code, '==', 0, "Can read https for $host_tls_http" );
$res = NPTest->testCmd( "./$plugin -C 1 --ssl $host_tls_http" );
cmp_ok( $res->return_code, '==', 0, "Checking certificate for $host_tls_http");
like ( $res->output, "/Certificate '$host_tls_cert' will expire on/", "Output OK" );
my $saved_cert_output = $res->output;
$res = NPTest->testCmd( "./$plugin -C 8000,1 --ssl $host_tls_http" );
cmp_ok( $res->return_code, '==', 1, "Checking certificate for $host_tls_http");
like ( $res->output, qr/WARNING - Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" );
$res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
is( $res->return_code, 0, "Old syntax for cert checking okay" );
is( $res->output, $saved_cert_output, "Same output as new syntax" );
$res = NPTest->testCmd( "./$plugin -H $host_tls_http -C 1" );
is( $res->return_code, 0, "Updated syntax for cert checking okay" );
is( $res->output, $saved_cert_output, "Same output as new syntax" );
$res = NPTest->testCmd( "./$plugin -C 1 $host_tls_http" );
cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
$res = NPTest->testCmd( "./$plugin $host_tls_http -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 ./$plugin -C 1 $host_tls_http");
like($res->output, qr/OK - Certificate '$host_tls_cert' 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))."' ./$plugin -C 1 $host_tls_http");
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' 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))."' ./$plugin -C 1 $host_tls_http");
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' 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))."' ./$plugin -C 1 $host_tls_http");
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' 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))."' ./$plugin -C 1 $host_tls_http");
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' 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))."' ./$plugin -C 1 $host_tls_http");
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output");
is( $res->return_code, 2, "Certificate expired exit code" );
};
$res = NPTest->testCmd( "./$plugin --ssl $host_tls_http -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(
"./$plugin --ssl -H www.e-paycobalt.com"
);
cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
is( $res->return_code, 0, "Redirection based on location is okay");
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
}

View file

@ -248,11 +248,11 @@ $result = NPTest->testCmd( "./check_disk -w 100% -c 100% ".${mountpoint_valid} )
cmp_ok( $result->return_code, "==", 2, "100% empty" );
like( $result->output, $failureOutput, "Right output" );
$result = NPTest->testCmd( "./check_disk -w 100000 -c 100000 $mountpoint_valid" );
cmp_ok( $result->return_code, '==', 2, "Check for 100GB free" );
$result = NPTest->testCmd( "./check_disk -w 100000000 -c 100000000 $mountpoint_valid" );
cmp_ok( $result->return_code, '==', 2, "Check for 100TB free" );
$result = NPTest->testCmd( "./check_disk -w 100 -c 100 -u GB ".${mountpoint_valid} ); # 100 GB empty
cmp_ok( $result->return_code, "==", 2, "100 GB empty" );
$result = NPTest->testCmd( "./check_disk -w 100 -c 100 -u TB ".${mountpoint_valid} ); # 100 TB empty
cmp_ok( $result->return_code, "==", 2, "100 TB empty" );
# Checking old syntax of check_disk warn crit [fs], with warn/crit at USED% thresholds

View file

@ -10,26 +10,38 @@ use NPTest;
plan skip_all => "check_dns not compiled" unless (-x "check_dns");
plan tests => 16;
plan tests => 19;
my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
my $hostname_valid = getTestParameter(
"NP_HOSTNAME_VALID",
"A valid (known to DNS) hostname",
"monitoring-plugins.org"
"monitoring-plugins.org",
);
my $hostname_valid_ip = getTestParameter(
"NP_HOSTNAME_VALID_IP",
"The IP address of the valid hostname $hostname_valid",
"66.118.156.50",
"130.133.8.40",
);
my $hostname_valid_cidr = getTestParameter(
"NP_HOSTNAME_VALID_CIDR",
"An valid CIDR range containing $hostname_valid_ip",
"130.133.8.41/30",
);
my $hostname_invalid_cidr = getTestParameter(
"NP_HOSTNAME_INVALID_CIDR",
"An (valid) CIDR range NOT containing $hostname_valid_ip",
"130.133.8.39/30",
);
my $hostname_valid_reverse = getTestParameter(
"NP_HOSTNAME_VALID_REVERSE",
"The hostname of $hostname_valid_ip",
"66-118-156-50.static.sagonet.net.",
"orwell.monitoring-plugins.org.",
);
my $hostname_invalid = getTestParameter(
@ -87,3 +99,9 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev
cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
like ( $res->output, $successOutput, "Output OK");
$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_cidr -t 5");
cmp_ok( $res->return_code, '==', 0, "Got expected address");
$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5");
cmp_ok( $res->return_code, '==', 2, "Got wrong address");
like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK");

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