Compare commits
40 commits
a005eec388
...
8cd52e30e9
Author | SHA1 | Date | |
---|---|---|---|
8cd52e30e9 | |||
7236330ac9 | |||
bee01b8716 | |||
a7037b2f06 | |||
223a2060cb | |||
1e0ad80693 | |||
dde9499b64 | |||
b724e41b3e | |||
ddaa81fb4c | |||
6bb85804e1 | |||
baad659ea8 | |||
7e8c776bf5 | |||
f8202f34c0 | |||
d0b0db0bd7 | |||
2f5d0256ae | |||
55f87b7a39 | |||
3a5f25020e | |||
b6a58eb919 | |||
45f91e2095 | |||
e817fecb7d | |||
38aec8e03d | |||
|
af69fcf310 | ||
|
9cb7faeeaf | ||
86f8f03a5a | |||
bf6001384f | |||
043d328f4e | |||
|
3c5882d3a9 | ||
f3e127972c | |||
9c49b6f179 | |||
1b018b3ee1 | |||
01e11f9582 | |||
8b17915ecc | |||
a6b1db0c7c | |||
15760add88 | |||
672d37c1af | |||
|
2d414bd266 | ||
92ccdbc4b4 | |||
b6f2ef0555 | |||
d4dccdaaa6 | |||
600e193ca4 |
127 changed files with 17195 additions and 31804 deletions
6
INSTALL
6
INSTALL
|
@ -1,8 +1,8 @@
|
|||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
|
@ -225,7 +225,7 @@ order to use an ANSI C compiler:
|
|||
|
||||
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||
|
||||
HP-UX 'make' updates targets which have the same time stamps as their
|
||||
HP-UX 'make' updates targets which have the same timestamps as their
|
||||
prerequisites, which makes it generally unusable when shipped generated
|
||||
files such as 'configure' are involved. Use GNU 'make' instead.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
|
||||
SUBDIRS = gl tap lib plugins plugins-scripts plugins-root @PERLMODS_DIR@
|
||||
|
||||
EXTRA_DIST = config.rpath \
|
||||
ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ NEWS \
|
||||
|
|
32
Makefile.in
32
Makefile.in
|
@ -1,7 +1,7 @@
|
|||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -163,8 +163,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/nocrash.m4 $(top_srcdir)/gl/m4/off_t.m4 \
|
||||
$(top_srcdir)/gl/m4/open-cloexec.m4 \
|
||||
$(top_srcdir)/gl/m4/open-slash.m4 $(top_srcdir)/gl/m4/open.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/pid_t.m4 \
|
||||
$(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pthread_rwlock_rdlock.m4 \
|
||||
$(top_srcdir)/gl/m4/realloc.m4 \
|
||||
$(top_srcdir)/gl/m4/reallocarray.m4 \
|
||||
|
@ -177,7 +176,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/sockets.m4 $(top_srcdir)/gl/m4/socklen.m4 \
|
||||
$(top_srcdir)/gl/m4/sockpfaf.m4 $(top_srcdir)/gl/m4/ssize_t.m4 \
|
||||
$(top_srcdir)/gl/m4/stat-time.m4 $(top_srcdir)/gl/m4/stat.m4 \
|
||||
$(top_srcdir)/gl/m4/std-gnu11.m4 \
|
||||
$(top_srcdir)/gl/m4/stdalign.m4 \
|
||||
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
|
||||
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
|
||||
|
@ -195,7 +193,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/time_r.m4 $(top_srcdir)/gl/m4/timegm.m4 \
|
||||
$(top_srcdir)/gl/m4/ungetc.m4 $(top_srcdir)/gl/m4/unistd_h.m4 \
|
||||
$(top_srcdir)/gl/m4/unlocked-io.m4 \
|
||||
$(top_srcdir)/gl/m4/vararrays.m4 \
|
||||
$(top_srcdir)/gl/m4/vasnprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/vasprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/visibility.m4 \
|
||||
|
@ -269,12 +266,10 @@ am__define_uniq_tagged_files = \
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
CSCOPE = cscope
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
|
||||
$(srcdir)/test.pl.in $(top_srcdir)/build-aux/config.guess \
|
||||
$(srcdir)/test.pl.in $(top_srcdir)/build-aux/compile \
|
||||
$(top_srcdir)/build-aux/config.guess \
|
||||
$(top_srcdir)/build-aux/config.rpath \
|
||||
$(top_srcdir)/build-aux/config.sub \
|
||||
$(top_srcdir)/build-aux/install-sh \
|
||||
|
@ -282,10 +277,11 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
|
|||
$(top_srcdir)/build-aux/missing \
|
||||
$(top_srcdir)/build-aux/mkinstalldirs \
|
||||
$(top_srcdir)/pkg/solaris/pkginfo.in ABOUT-NLS AUTHORS COPYING \
|
||||
ChangeLog INSTALL NEWS README THANKS build-aux/config.guess \
|
||||
build-aux/config.rpath build-aux/config.sub \
|
||||
build-aux/install-sh build-aux/ltmain.sh build-aux/missing \
|
||||
build-aux/mkinstalldirs config.rpath mkinstalldirs
|
||||
ChangeLog INSTALL NEWS README THANKS build-aux/compile \
|
||||
build-aux/config.guess build-aux/config.rpath \
|
||||
build-aux/config.sub build-aux/install-sh build-aux/ltmain.sh \
|
||||
build-aux/missing build-aux/mkinstalldirs config.rpath \
|
||||
mkinstalldirs
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
|
@ -356,6 +352,8 @@ CFLAGS = @CFLAGS@
|
|||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DBILIBS = @DBILIBS@
|
||||
DEFS = -DLOCALEDIR=\"$(localedir)\"
|
||||
|
@ -375,6 +373,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
|
|||
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
|
||||
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
|
||||
ERRNO_H = @ERRNO_H@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTRAS = @EXTRAS@
|
||||
EXTRAS_ROOT = @EXTRAS_ROOT@
|
||||
|
@ -1746,6 +1745,8 @@ install_sh = @install_sh@
|
|||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = $(datadir)/locale
|
||||
localedir_c = @localedir_c@
|
||||
localedir_c_make = @localedir_c_make@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
|
@ -1765,7 +1766,7 @@ top_build_prefix = @top_build_prefix@
|
|||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
with_trusted_path = @with_trusted_path@
|
||||
SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
|
||||
SUBDIRS = gl tap lib plugins plugins-scripts plugins-root @PERLMODS_DIR@
|
||||
EXTRA_DIST = config.rpath \
|
||||
ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ NEWS \
|
||||
NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
|
||||
|
@ -1951,7 +1952,6 @@ cscopelist-am: $(am__tagged_files)
|
|||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
|
59
NEWS
59
NEWS
|
@ -1,5 +1,64 @@
|
|||
This file documents the major additions and syntax changes between releases.
|
||||
|
||||
2.4.0 25th Jul 2024
|
||||
FIXES
|
||||
* check_dbi: Compiler warning for uninitialized variable
|
||||
* check_curl: Initialize pointer before usage
|
||||
* check_ntp: Initialize intermediate results in any case
|
||||
* Fixes for -Wsign-compare
|
||||
* check_tcp: Fixes an error with using the wrong type for a variable
|
||||
* check_mailq: exit on empty strings and exit early
|
||||
* check_users: Change option for sanity checking arguments to avoid segfault
|
||||
* check_users: Update help to properly show that thresholds are ranges
|
||||
* check_users: fix segfault
|
||||
* check_dbi: Fix compiler warning for uninitialized variable
|
||||
* check_curl: Initialize pointer before usage
|
||||
* check_ntp: Initialize intermediate results in any case
|
||||
* Fix logic in is_uint64_t to fix type-limit warning
|
||||
* check_ntp_peer: Fixes for Wmaybe-unitialized and some restructuring
|
||||
* check_dns: Remove unused variable
|
||||
* check_ntp_peer: Fixes for Wmaybe-unitialized and some restructuring
|
||||
* check_dns: Remove unused variable
|
||||
* check_disk: fix ignore-missing in combination with includes
|
||||
* check_procs: ignore our own children
|
||||
* Prevent -lcrypto from showing up in Makefile dependencies
|
||||
* Change irritating NULL assignment
|
||||
* check_http: Remove self assignment of a variable and add some comments
|
||||
* check_snmp: Remove unused variable
|
||||
* check_dhcp: Make implicit conversion explicit to dismiss warning
|
||||
* check_http: Remove self assignment of a variable and add some comments
|
||||
* check_dhcp: Make implicit conversion explicit to dismiss warning
|
||||
* Ini Parser: Avoid freeing symbols from text section
|
||||
* check_icmp: keep performance data order in case of none-reachable hosts
|
||||
* check_swap: Change another fake boolean to a real one
|
||||
* check_swap: Rename type since *_t is reserved for C standard types
|
||||
* check_ssh: Fix a typo in "remote-protocol parameter
|
||||
* check_ssh: Handle non-alpha software versions
|
||||
* check_ssh: properly parse a delayed version control string
|
||||
* check_disk: Fail on missing arguments for --warning and --critical and fix a test case
|
||||
* check_disk: Use new test function for percentage expressions
|
||||
* check_load: remove unused code
|
||||
* check_curl/check_http: clarified format of POST data
|
||||
|
||||
ENHANCEMENTS
|
||||
* Use C99 booleans
|
||||
* check_mailq: remove trailing whitespaces
|
||||
* check_mailq: unify tabs/spaces
|
||||
* check_oracle: Shellcheck fixes
|
||||
* check_ups: output ups.realpower if supported
|
||||
* check_disk: add -n short option for --ignore-missing
|
||||
* check_procs: Improve help text, mentioning excluded processes
|
||||
* check_procs: Generalise wording, remove mentioning of nrpe
|
||||
* check_curl: add haproxy protocol option
|
||||
* Improve negate plugin helptext
|
||||
* check_disk: increase alert precision
|
||||
* check_ircd: IPv6 support
|
||||
* check_nwstat: adds percentage used space
|
||||
* Add new test function for percentage expressions
|
||||
* check_swap: Possibility to run check_swap without thresholds
|
||||
* check_ups: additional alarm conditions
|
||||
* check_http/check_curl: added a --regex-state option to change the state of a regex check
|
||||
|
||||
2.3.5 18th Oct 2023
|
||||
FIXES
|
||||
* Include maxfd.h in lib Makefile
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
SRC_ROOT=`dirname $0`
|
||||
|
||||
NPVF=NP-VERSION-FILE
|
||||
DEF_VER=2.3.5
|
||||
DEF_VER=2.4.0
|
||||
|
||||
LF='
|
||||
'
|
||||
|
|
43
THANKS
43
THANKS
|
@ -2,18 +2,18 @@ This software is brought to you by the Monitoring Plugins Development Team. Howe
|
|||
there have been many contributors to this project. Everyone below has helped in
|
||||
raising bug reports, creating patches or contributing new plugins.
|
||||
|
||||
Arkadiusz Miśkiewicz
|
||||
Matthias Hähnel
|
||||
dag rob?le
|
||||
Diego Elio Pettenò
|
||||
Elan Ruusamäe
|
||||
Thoralf Rickert-Wendt
|
||||
Aksel Sjögren
|
||||
fabiodds
|
||||
Nicolai Søborg
|
||||
Arkadiusz Miśkiewicz
|
||||
Wolfgang Karall-Ahlborn
|
||||
Matthias Döhler
|
||||
Marc Sánchez
|
||||
Wolfgang Karall-Ahlborn
|
||||
Thoralf Rickert-Wendt
|
||||
Diego Elio Pettenò
|
||||
Nicolai Søborg
|
||||
Elan Ruusamäe
|
||||
Matthias Hähnel
|
||||
fabiodds
|
||||
Aksel Sjögren
|
||||
Randy O'Meara
|
||||
Oskar Ahner
|
||||
Lance Albertson
|
||||
|
@ -25,8 +25,8 @@ Felipe Gustavo de Almeida
|
|||
Michael Almond
|
||||
Michael Anthon
|
||||
Bernd Apfel
|
||||
Bernd Arnold
|
||||
Paula Arnold
|
||||
Bernd Arnold
|
||||
Kondoros Attila
|
||||
Daniel Austin
|
||||
Karol Babioch
|
||||
|
@ -89,9 +89,9 @@ Lee Clemens
|
|||
Ben Clewett
|
||||
Jean-Claude Computing
|
||||
Lionel Cons
|
||||
Ollie Cook
|
||||
Garry Cook
|
||||
Charlie Cook
|
||||
Garry Cook
|
||||
Ollie Cook
|
||||
Luca Corti
|
||||
Greg Cox
|
||||
Jason Crawford
|
||||
|
@ -135,8 +135,8 @@ Paulo Fessel
|
|||
James Fidell
|
||||
Tobias Fiebig
|
||||
Roman Fiedler
|
||||
Johan Fischer
|
||||
Bernhard Fischer
|
||||
Johan Fischer
|
||||
Matthias Flacke
|
||||
Martin Foster
|
||||
Felix Frank
|
||||
|
@ -149,11 +149,12 @@ Tim Gates
|
|||
Sven Geggus
|
||||
Jonas Genannt
|
||||
Robby Giffin
|
||||
Flo Gleixner
|
||||
Florian Gleixner
|
||||
Flo Gleixner
|
||||
Evgeni Golov
|
||||
Joseph Gooch
|
||||
Aravind Gottipati
|
||||
Ralph Gottschalkson
|
||||
Kev Green
|
||||
Steve Greenland
|
||||
Roberto Greiner
|
||||
|
@ -166,10 +167,11 @@ Sebastien Guay
|
|||
Linda Guo
|
||||
Jon Hallett
|
||||
Steve Hanselman
|
||||
Ask Bjoern Hansen
|
||||
Jacob Hansen
|
||||
Ask Bjoern Hansen
|
||||
Sebastian Harl
|
||||
Michael Haro
|
||||
Sven Hartge
|
||||
Olli Hauer
|
||||
Gunnar Hellekson
|
||||
Stuart Henderson
|
||||
|
@ -204,6 +206,7 @@ Konstantin Khomoutov
|
|||
Serhan Kiymaz
|
||||
Alexander A. Klimov
|
||||
Denis Knauf
|
||||
Eric Knibbe
|
||||
Harald Koch
|
||||
Tilman Koschnick
|
||||
John Koyle
|
||||
|
@ -247,8 +250,8 @@ Gerardo Malazdrewicz
|
|||
Ricardo Maraschini
|
||||
Michael Markstaller
|
||||
John Marquart
|
||||
Jason Martin
|
||||
Ernst-Dieter Martin
|
||||
Jason Martin
|
||||
Christopher Maser
|
||||
Mathieu Masseboeuf
|
||||
Alexander Matey
|
||||
|
@ -293,6 +296,7 @@ Remi Paulmier
|
|||
Tom Payerle
|
||||
Nick Peelman
|
||||
Fabian Pehla
|
||||
Alvar Penning
|
||||
Chris Pepper
|
||||
Matt Perry
|
||||
Matthew Peters
|
||||
|
@ -318,6 +322,7 @@ Abid Rasheed
|
|||
Patrick Rauscher
|
||||
Jeremy Reed
|
||||
Spenser Reinhardt
|
||||
Eunice Remoquillo
|
||||
Marc Remy
|
||||
Alessandro Ren
|
||||
Joe Rhett
|
||||
|
@ -325,6 +330,7 @@ Cliff Rice
|
|||
Alain Richard
|
||||
Didi Rieder
|
||||
Steve Rigler
|
||||
Emmanuel Riviere
|
||||
Josip Rodin
|
||||
Kenny Root
|
||||
Wolfgang Rosenauer
|
||||
|
@ -335,12 +341,13 @@ Sascha Runschke
|
|||
Dietmar Ruzicka
|
||||
Ralph Rye
|
||||
Alen Salamun
|
||||
Louis Sautier
|
||||
Sven Schaffranneck
|
||||
Christoph Schell
|
||||
Thomas Schimpke
|
||||
Benjamin Schmid
|
||||
Christian Schmidt
|
||||
Sebastian Schmidt
|
||||
Christian Schmidt
|
||||
Henning Schmiedehausen
|
||||
Christian Schneemann
|
||||
Cove Schneider
|
||||
|
@ -416,8 +423,8 @@ Shawn Wills
|
|||
Rob Windsor
|
||||
Mario Witte
|
||||
Alexander Wittig
|
||||
Tobias Wolf
|
||||
Brian De Wolf
|
||||
Tobias Wolf
|
||||
Eric Wunderlin
|
||||
Patric Wust
|
||||
Jamie Zawinski
|
||||
|
|
777
aclocal.m4
vendored
777
aclocal.m4
vendored
File diff suppressed because it is too large
Load diff
348
build-aux/compile
Executable file
348
build-aux/compile
Executable file
|
@ -0,0 +1,348 @@
|
|||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# 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, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN* | MSYS*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/* | msys/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
|
||||
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
1500
build-aux/config.guess
vendored
1500
build-aux/config.guess
vendored
File diff suppressed because it is too large
Load diff
2855
build-aux/config.sub
vendored
2855
build-aux/config.sub
vendored
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
|||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
|
||||
# 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
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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
|
||||
|
@ -105,8 +105,11 @@ trap "st=130; $do_exit" 2
|
|||
trap "st=141; $do_exit" 13
|
||||
trap "st=143; $do_exit" 15
|
||||
|
||||
# Test script is run here.
|
||||
"$@" >$log_file 2>&1
|
||||
# Test script is run here. We create the file first, then append to it,
|
||||
# to ameliorate tests themselves also writing to the log file. Our tests
|
||||
# don't, but others can (automake bug#35762).
|
||||
: >"$log_file"
|
||||
"$@" >>"$log_file" 2>&1
|
||||
estatus=$?
|
||||
|
||||
if test $enable_hard_errors = no && test $estatus -eq 99; then
|
||||
|
@ -128,7 +131,7 @@ esac
|
|||
# know whether the test passed or failed simply by looking at the '.log'
|
||||
# file, without the need of also peaking into the corresponding '.trs'
|
||||
# file (automake bug#11814).
|
||||
echo "$res $test_name (exit status: $estatus)" >>$log_file
|
||||
echo "$res $test_name (exit status: $estatus)" >>"$log_file"
|
||||
|
||||
# Report outcome to console.
|
||||
echo "${col}${res}${std}: $test_name"
|
||||
|
|
24
config.h.in
24
config.h.in
|
@ -338,8 +338,7 @@
|
|||
may be supplied by this distribution. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
/* Define to 1 if <alloca.h> works. */
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
|
@ -860,9 +859,6 @@
|
|||
/* Define to 1 if you have the `memmove' function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <minix/config.h> header file. */
|
||||
#undef HAVE_MINIX_CONFIG_H
|
||||
|
||||
|
@ -1064,6 +1060,9 @@
|
|||
/* Define to 1 if you have the <stdio_ext.h> header file. */
|
||||
#undef HAVE_STDIO_EXT_H
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#undef HAVE_STDIO_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
|
@ -1076,7 +1075,7 @@
|
|||
/* Define to 1 if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the `strerror_r' function. */
|
||||
/* Define if you have `strerror_r'. */
|
||||
#undef HAVE_STRERROR_R
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
|
@ -1836,9 +1835,9 @@
|
|||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define if the block counts reported by statfs may be truncated to 2GB and
|
||||
|
@ -1874,7 +1873,9 @@
|
|||
/* Define if statvfs64 should be preferred over statvfs. */
|
||||
#undef STAT_STATVFS64
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
/* Define to 1 if all of the C90 standard headers exist (not just the ones
|
||||
required in a freestanding environment). This macro is provided for
|
||||
backward compatibility; new code need not use it. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if strerror_r returns char *. */
|
||||
|
@ -1895,7 +1896,8 @@
|
|||
/* Define to 1 if time_t is signed. */
|
||||
#undef TIME_T_IS_SIGNED
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This
|
||||
macro is obsolete. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.64)
|
||||
AC_INIT(monitoring-plugins,2.3.5)
|
||||
AC_INIT(monitoring-plugins,2.4.0)
|
||||
AC_CONFIG_SRCDIR(NPTest.pm)
|
||||
AC_CONFIG_FILES([gl/Makefile])
|
||||
AC_CONFIG_AUX_DIR(build-aux)
|
||||
|
@ -1923,7 +1923,6 @@ AC_OUTPUT(
|
|||
plugins-scripts/utils.sh
|
||||
test.pl
|
||||
pkg/solaris/pkginfo
|
||||
po/Makefile.in
|
||||
)
|
||||
|
||||
|
||||
|
|
14
debian/NEWS
vendored
14
debian/NEWS
vendored
|
@ -1,7 +1,19 @@
|
|||
monitoring-plugins (2.4.0-3) unstable; urgency=medium
|
||||
|
||||
The check_http plugin was deprecated. Please migrate the check command
|
||||
definitions over to the drop-in replacement check_curl. It should be
|
||||
sufficient to replace check_http with check_curl in your command definitions.
|
||||
The check_curl plugin was moved to the monitoring-plugins-basic package for
|
||||
a smoother migration path. For making things easy, update-alternatives can
|
||||
be used to change the check_http alternative. This can be done with the
|
||||
command: update-alternatives --config check_http
|
||||
|
||||
-- Jan Wagner <waja@cyconet.org> Mon, 21 Apr 2025 11:00:59 +0200
|
||||
|
||||
monitoring-plugins (2.1.2-3) unstable; urgency=medium
|
||||
|
||||
We switched again over to another radius library. This time radcli
|
||||
to fix #822337. This makes it again necessary to migrate you radius
|
||||
to fix #822337. This makes it again necessary to migrate your radius
|
||||
credentials from /etc/radiusclient/servers to /etc/radcli/servers
|
||||
in case you are using check_radius.
|
||||
Please install the new dependencies in this case if you don't install
|
||||
|
|
65
debian/changelog
vendored
65
debian/changelog
vendored
|
@ -1,8 +1,69 @@
|
|||
monitoring-plugins (2.3.5-2) UNRELEASED; urgency=medium
|
||||
monitoring-plugins (2.4.0-4) UNRELEASED; urgency=medium
|
||||
|
||||
*
|
||||
|
||||
-- Jan Wagner <waja@cyconet.org> Sat, 21 Oct 2023 21:52:04 +0200
|
||||
-- Jan Wagner <waja@cyconet.org> Tue, 22 Apr 2025 16:31:05 +0200
|
||||
|
||||
monitoring-plugins (2.4.0-3) unstable; urgency=medium
|
||||
|
||||
* Upload to unstable
|
||||
|
||||
-- Jan Wagner <waja@cyconet.org> Tue, 22 Apr 2025 16:25:21 +0200
|
||||
|
||||
monitoring-plugins (2.4.0-3~exp1) experimental; urgency=medium
|
||||
|
||||
* [7e8c776] Adding d/p/24_check_http_deprecation from upstream
|
||||
* [baad659] Add d/monitoring-plugins-basic.alternatives
|
||||
* [6bb8580] Adjust debian/rules for check_http rename
|
||||
* [ddaa81f] check_curl: move to monitoring-plugins-basic package
|
||||
* [b724e41] d/NEWS: Add information about check_http deprecation
|
||||
|
||||
-- Jan Wagner <waja@cyconet.org> Mon, 21 Apr 2025 16:29:02 +0200
|
||||
|
||||
monitoring-plugins (2.4.0-2) unstable; urgency=medium
|
||||
|
||||
[ Bas Couwenberg ]
|
||||
* [2d414bd] Bump Standards-Version to 4.7.0, no changes.
|
||||
|
||||
[ Jan Wagner ]
|
||||
* [672d37c] Adding d/p/10_check_curl_fix_redirects from upstream
|
||||
* [15760ad] Adding d/p/11_check_curl_raise_ssl_issue from upstream
|
||||
* [a6b1db0] Adding d/p/12_check_curl_add_docu from upstream
|
||||
* [8b17915] Adding d/p/13_check_mysql_fix_variables from upstream
|
||||
* [01e11f9] Adding d/p/14_check_curl_remove_experimental_state from upstream
|
||||
* [1b018b3] Adding d/p/15_check_curl_fix_regex from upstream
|
||||
* [9c49b6f] Adding d/p/16_check_curl_openssl_error from upstream
|
||||
* [f3e1279] Adding d/p/17_check_fping_dontfrag_random from upstream
|
||||
|
||||
[ Bas Couwenberg ]
|
||||
* [3c5882d] Add check_curl to monitoring-plugins-standard description.
|
||||
|
||||
[ Jan Wagner ]
|
||||
* [043d328] Adding d/p/18_check_curl_fix_TLS_notes from upstream
|
||||
* [bf60013] Adding d/p/19_check_curl_cookie_handling from upstream
|
||||
|
||||
[ Bas Couwenberg ]
|
||||
* [9cb7fae] Bump Standards-Version to 4.7.2, no changes.
|
||||
* [af69fcf] Fix old FSF address in copyright file.
|
||||
|
||||
[ Jan Wagner ]
|
||||
* [38aec8e] Adding d/p/20_check_icmp_fix_rtmin from upstream
|
||||
* [e817fec] Adding d/p/21_check_http_state_regex from upstream
|
||||
* [45f91e2] Adding d/p/22_check_by_ssh_missing_options from upstream
|
||||
* [b6a58eb] Adding d/p/23_sslutils_fix_error_message from upstream
|
||||
* [3a5f250] debian/NEWS: Fix spelling error
|
||||
* [55f87b7] Changing check_httpname to the intended check_http_hostname
|
||||
definition (Closes: #1099028)
|
||||
* [2f5d025] Adding d/p/04_lmstat_path (Closes: #1053687)
|
||||
|
||||
-- Jan Wagner <waja@cyconet.org> Sun, 20 Apr 2025 21:09:27 +0200
|
||||
|
||||
monitoring-plugins (2.4.0-1) unstable; urgency=medium
|
||||
|
||||
* [600e193] New upstream version 2.4.0
|
||||
(Closes: #928752)
|
||||
|
||||
-- Jan Wagner <waja@cyconet.org> Tue, 23 Jul 2024 20:28:15 +0000
|
||||
|
||||
monitoring-plugins (2.3.5-1) unstable; urgency=medium
|
||||
|
||||
|
|
28
debian/control
vendored
28
debian/control
vendored
|
@ -2,7 +2,7 @@ Source: monitoring-plugins
|
|||
Section: net
|
||||
Priority: optional
|
||||
Maintainer: Debian Nagios Maintainer Group <pkg-nagios-devel@lists.alioth.debian.org>
|
||||
Uploaders: Jan Wagner <waja@cyconet.org>, Alexander Wirt <formorer@debian.org>
|
||||
Uploaders: Jan Wagner <waja@cyconet.org>
|
||||
Build-Depends: debhelper-compat (= 13),
|
||||
libcurl4-openssl-dev | libcurl4-nss-dev | libcurl4-gnutls-dev,
|
||||
libdbi-dev,
|
||||
|
@ -13,11 +13,13 @@ Build-Depends: debhelper-compat (= 13),
|
|||
libnet-snmp-perl,
|
||||
libpq-dev,
|
||||
libssl-dev,
|
||||
libsystemd0,
|
||||
libsystemd-dev,
|
||||
liburiparser-dev,
|
||||
mawk | awk,
|
||||
perl,
|
||||
procps
|
||||
Standards-Version: 4.6.2
|
||||
Standards-Version: 4.7.2
|
||||
Vcs-Browser: https://salsa.debian.org/nagios-team/monitoring-plugins
|
||||
Vcs-Git: https://salsa.debian.org/nagios-team/monitoring-plugins.git
|
||||
Homepage: https://www.monitoring-plugins.org
|
||||
|
@ -58,22 +60,24 @@ Depends: inetutils-ping [kfreebsd-any hurd-any],
|
|||
${shlibs:Depends}
|
||||
Recommends: libcap2-bin [linux-any]
|
||||
Suggests: icinga2
|
||||
Breaks: monitoring-plugins-standard (<< 2.4.0-3~)
|
||||
Replaces: monitoring-plugins-standard (<< 2.4.0-3~)
|
||||
Provides: nagios-plugins-basic
|
||||
Description: Plugins for nagios compatible monitoring systems (basic)
|
||||
Plugins for nagios compatible monitoring systems like Naemon and Icinga. It
|
||||
contains the following plugins:
|
||||
.
|
||||
check_apt, check_by_ssh, check_clamd, check_cluster,
|
||||
check_dhcp, check_disk, check_dummy, check_file_age,
|
||||
check_ftp, check_host, check_http, check_icmp,
|
||||
check_ide_smart, check_imap, check_ircd, check_jabber,
|
||||
check_load, check_log, check_mrtg, check_mrtgtraf,
|
||||
check_nagios, check_nntp, check_nntps, check_nt,
|
||||
check_ntp, check_ntp_peer, check_ntp_time, check_nwstat,
|
||||
check_overcr, check_ping, check_pop, check_procs,
|
||||
check_real, check_rta_multi, check_sensors, check_simap,
|
||||
check_smtp, check_spop, check_ssh, check_ssmtp,
|
||||
check_swap, check_tcp, check_time, check_udp,
|
||||
check_curl, check_dhcp, check_disk, check_dummy,
|
||||
check_file_age, check_ftp, check_host, check_http,
|
||||
check_icmp, check_ide_smart, check_imap, check_ircd,
|
||||
check_jabber, check_load, check_log, check_mrtg,
|
||||
check_mrtgtraf, check_nagios, check_nntp, check_nntps,
|
||||
check_nt, check_ntp, check_ntp_peer, check_ntp_time,
|
||||
check_nwstat, check_overcr, check_ping, check_pop,
|
||||
check_procs, check_real, check_rta_multi, check_sensors,
|
||||
check_simap, check_smtp, check_spop, check_ssh,
|
||||
check_ssmtp, check_swap, check_tcp, check_time, check_udp,
|
||||
check_ups, check_users
|
||||
.
|
||||
This package provides a basic set of plugins with minimal external
|
||||
|
|
9
debian/copyright
vendored
9
debian/copyright
vendored
|
@ -82,9 +82,7 @@ Files with different Licenses:
|
|||
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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA.
|
||||
along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
gl/alloca.in.h
|
||||
gl/as*
|
||||
|
@ -153,9 +151,8 @@ Files with different Licenses:
|
|||
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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA.
|
||||
License along with this program; if not, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
gl/reg*
|
||||
gl/mktime.c
|
||||
|
|
12
debian/monitoring-plugins-basic.alternatives
vendored
Normal file
12
debian/monitoring-plugins-basic.alternatives
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
Name: check_http
|
||||
Link: /usr/lib/nagios/plugins/check_http
|
||||
Status: auto
|
||||
Best: /usr/lib/nagios/plugins/check_http.deprecated
|
||||
Value: /usr/lib/nagios/plugins/check_http.deprecated
|
||||
Alternative: /usr/lib/nagios/plugins/check_http.deprecated
|
||||
Priority: 50
|
||||
|
||||
Name: check_http
|
||||
Link: /usr/lib/nagios/plugins/check_http
|
||||
Alternative: /usr/lib/nagios/plugins/check_curl
|
||||
Priority: -100
|
11
debian/patches/04_lmstat_path
vendored
Normal file
11
debian/patches/04_lmstat_path
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- a/plugins-scripts/utils.pm.in
|
||||
+++ b/plugins-scripts/utils.pm.in
|
||||
@@ -19,7 +19,7 @@
|
||||
## updated by autoconf
|
||||
$PATH_TO_SUDO = "@PATH_TO_SUDO@";
|
||||
$PATH_TO_RPCINFO = "@PATH_TO_RPCINFO@" ;
|
||||
-$PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ;
|
||||
+$PATH_TO_LMSTAT = "/usr/local/bin/lmstat" ;
|
||||
$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ;
|
||||
$PATH_TO_MAILQ = "@PATH_TO_MAILQ@";
|
||||
$PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@";
|
164
debian/patches/10_check_curl_fix_redirects
vendored
Normal file
164
debian/patches/10_check_curl_fix_redirects
vendored
Normal file
|
@ -0,0 +1,164 @@
|
|||
From 17549189ae6864203a48a2b2488db35a9e020e0e Mon Sep 17 00:00:00 2001
|
||||
From: Sven Nierlein <sven@consol.de>
|
||||
Date: Mon, 29 Jul 2024 20:53:32 +0200
|
||||
Subject: [PATCH] check_curl: fix relative redirects on non-standard port
|
||||
|
||||
Having a webserver respond with a relative redirect as for ex. in `Location: /path/to.html`
|
||||
check_curl would use the wrong standard http/https port instead
|
||||
of crafting the absolute url using the given scheme/hostname and port.
|
||||
|
||||
Adding a new test case for this for check_http and check_curl. check_http did
|
||||
it correct already, so no fix necessary there.
|
||||
|
||||
before:
|
||||
|
||||
%>./check_curl -H 127.0.0.1 -p 50493 -f follow -u /redirect_rel -s redirected -vvv
|
||||
**** HEADER ****
|
||||
HTTP/1.1 302 Found
|
||||
...
|
||||
Location: /redirect2
|
||||
|
||||
...
|
||||
* Seen redirect location /redirect2
|
||||
** scheme: (null)
|
||||
** host: (null)
|
||||
** port: (null)
|
||||
** path: /redirect2
|
||||
Redirection to http://127.0.0.1:80/redirect2
|
||||
|
||||
fixed:
|
||||
|
||||
%>./check_curl -H 127.0.0.1 -p 50493 -f follow -u /redirect_rel -s redirected -vvv
|
||||
**** HEADER ****
|
||||
HTTP/1.1 302 Found
|
||||
...
|
||||
Location: /redirect2
|
||||
|
||||
...
|
||||
* Seen redirect location /redirect2
|
||||
** scheme: (null)
|
||||
** host: (null)
|
||||
** port: (null)
|
||||
** path: /redirect2
|
||||
Redirection to http://127.0.0.1:50493/redirect2
|
||||
|
||||
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|
||||
---
|
||||
plugins/check_curl.c | 15 ++++++++++-----
|
||||
plugins/tests/check_curl.t | 14 +++++++++++---
|
||||
plugins/tests/check_http.t | 12 +++++++++++-
|
||||
3 files changed, 32 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
||||
index c54be5e4f..01e2770e3 100644
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -1285,10 +1285,12 @@ redir (curlhelp_write_curlbuf* header_buf)
|
||||
}
|
||||
}
|
||||
|
||||
- if (!uri_strcmp (uri.scheme, "https"))
|
||||
- use_ssl = true;
|
||||
- else
|
||||
- use_ssl = false;
|
||||
+ if (uri.scheme.first) {
|
||||
+ if (!uri_strcmp (uri.scheme, "https"))
|
||||
+ use_ssl = true;
|
||||
+ else
|
||||
+ use_ssl = false;
|
||||
+ }
|
||||
|
||||
/* we do a sloppy test here only, because uriparser would have failed
|
||||
* above, if the port would be invalid, we just check for MAX_PORT
|
||||
@@ -1306,10 +1308,13 @@ redir (curlhelp_write_curlbuf* header_buf)
|
||||
MAX_PORT, location, display_html ? "</A>" : "");
|
||||
|
||||
/* by RFC 7231 relative URLs in Location should be taken relative to
|
||||
- * the original URL, so wy try to form a new absolute URL here
|
||||
+ * the original URL, so we try to form a new absolute URL here
|
||||
*/
|
||||
if (!uri.scheme.first && !uri.hostText.first) {
|
||||
new_host = strdup (host_name ? host_name : server_address);
|
||||
+ new_port = server_port;
|
||||
+ if(use_ssl)
|
||||
+ uri_string (uri.scheme, "https", DEFAULT_BUFFER_SIZE);
|
||||
} else {
|
||||
new_host = strdup (uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE));
|
||||
}
|
||||
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
|
||||
index 3c9148308..eaa9f5183 100755
|
||||
--- a/plugins/tests/check_curl.t
|
||||
+++ b/plugins/tests/check_curl.t
|
||||
@@ -21,7 +21,7 @@ use FindBin qw($Bin);
|
||||
|
||||
$ENV{'LC_TIME'} = "C";
|
||||
|
||||
-my $common_tests = 73;
|
||||
+my $common_tests = 75;
|
||||
my $ssl_only_tests = 8;
|
||||
# Check that all dependent modules are available
|
||||
eval "use HTTP::Daemon 6.01;";
|
||||
@@ -178,6 +178,11 @@ sub run_server {
|
||||
$c->send_basic_header;
|
||||
$c->send_crlf;
|
||||
$c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
|
||||
+ } elsif ($r->url->path eq "/redirect_rel") {
|
||||
+ $c->send_basic_header(302);
|
||||
+ $c->send_header("Location", "/redirect2" );
|
||||
+ $c->send_crlf;
|
||||
+ $c->send_response('moved to /redirect2');
|
||||
} elsif ($r->url->path eq "/redir_timeout") {
|
||||
$c->send_redirect( "/timeout" );
|
||||
} elsif ($r->url->path eq "/timeout") {
|
||||
@@ -471,9 +476,12 @@ sub run_common_tests {
|
||||
is( $result->return_code, 0, $cmd);
|
||||
like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
|
||||
|
||||
- # These tests may block
|
||||
- print "ALRM\n";
|
||||
+ $cmd = "$command -f follow -u /redirect_rel -s redirected";
|
||||
+ $result = NPTest->testCmd( $cmd );
|
||||
+ is( $result->return_code, 0, $cmd);
|
||||
+ like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
|
||||
|
||||
+ # These tests may block
|
||||
# stickyport - on full urlS port is set back to 80 otherwise
|
||||
$cmd = "$command -f stickyport -u /redir_external -t 5 -s redirected";
|
||||
eval {
|
||||
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
|
||||
index 6078b2745..6eaf85b29 100755
|
||||
--- a/plugins/tests/check_http.t
|
||||
+++ b/plugins/tests/check_http.t
|
||||
@@ -13,7 +13,7 @@ use IO::Socket::INET;
|
||||
|
||||
$ENV{'LC_TIME'} = "C";
|
||||
|
||||
-my $common_tests = 71;
|
||||
+my $common_tests = 73;
|
||||
my $virtual_port_tests = 8;
|
||||
my $ssl_only_tests = 12;
|
||||
my $chunked_encoding_special_tests = 1;
|
||||
@@ -199,6 +199,11 @@ sub run_server {
|
||||
$c->send_basic_header;
|
||||
$c->send_crlf;
|
||||
$c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
|
||||
+ } elsif ($r->url->path eq "/redirect_rel") {
|
||||
+ $c->send_basic_header(302);
|
||||
+ $c->send_header("Location", "/redirect2" );
|
||||
+ $c->send_crlf;
|
||||
+ $c->send_response('moved to /redirect2');
|
||||
} elsif ($r->url->path eq "/redir_timeout") {
|
||||
$c->send_redirect( "/timeout" );
|
||||
} elsif ($r->url->path eq "/timeout") {
|
||||
@@ -515,6 +520,11 @@ sub run_common_tests {
|
||||
is( $result->return_code, 0, $cmd);
|
||||
like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
|
||||
|
||||
+ $cmd = "$command -f follow -u /redirect_rel -s redirected";
|
||||
+ $result = NPTest->testCmd( $cmd );
|
||||
+ is( $result->return_code, 0, $cmd);
|
||||
+ like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
|
||||
+
|
||||
# These tests may block
|
||||
print "ALRM\n";
|
||||
|
87
debian/patches/11_check_curl_raise_ssl_issue
vendored
Normal file
87
debian/patches/11_check_curl_raise_ssl_issue
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
From ca40cf81fb94cf57a82df938ed2aa2843691be3a Mon Sep 17 00:00:00 2001
|
||||
From: Yannick Martin <yannick.martin@ovhcloud.com>
|
||||
Date: Fri, 9 Aug 2024 12:14:28 +0200
|
||||
Subject: [PATCH] check_curl: raise SSL issue when --continue-after-certificate
|
||||
is used
|
||||
|
||||
This change aims to raise the worst status between the SSL check and the HTTP check.
|
||||
|
||||
before:
|
||||
check_curl -H www.google.fr -S --continue-after-certificate --certificate 4000,4000 ; echo $?
|
||||
CRITICAL - Certificate '*.google.fr' expires in 74 day(s) (Tue 22 Oct 2024 12:53:52 PM GMT +0000).
|
||||
HTTP OK: HTTP/2 200 - 22807 bytes in 0.076 second response time |time=0.075516s;;;0.000000;10.000000 size=22807B;;;0;
|
||||
0
|
||||
|
||||
after:
|
||||
/usr/lib/nagios/ovh/check_curl -H www.google.fr -S --continue-after-certificate --certificate 4000,4000 ; echo $?
|
||||
CRITICAL - Certificate '*.google.fr' expires in 74 day(s) (Tue 22 Oct 2024 12:53:52 PM GMT +0000).
|
||||
HTTP OK: HTTP/2 200 - 22840 bytes in 0.090 second response time |time=0.090463s;;;0.000000;10.000000 size=22840B;;;0;
|
||||
2
|
||||
---
|
||||
plugins/check_curl.c | 17 +++++++++--------
|
||||
1 file changed, 9 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
||||
index 01e2770e3..4522e6c9f 100644
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -468,6 +468,7 @@ int
|
||||
check_http (void)
|
||||
{
|
||||
int result = STATE_OK;
|
||||
+ int result_ssl = STATE_OK;
|
||||
int page_len = 0;
|
||||
int i;
|
||||
char *force_host_header = NULL;
|
||||
@@ -852,9 +853,9 @@ check_http (void)
|
||||
/* check certificate with OpenSSL functions, curl has been built against OpenSSL
|
||||
* and we actually have OpenSSL in the monitoring tools
|
||||
*/
|
||||
- result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
|
||||
+ result_ssl = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
|
||||
if (!continue_after_check_cert) {
|
||||
- return result;
|
||||
+ return result_ssl;
|
||||
}
|
||||
#else /* USE_OPENSSL */
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates - OpenSSL callback used and not linked against OpenSSL\n");
|
||||
@@ -898,17 +899,17 @@ check_http (void)
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
}
|
||||
BIO_free (cert_BIO);
|
||||
- result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
|
||||
+ result_ssl = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
|
||||
if (!continue_after_check_cert) {
|
||||
- return result;
|
||||
+ return result_ssl;
|
||||
}
|
||||
#else /* USE_OPENSSL */
|
||||
/* We assume we don't have OpenSSL and np_net_ssl_check_certificate at our disposal,
|
||||
* so we use the libcurl CURLINFO data
|
||||
*/
|
||||
- result = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit);
|
||||
+ result_ssl = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit);
|
||||
if (!continue_after_check_cert) {
|
||||
- return result;
|
||||
+ return result_ssl;
|
||||
}
|
||||
#endif /* USE_OPENSSL */
|
||||
} else {
|
||||
@@ -1176,7 +1177,7 @@ check_http (void)
|
||||
}
|
||||
|
||||
/* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
|
||||
- die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
|
||||
+ die (max_state_alt(result, result_ssl), "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
|
||||
state_text(result), string_statuscode (status_line.http_major, status_line.http_minor),
|
||||
status_line.http_code, status_line.msg,
|
||||
strlen(msg) > 0 ? " - " : "",
|
||||
@@ -1186,7 +1187,7 @@ check_http (void)
|
||||
(show_body ? body_buf.buf : ""),
|
||||
(show_body ? "\n" : "") );
|
||||
|
||||
- return result;
|
||||
+ return max_state_alt(result, result_ssl);
|
||||
}
|
||||
|
||||
int
|
42
debian/patches/12_check_curl_add_docu
vendored
Normal file
42
debian/patches/12_check_curl_add_docu
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
From 9cdf2aec7fa3277237c078fc9da32f40d0292299 Mon Sep 17 00:00:00 2001
|
||||
From: Alvar Penning <alvar.penning@icinga.com>
|
||||
Date: Fri, 16 Aug 2024 10:38:02 +0200
|
||||
Subject: [PATCH] check_curl: Documentation for --certificate, --cookie-jar
|
||||
|
||||
From the mere help output for -C / --certificate, I was confused about
|
||||
what its two integer parameters do. Unfortunately, I also missed out on
|
||||
the explaining examples later. Since I like to have basic documentation
|
||||
for each flag, I tried to make the arguments as short as possible.
|
||||
|
||||
The other fix was one hyphen too many for the --cookie-jar option.
|
||||
---
|
||||
plugins/check_curl.c | 9 ++++++---
|
||||
1 file changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
||||
index 4522e6c9f..e9c15e648 100644
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -2008,8 +2008,11 @@ print_help (void)
|
||||
printf (" %s\n", _("Note: SNI is not supported in libcurl before 7.18.1"));
|
||||
#endif
|
||||
printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
|
||||
- printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
|
||||
- printf (" %s\n", _("(when this option is used the URL is not checked by default. You can use"));
|
||||
+ printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443."));
|
||||
+ printf (" %s\n", _("A STATE_WARNING is returned if the certificate has a validity less than the"));
|
||||
+ printf (" %s\n", _("first agument's value. If there is a second argument and the certificate's"));
|
||||
+ printf (" %s\n", _("validity is less than its value, a STATE_CRITICAL is returned."));
|
||||
+ printf (" %s\n", _("(When this option is used the URL is not checked by default. You can use"));
|
||||
printf (" %s\n", _(" --continue-after-certificate to override this behavior)"));
|
||||
printf (" %s\n", "--continue-after-certificate");
|
||||
printf (" %s\n", _("Allows the HTTP check to continue after performing the certificate check."));
|
||||
@@ -2092,7 +2095,7 @@ print_help (void)
|
||||
printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING)."));
|
||||
printf(" %s\n", "--haproxy-protocol");
|
||||
printf(" %s\n", _("Send HAProxy proxy protocol v1 header (CURLOPT_HAPROXYPROTOCOL)."));
|
||||
- printf (" %s\n", "---cookie-jar=FILE");
|
||||
+ printf (" %s\n", "--cookie-jar=FILE");
|
||||
printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested."));
|
||||
printf ("\n");
|
||||
|
28
debian/patches/13_check_mysql_fix_variables
vendored
Normal file
28
debian/patches/13_check_mysql_fix_variables
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
|
||||
index 6a7daf11a..15ec04c04 100644
|
||||
--- a/plugins/check_mysql.c
|
||||
+++ b/plugins/check_mysql.c
|
||||
@@ -59,8 +59,8 @@ bool ssl = false;
|
||||
char *opt_file = NULL;
|
||||
char *opt_group = NULL;
|
||||
unsigned int db_port = MYSQL_PORT;
|
||||
-int check_slave = 0, warn_sec = 0, crit_sec = 0;
|
||||
-int ignore_auth = 0;
|
||||
+bool check_slave = false;
|
||||
+bool ignore_auth = false;
|
||||
int verbose = 0;
|
||||
|
||||
static double warning_time = 0;
|
||||
@@ -456,10 +456,10 @@ process_arguments (int argc, char **argv)
|
||||
db_port = atoi (optarg);
|
||||
break;
|
||||
case 'S':
|
||||
- check_slave = 1; /* check-slave */
|
||||
+ check_slave = true; /* check-slave */
|
||||
break;
|
||||
case 'n':
|
||||
- ignore_auth = 1; /* ignore-auth */
|
||||
+ ignore_auth = true; /* ignore-auth */
|
||||
break;
|
||||
case 'w':
|
||||
warning = optarg;
|
13
debian/patches/14_check_curl_remove_experimental_state
vendored
Normal file
13
debian/patches/14_check_curl_remove_experimental_state
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
||||
index e9c15e648..e25d7a79a 100644
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -2190,8 +2190,6 @@ print_usage (void)
|
||||
printf ("%s\n", _("In the first form, make an HTTP request."));
|
||||
printf ("%s\n\n", _("In the second form, connect to the server and check the TLS certificate."));
|
||||
#endif
|
||||
- printf ("%s\n", _("WARNING: check_curl is experimental. Please use"));
|
||||
- printf ("%s\n\n", _("check_http if you need a stable version."));
|
||||
}
|
||||
|
||||
void
|
82
debian/patches/15_check_curl_fix_regex
vendored
Normal file
82
debian/patches/15_check_curl_fix_regex
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
From 46efe803cf8e7b769ca112afc158b76510b01e46 Mon Sep 17 00:00:00 2001
|
||||
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
|
||||
Date: Mon, 19 Aug 2024 15:23:41 +0200
|
||||
Subject: [PATCH 1/3] check_curl: Fix help for state regex option
|
||||
|
||||
The help output of `check-curl` contained a typo,
|
||||
the real option is `state-regex` and not `regex-state` as
|
||||
the help suggests.
|
||||
Also added the two possible options to avoid confusion.
|
||||
---
|
||||
plugins/check_curl.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
||||
index e9c15e648..bf46b2261 100644
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -2061,8 +2061,8 @@ print_help (void)
|
||||
printf (" %s\n", "--invert-regex");
|
||||
printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)"));
|
||||
printf (" %s\n", _("can be changed with --state--regex)"));
|
||||
- printf (" %s\n", "--regex-state=STATE");
|
||||
- printf (" %s\n", _("Return STATE if regex is found, OK if not\n"));
|
||||
+ printf (" %s\n", "--state-regex=STATE");
|
||||
+ printf (" %s\n", _("Return STATE if regex is found, OK if not\nSTATE can be one of \"critical\",\"warning\""));
|
||||
printf (" %s\n", "-a, --authorization=AUTH_PAIR");
|
||||
printf (" %s\n", _("Username:password on sites with basic authentication"));
|
||||
printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR");
|
||||
|
||||
From b6c72064a53da8b173b7406a0a535922dc0cc1b3 Mon Sep 17 00:00:00 2001
|
||||
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
|
||||
Date: Mon, 19 Aug 2024 15:26:52 +0200
|
||||
Subject: [PATCH 2/3] check_curl: Parse state-regex option ignoring case
|
||||
|
||||
Previously the --state-regex option accepted only "critical" and
|
||||
"warning" as values.
|
||||
This commit changes the strcmp there to strcasecmp to be more tolerant
|
||||
regarding the input.
|
||||
---
|
||||
plugins/check_curl.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
||||
index bf46b2261..38c971093 100644
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -1775,9 +1775,9 @@ process_arguments (int argc, char **argv)
|
||||
invert_regex = true;
|
||||
break;
|
||||
case STATE_REGEX:
|
||||
- if (!strcmp (optarg, "critical"))
|
||||
+ if (!strcasecmp (optarg, "critical"))
|
||||
state_regex = STATE_CRITICAL;
|
||||
- else if (!strcmp (optarg, "warning"))
|
||||
+ else if (!strcasecmp (optarg, "warning"))
|
||||
state_regex = STATE_WARNING;
|
||||
else usage2 (_("Invalid state-regex option"), optarg);
|
||||
break;
|
||||
|
||||
From af097aa3642174a2111f0bbcbc8236fff0901e17 Mon Sep 17 00:00:00 2001
|
||||
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
|
||||
Date: Mon, 19 Aug 2024 15:33:17 +0200
|
||||
Subject: [PATCH 3/3] check_curl: change help for --state-regex again to fix
|
||||
formatting
|
||||
|
||||
---
|
||||
plugins/check_curl.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
||||
index 38c971093..214ba74f9 100644
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -2062,7 +2062,7 @@ print_help (void)
|
||||
printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)"));
|
||||
printf (" %s\n", _("can be changed with --state--regex)"));
|
||||
printf (" %s\n", "--state-regex=STATE");
|
||||
- printf (" %s\n", _("Return STATE if regex is found, OK if not\nSTATE can be one of \"critical\",\"warning\""));
|
||||
+ printf (" %s\n", _("Return STATE if regex is found, OK if not. STATE can be one of \"critical\",\"warning\""));
|
||||
printf (" %s\n", "-a, --authorization=AUTH_PAIR");
|
||||
printf (" %s\n", _("Username:password on sites with basic authentication"));
|
||||
printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR");
|
115
debian/patches/16_check_curl_openssl_error
vendored
Normal file
115
debian/patches/16_check_curl_openssl_error
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
From 528e92c180148703ee2cb90d7291f4edbfc270d4 Mon Sep 17 00:00:00 2001
|
||||
From: Sven Nierlein <sven@consol.de>
|
||||
Date: Wed, 9 Oct 2024 09:50:39 +0200
|
||||
Subject: [PATCH] fix check_curl: OpenSSL SSL_read: error:0A000126:SSL
|
||||
routines::unexpected eof while reading, errno 0
|
||||
|
||||
using check_curl on a probably embedded device responding as 'Server: GoAhead-Webs'
|
||||
|
||||
%> check_curl -H ... -S -vvv
|
||||
|
||||
> GET / HTTP/1.1
|
||||
Host: ...
|
||||
User-Agent: check_curl/v2.4.0 (monitoring-plugins 2.4.0, libcurl/7.76.1 OpenSSL/3.0.7 zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh/0.10.4/openssl/zlib nghttp2/1.43.0)
|
||||
Accept: */*
|
||||
Connection: close
|
||||
|
||||
* Mark bundle as not supporting multiuse
|
||||
* HTTP 1.0, assume close after body
|
||||
< HTTP/1.0 302 Redirect
|
||||
< Server: GoAhead-Webs
|
||||
< Date: Tue Mar 26 17:57:16 2019
|
||||
< Cache-Control: no-cache, no-store, must-revalidate,private
|
||||
< Pragma: no-cache
|
||||
< Expires: 0
|
||||
< Content-Type: text/html
|
||||
< X-Frame-Options: sameorigin
|
||||
< X-XSS-Protection: 1; mode=block
|
||||
< X-Content-Type-Options: nosniff
|
||||
< Location: https://...
|
||||
<
|
||||
* OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
|
||||
* Closing connection 0
|
||||
|
||||
reading the discussion on https://github.com/openssl/openssl/discussions/22690 suggest to set the option SSL_OP_IGNORE_UNEXPECTED_EOF
|
||||
which makes check_curl behave like check_http at this point.
|
||||
Since this is a rather new flag, fencing it in ifdefs.
|
||||
And since there can only be one ssl ctx function, we need to move both tasks into one function.
|
||||
---
|
||||
plugins/check_curl.c | 29 ++++++++++++++++++++++-------
|
||||
1 file changed, 22 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
||||
index 7f45b5a79..d3bddacd2 100644
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -214,6 +214,7 @@ char *client_privkey = NULL;
|
||||
char *ca_cert = NULL;
|
||||
bool verify_peer_and_host = false;
|
||||
bool is_openssl_callback = false;
|
||||
+bool add_sslctx_verify_fun = false;
|
||||
#if defined(HAVE_SSL) && defined(USE_OPENSSL)
|
||||
X509 *cert = NULL;
|
||||
#endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */
|
||||
@@ -299,7 +300,7 @@ main (int argc, char **argv)
|
||||
|
||||
int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
|
||||
{
|
||||
- (void) preverify_ok;
|
||||
+ (void) preverify_ok;
|
||||
/* TODO: we get all certificates of the chain, so which ones
|
||||
* should we test?
|
||||
* TODO: is the last certificate always the server certificate?
|
||||
@@ -324,9 +325,18 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
|
||||
|
||||
CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm)
|
||||
{
|
||||
- (void) curl; // ignore unused parameter
|
||||
- (void) parm; // ignore unused parameter
|
||||
- SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback);
|
||||
+ (void) curl; // ignore unused parameter
|
||||
+ (void) parm; // ignore unused parameter
|
||||
+ if(add_sslctx_verify_fun) {
|
||||
+ SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback);
|
||||
+ }
|
||||
+
|
||||
+ // workaround for issue:
|
||||
+ // OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
|
||||
+ // see discussion https://github.com/openssl/openssl/discussions/22690
|
||||
+#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF
|
||||
+ SSL_CTX_set_options(sslctx, SSL_OP_IGNORE_UNEXPECTED_EOF);
|
||||
+#endif
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
@@ -678,9 +688,8 @@ check_http (void)
|
||||
* OpenSSL-style libraries only!) */
|
||||
#ifdef USE_OPENSSL
|
||||
/* libcurl and monitoring plugins built with OpenSSL, good */
|
||||
- handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
|
||||
+ add_sslctx_verify_fun = true;
|
||||
is_openssl_callback = true;
|
||||
-#else /* USE_OPENSSL */
|
||||
#endif /* USE_OPENSSL */
|
||||
/* libcurl is built with OpenSSL, monitoring plugins, so falling
|
||||
* back to manually extracting certificate information */
|
||||
@@ -713,12 +722,18 @@ check_http (void)
|
||||
#else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */
|
||||
/* old libcurl, our only hope is OpenSSL, otherwise we are out of luck */
|
||||
if (ssl_library == CURLHELP_SSL_LIBRARY_OPENSSL || ssl_library == CURLHELP_SSL_LIBRARY_LIBRESSL)
|
||||
- handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
|
||||
+ add_sslctx_verify_fun = true;
|
||||
else
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (no CURLOPT_SSL_CTX_FUNCTION, no OpenSSL library or libcurl too old and has no CURLOPT_CERTINFO)\n");
|
||||
#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */
|
||||
}
|
||||
|
||||
+#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 10, 6) /* required for CURLOPT_SSL_CTX_FUNCTION */
|
||||
+ // ssl ctx function is not available with all ssl backends
|
||||
+ if (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, NULL) != CURLE_UNKNOWN_OPTION)
|
||||
+ handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
|
||||
+#endif
|
||||
+
|
||||
#endif /* LIBCURL_FEATURE_SSL */
|
||||
|
||||
/* set default or user-given user agent identification */
|
83
debian/patches/17_check_fping_dontfrag_random
vendored
Normal file
83
debian/patches/17_check_fping_dontfrag_random
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
From 88d991773b6d8ac416ad2931ea8debc949555c7a Mon Sep 17 00:00:00 2001
|
||||
From: William <william@blackhats.net.au>
|
||||
Date: Wed, 6 Nov 2024 14:00:23 +1000
|
||||
Subject: [PATCH] Add dontfrag/random for fping
|
||||
|
||||
Support the dont fragment and randomise packet data options for check_fping
|
||||
---
|
||||
plugins/check_fping.c | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
--- a/plugins/check_fping.c
|
||||
+++ b/plugins/check_fping.c
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
-* This file contains the check_disk plugin
|
||||
+* This file contains the check_fping plugin
|
||||
*
|
||||
* This plugin will use the fping command to ping the specified host for a
|
||||
* fast check
|
||||
@@ -60,6 +60,8 @@
|
||||
int target_timeout = 0;
|
||||
int packet_interval = 0;
|
||||
bool verbose = false;
|
||||
+bool dontfrag = false;
|
||||
+bool randomize_packet_data = false;
|
||||
int cpl;
|
||||
int wpl;
|
||||
double crta;
|
||||
@@ -105,6 +107,10 @@
|
||||
xasprintf(&option_string, "%s-S %s ", option_string, sourceip);
|
||||
if (sourceif)
|
||||
xasprintf(&option_string, "%s-I %s ", option_string, sourceif);
|
||||
+ if (dontfrag)
|
||||
+ xasprintf(&option_string, "%s-M ", option_string);
|
||||
+ if (randomize_packet_data)
|
||||
+ xasprintf(&option_string, "%s-R ", option_string);
|
||||
|
||||
#ifdef PATH_TO_FPING6
|
||||
if (address_family != AF_INET && is_inet6_addr(server))
|
||||
@@ -303,6 +309,8 @@
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"use-ipv4", no_argument, 0, '4'},
|
||||
{"use-ipv6", no_argument, 0, '6'},
|
||||
+ {"dontfrag", no_argument, 0, 'M'},
|
||||
+ {"random", no_argument, 0, 'R'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -320,7 +328,7 @@
|
||||
}
|
||||
|
||||
while (1) {
|
||||
- c = getopt_long (argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:46", longopts, &option);
|
||||
+ c = getopt_long (argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:M:R:46", longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF || c == 1)
|
||||
break;
|
||||
@@ -415,6 +423,12 @@
|
||||
else
|
||||
usage (_("Interval must be a positive integer"));
|
||||
break;
|
||||
+ case 'R':
|
||||
+ randomize_packet_data = true;
|
||||
+ break;
|
||||
+ case 'M':
|
||||
+ dontfrag = true;
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,6 +520,10 @@
|
||||
printf (" %s\n", _("name or IP Address of sourceip"));
|
||||
printf (" %s\n", "-I, --sourceif=IF");
|
||||
printf (" %s\n", _("source interface name"));
|
||||
+ printf(" %s\n", "-M, --dontfrag");
|
||||
+ printf(" %s\n", _("set the Don't Fragment flag"));
|
||||
+ printf(" %s\n", "-R, --random");
|
||||
+ printf(" %s\n", _("random packet data (to foil link data compression)"));
|
||||
printf (UT_VERBOSE);
|
||||
printf ("\n");
|
||||
printf (" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)"));
|
21
debian/patches/18_check_curl_fix_TLS_notes
vendored
Normal file
21
debian/patches/18_check_curl_fix_TLS_notes
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
From 8de299308c52d083b893a87e6924405b652f1f7b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
|
||||
<12514511+RincewindsHat@users.noreply.github.com>
|
||||
Date: Wed, 27 Nov 2024 14:22:02 +0100
|
||||
Subject: [PATCH] check_curl: update TLS notification notes
|
||||
|
||||
---
|
||||
plugins/check_curl.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -2013,7 +2013,7 @@
|
||||
printf (" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"));
|
||||
printf (" %s\n", _("auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"));
|
||||
printf (" %s\n", _("1.2 = TLSv1.2, 1.3 = TLSv1.3). With a '+' suffix, newer versions are also accepted."));
|
||||
- printf (" %s\n", _("Note: SSLv2 and SSLv3 are deprecated and are usually disabled in libcurl"));
|
||||
+ printf (" %s\n", _("Note: SSLv2, SSLv3, TLSv1.0 and TLSv1.1 are deprecated and are usually disabled in libcurl"));
|
||||
printf (" %s\n", "--sni");
|
||||
printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
|
||||
#if LIBCURL_VERSION_NUM >= 0x071801
|
46
debian/patches/19_check_curl_cookie_handling
vendored
Normal file
46
debian/patches/19_check_curl_cookie_handling
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
From 191d15354ba32a483fd4f8017595c7eb82ee5650 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= <kandre@ak-online.be>
|
||||
Date: Fri, 29 Nov 2024 10:34:16 +0100
|
||||
Subject: [PATCH] check_curl: enable internal cookie handling
|
||||
|
||||
This enables us to enable curl cookie engine by specifying an empty
|
||||
filename as the cookie jar file.
|
||||
|
||||
This works, since curl's CURLOPT_COOKIEFILE option allows passing an
|
||||
empty string as filename, which it interprets as a request to enable the
|
||||
cookie processing. But since CURLOPT_COOKIEJAR would now attempt to
|
||||
write to a file named by an empty filename, it would break again (or at
|
||||
least produce a warning in verbose output).
|
||||
|
||||
Overall this is allows to handle checking URLs with cookie based
|
||||
sessions without persisting the cookies to disk, by using the
|
||||
curl-internal redirect following.
|
||||
---
|
||||
plugins/check_curl.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/plugins/check_curl.c
|
||||
+++ b/plugins/check_curl.c
|
||||
@@ -831,8 +831,11 @@
|
||||
|
||||
/* cookie handling */
|
||||
if (cookie_jar_file != NULL) {
|
||||
- handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEJAR, cookie_jar_file), "CURLOPT_COOKIEJAR");
|
||||
+ /* enable reading cookies from a file, and if the filename is an empty string, only enable the curl cookie engine */
|
||||
handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEFILE, cookie_jar_file), "CURLOPT_COOKIEFILE");
|
||||
+ /* now enable saving cookies to a file, but only if the filename is not an empty string, since writing it would fail */
|
||||
+ if (*cookie_jar_file)
|
||||
+ handle_curl_option_return_code(curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookie_jar_file), "CURLOPT_COOKIEJAR");
|
||||
}
|
||||
|
||||
/* do the request */
|
||||
@@ -2111,6 +2114,9 @@
|
||||
printf(" %s\n", "--haproxy-protocol");
|
||||
printf(" %s\n", _("Send HAProxy proxy protocol v1 header (CURLOPT_HAPROXYPROTOCOL)."));
|
||||
printf (" %s\n", "--cookie-jar=FILE");
|
||||
+ printf (" %s\n", _("Specify an empty string as FILE to enable curl's cookie engine without saving"));
|
||||
+ printf (" %s\n", _("the cookies to disk. Only enabling the engine without saving to disk requires"));
|
||||
+ printf (" %s\n", _("handling multiple requests internally to curl, so use it with --onredirect=curl"));
|
||||
printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested."));
|
||||
printf ("\n");
|
||||
|
29
debian/patches/20_check_icmp_fix_rtmin
vendored
Normal file
29
debian/patches/20_check_icmp_fix_rtmin
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
From e5f35d40556468fcdebccae847cfc19380952ca0 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
|
||||
<12514511+RincewindsHat@users.noreply.github.com>
|
||||
Date: Wed, 27 Nov 2024 15:29:19 +0100
|
||||
Subject: [PATCH] check_icmp: set rtmin initially
|
||||
|
||||
---
|
||||
plugins-root/check_icmp.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/plugins-root/check_icmp.c
|
||||
+++ b/plugins-root/check_icmp.c
|
||||
@@ -64,6 +64,7 @@
|
||||
#include <netinet/ip_icmp.h>
|
||||
#include <netinet/icmp6.h>
|
||||
#include <arpa/inet.h>
|
||||
+#include <math.h>
|
||||
|
||||
|
||||
/** sometimes undefined system macros (quite a few, actually) **/
|
||||
@@ -1051,7 +1052,7 @@
|
||||
icmp_recv++;
|
||||
if (tdiff > (unsigned int)host->rtmax)
|
||||
host->rtmax = tdiff;
|
||||
- if (tdiff < (unsigned int)host->rtmin)
|
||||
+ if ((host->rtmin == INFINITY) || (tdiff < (unsigned int)host->rtmin))
|
||||
host->rtmin = tdiff;
|
||||
|
||||
if(debug) {
|
22
debian/patches/21_check_http_state_regex
vendored
Normal file
22
debian/patches/21_check_http_state_regex
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
From e445a386f8ad1166b05fcdfdb5b9cde4622a8632 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Baumann <mail@andreasbaumann.cc>
|
||||
Date: Fri, 27 Dec 2024 15:32:24 +0100
|
||||
Subject: [PATCH] check_http: fix documentation for --state-regex
|
||||
|
||||
---
|
||||
plugins/check_http.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/plugins/check_http.c b/plugins/check_http.c
|
||||
index 97c0e39ad..baff682a7 100644
|
||||
--- a/plugins/check_http.c
|
||||
+++ b/plugins/check_http.c
|
||||
@@ -1805,7 +1805,7 @@ print_help (void)
|
||||
printf (" %s\n", "--invert-regex");
|
||||
printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)"));
|
||||
printf (" %s\n", _("can be changed with --state--regex)"));
|
||||
- printf (" %s\n", "--regex-state=STATE");
|
||||
+ printf (" %s\n", "--state-regex=STATE");
|
||||
printf (" %s\n", _("Return STATE if regex is found, OK if not\n"));
|
||||
|
||||
printf (" %s\n", "-a, --authorization=AUTH_PAIR");
|
20
debian/patches/22_check_by_ssh_missing_options
vendored
Normal file
20
debian/patches/22_check_by_ssh_missing_options
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
From 02adcbfa896eb726c59ca647eb4cf6909c690f37 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
|
||||
<12514511+RincewindsHat@users.noreply.github.com>
|
||||
Date: Mon, 24 Feb 2025 20:32:19 +0100
|
||||
Subject: [PATCH] check_by_ssh: Remove warning/critical from help
|
||||
|
||||
---
|
||||
plugins/check_by_ssh.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
--- a/plugins/check_by_ssh.c
|
||||
+++ b/plugins/check_by_ssh.c
|
||||
@@ -454,7 +454,6 @@
|
||||
printf (" %s\n", _("Tell ssh to use this configfile [optional]"));
|
||||
printf (" %s\n","-q, --quiet");
|
||||
printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
|
||||
- printf (UT_WARN_CRIT);
|
||||
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
||||
printf (" %s\n","-U, --unknown-timeout");
|
||||
printf (" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL"));
|
23
debian/patches/23_sslutils_fix_error_message
vendored
Normal file
23
debian/patches/23_sslutils_fix_error_message
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
From ef3045b97eea23a4dec3197277e5ff4e5afc5c71 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= <kandre@ak-online.be>
|
||||
Date: Mon, 17 Mar 2025 16:13:46 +0100
|
||||
Subject: [PATCH] change error message for missing certificate
|
||||
|
||||
The old error message is quite similar to the openssl `failed to retrieve issuer certificate` and can mislead users to troubleshooting certificate stores.
|
||||
|
||||
The new message should be distinct enough to make it clear to users that this is not a problem raised by the underlying SSL implementation, but a problem inside monitoring-plugins.
|
||||
---
|
||||
plugins/sslutils.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/plugins/sslutils.c
|
||||
+++ b/plugins/sslutils.c
|
||||
@@ -208,7 +208,7 @@
|
||||
time_t tm_t;
|
||||
|
||||
if (!certificate) {
|
||||
- printf("%s\n",_("CRITICAL - Cannot retrieve server certificate."));
|
||||
+ printf("%s\n",_("CRITICAL - No server certificate present to inspect."));
|
||||
return STATE_CRITICAL;
|
||||
}
|
||||
|
30
debian/patches/24_check_http_deprecation
vendored
Normal file
30
debian/patches/24_check_http_deprecation
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
From 14169fe5a11b94a9f9ab44336fdb5170ee98be66 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Wagner <waja@cyconet.org>
|
||||
Date: Sat, 19 Apr 2025 14:37:46 +0200
|
||||
Subject: [PATCH] check_http: Adding deprecation text
|
||||
|
||||
---
|
||||
plugins/check_http.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/plugins/check_http.c b/plugins/check_http.c
|
||||
index baff682a7..8e0c15ec9 100644
|
||||
--- a/plugins/check_http.c
|
||||
+++ b/plugins/check_http.c
|
||||
@@ -1724,6 +1724,16 @@ print_help (void)
|
||||
printf ("%s\n", _("strings and regular expressions, check connection times, and report on"));
|
||||
printf ("%s\n", _("certificate expiration times."));
|
||||
|
||||
+ printf ("\n");
|
||||
+ printf ("%s\n", _("ATTENTION!"));
|
||||
+ printf ("\n");
|
||||
+ printf ("%s\n", _("THIS PLUGIN IS DEPRECATED. The functionality was reimplemented by the"));
|
||||
+ printf ("%s\n", _("check_curl plugin, which can be used as a drop-in replacement. You should"));
|
||||
+ printf ("%s\n", _("migrate your checks over to check_curl, because check_http is going to be"));
|
||||
+ printf ("%s\n", _("removed sooner than later. Just replace check_http with check_curl in your"));
|
||||
+ printf ("%s\n", _("check command definitions."));
|
||||
+ printf ("%s\n", _("Report issues to: https://github.com/monitoring-plugins/monitoring-plugins/issues"));
|
||||
+
|
||||
printf ("\n\n");
|
||||
|
||||
print_usage ();
|
28
debian/patches/25_check_users_sd_get_uids
vendored
Normal file
28
debian/patches/25_check_users_sd_get_uids
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
From fb39f96ac6f72bb56d17f3e8694134dfea9186e9 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
|
||||
<12514511+RincewindsHat@users.noreply.github.com>
|
||||
Date: Mon, 11 Aug 2025 21:49:20 +0200
|
||||
Subject: [PATCH] check_users: Use sd_get_uids instead of sd_get_session
|
||||
|
||||
Previously check_users in combination with systemd used
|
||||
sd_get_sessions (3) to aquire the number of users, probably
|
||||
with the idea that every users opens a session.
|
||||
Turns out, that a user can have multiple sessions and we only really
|
||||
want to know how many users there are.
|
||||
|
||||
This commit changes to sd_get_uids (3) to achieve that target.
|
||||
---
|
||||
plugins/check_users.d/users.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/plugins/check_users.c
|
||||
+++ b/plugins/check_users.c
|
||||
@@ -92,7 +92,7 @@
|
||||
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
if (sd_booted () > 0)
|
||||
- users = sd_get_sessions (NULL);
|
||||
+ users = sd_get_uids(NULL);
|
||||
else {
|
||||
#endif
|
||||
#if HAVE_WTSAPI32_H
|
17
debian/patches/series
vendored
17
debian/patches/series
vendored
|
@ -1,4 +1,21 @@
|
|||
02_check_icmp_links
|
||||
03_epn
|
||||
04_lmstat_path
|
||||
# commited upstream
|
||||
10_check_curl_fix_redirects
|
||||
11_check_curl_raise_ssl_issue
|
||||
12_check_curl_add_docu
|
||||
13_check_mysql_fix_variables
|
||||
14_check_curl_remove_experimental_state
|
||||
15_check_curl_fix_regex
|
||||
16_check_curl_openssl_error
|
||||
17_check_fping_dontfrag_random
|
||||
18_check_curl_fix_TLS_notes
|
||||
19_check_curl_cookie_handling
|
||||
20_check_icmp_fix_rtmin
|
||||
21_check_http_state_regex
|
||||
22_check_by_ssh_missing_options
|
||||
23_sslutils_fix_error_message
|
||||
24_check_http_deprecation
|
||||
25_check_users_sd_get_uids
|
||||
# feature patches
|
||||
|
|
4
debian/pluginconfig/http.cfg
vendored
4
debian/pluginconfig/http.cfg
vendored
|
@ -6,7 +6,7 @@ define command{
|
|||
|
||||
# 'check_http_hostname' command definition
|
||||
define command{
|
||||
command_name check_httpname
|
||||
command_name check_http_hostname
|
||||
command_line /usr/lib/nagios/plugins/check_http -H '$HOSTNAME$' -I '$HOSTADDRESS$' '$ARG1$'
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ define command{
|
|||
|
||||
# 'check_http_hostname_4' command definition
|
||||
define command{
|
||||
command_name check_httpname_4
|
||||
command_name check_http_hostname_4
|
||||
command_line /usr/lib/nagios/plugins/check_http -H '$HOSTNAME$' -I '$HOSTADDRESS$' -4 '$ARG1$'
|
||||
}
|
||||
|
||||
|
|
9
debian/rules
vendored
9
debian/rules
vendored
|
@ -28,15 +28,15 @@ std_plugins:=check_breeze check_ifoperstatus check_hpjd check_ifstatus \
|
|||
check_rpc check_snmp check_wave check_fping check_game \
|
||||
check_radius check_mysql check_mysql_query check_pgsql \
|
||||
check_disk_smb check_ldap check_ldaps \
|
||||
check_mailq check_curl \
|
||||
check_mailq \
|
||||
check_dns check_dig check_flexlm check_oracle \
|
||||
check_dbi
|
||||
|
||||
common_files:=negate urlize utils.pm utils.sh
|
||||
|
||||
basic_plugin_cfgs:=apt dhcp disk dummy ftp http load mail news ntp ping procs \
|
||||
basic_plugin_cfgs:=apt dhcp disk dummy ftp http curl-http load mail news ntp ping procs \
|
||||
real ssh tcp_udp telnet users
|
||||
std_plugin_cfgs:=breeze curl-http disk-smb dns flexlm fping games hppjd ifstatus ldap \
|
||||
std_plugin_cfgs:=breeze disk-smb dns flexlm fping games hppjd ifstatus ldap \
|
||||
mailq mrtg mysql netware nt pgsql radius rpc-nfs snmp
|
||||
|
||||
PATH = /bin:/sbin:/usr/bin:/usr/sbin
|
||||
|
@ -156,6 +156,8 @@ install: build
|
|||
for p in ${std_plugins}; do \
|
||||
mv ${NP_BASIC_DIR}/${NP_LIBEXEC}/$$p ${NP_STD_DIR}/${NP_LIBEXEC}; \
|
||||
done
|
||||
# rename check_http to check_http_deprecated for making use of update-alternatives
|
||||
mv ${NP_BASIC_DIR}/${NP_LIBEXEC}/check_http ${NP_BASIC_DIR}/${NP_LIBEXEC}/check_http.deprecated
|
||||
# slit out common files
|
||||
for p in ${common_files}; do \
|
||||
mv ${NP_BASIC_DIR}/${NP_LIBEXEC}/$$p ${NP_COMMON_DIR}/${NP_LIBEXEC}; \
|
||||
|
@ -213,6 +215,7 @@ binary-arch: build install
|
|||
dh_link -a
|
||||
dh_installexamples -a
|
||||
dh_installman -a
|
||||
dh_installalternatives -a
|
||||
dh_strip -a
|
||||
dh_compress -a
|
||||
dh_fixperms -a -X utils.pm
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -280,8 +280,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/nocrash.m4 $(top_srcdir)/gl/m4/off_t.m4 \
|
||||
$(top_srcdir)/gl/m4/open-cloexec.m4 \
|
||||
$(top_srcdir)/gl/m4/open-slash.m4 $(top_srcdir)/gl/m4/open.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/pid_t.m4 \
|
||||
$(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pthread_rwlock_rdlock.m4 \
|
||||
$(top_srcdir)/gl/m4/realloc.m4 \
|
||||
$(top_srcdir)/gl/m4/reallocarray.m4 \
|
||||
|
@ -294,7 +293,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/sockets.m4 $(top_srcdir)/gl/m4/socklen.m4 \
|
||||
$(top_srcdir)/gl/m4/sockpfaf.m4 $(top_srcdir)/gl/m4/ssize_t.m4 \
|
||||
$(top_srcdir)/gl/m4/stat-time.m4 $(top_srcdir)/gl/m4/stat.m4 \
|
||||
$(top_srcdir)/gl/m4/std-gnu11.m4 \
|
||||
$(top_srcdir)/gl/m4/stdalign.m4 \
|
||||
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
|
||||
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
|
||||
|
@ -312,7 +310,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/time_r.m4 $(top_srcdir)/gl/m4/timegm.m4 \
|
||||
$(top_srcdir)/gl/m4/ungetc.m4 $(top_srcdir)/gl/m4/unistd_h.m4 \
|
||||
$(top_srcdir)/gl/m4/unlocked-io.m4 \
|
||||
$(top_srcdir)/gl/m4/vararrays.m4 \
|
||||
$(top_srcdir)/gl/m4/vasnprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/vasprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/visibility.m4 \
|
||||
|
@ -656,8 +653,6 @@ am__define_uniq_tagged_files = \
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in \
|
||||
$(top_srcdir)/build-aux/depcomp \
|
||||
|
@ -714,6 +709,8 @@ CFLAGS = @CFLAGS@
|
|||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DBILIBS = @DBILIBS@
|
||||
DEFS = @DEFS@
|
||||
|
@ -733,6 +730,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
|
|||
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
|
||||
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
|
||||
ERRNO_H = @ERRNO_H@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTRAS = @EXTRAS@
|
||||
EXTRAS_ROOT = @EXTRAS_ROOT@
|
||||
|
@ -2104,6 +2102,8 @@ install_sh = @install_sh@
|
|||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localedir_c = @localedir_c@
|
||||
localedir_c_make = @localedir_c_make@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
|
@ -4268,7 +4268,6 @@ cscopelist-am: $(am__tagged_files)
|
|||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
# pid_t.m4 serial 4
|
||||
dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# The following implementation works around a problem in autoconf <= 2.69.
|
||||
m4_version_prereq([2.70], [], [
|
||||
|
||||
dnl Define pid_t if the headers don't define it.
|
||||
AC_DEFUN([AC_TYPE_PID_T],
|
||||
[
|
||||
AC_CHECK_TYPE([pid_t],
|
||||
[],
|
||||
[dnl On 64-bit native Windows, define it to the equivalent of 'intptr_t'
|
||||
dnl (= 'long long' = '__int64'), because that is the return type
|
||||
dnl of the _spawnv* functions
|
||||
dnl <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/spawnvp-wspawnvp>
|
||||
dnl and the argument type of the _cwait function
|
||||
dnl <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/cwait>.
|
||||
dnl Otherwise (on 32-bit Windows and on old Unix platforms), define it
|
||||
dnl to 'int'.
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#if defined _WIN64 && !defined __CYGWIN__
|
||||
LLP64
|
||||
#endif
|
||||
]])
|
||||
],
|
||||
[gl_pid_type='int'],
|
||||
[gl_pid_type='__int64'])
|
||||
AC_DEFINE_UNQUOTED([pid_t], [$gl_pid_type],
|
||||
[Define as a signed integer type capable of holding a process identifier.])
|
||||
],
|
||||
[AC_INCLUDES_DEFAULT])
|
||||
])
|
||||
|
||||
])# m4_version_prereq 2.70
|
|
@ -1,829 +0,0 @@
|
|||
# Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*-
|
||||
|
||||
# This implementation is taken from GNU Autoconf lib/autoconf/c.m4
|
||||
# commit 017d5ddd82854911f0119691d91ea8a1438824d6
|
||||
# dated Sun Apr 3 13:57:17 2016 -0700
|
||||
# This implementation will be obsolete once we can assume Autoconf 2.70
|
||||
# or later is installed everywhere a Gnulib program might be developed.
|
||||
|
||||
m4_version_prereq([2.70], [], [
|
||||
|
||||
|
||||
# Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Written by David MacKenzie, with help from
|
||||
# Akim Demaille, Paul Eggert,
|
||||
# François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
|
||||
# Roland McGrath, Noah Friedman, david d zuhn, and many others.
|
||||
|
||||
|
||||
# AC_PROG_CC([COMPILER ...])
|
||||
# --------------------------
|
||||
# COMPILER ... is a space separated list of C compilers to search for.
|
||||
# This just gives the user an opportunity to specify an alternative
|
||||
# search list for the C compiler.
|
||||
AC_DEFUN_ONCE([AC_PROG_CC],
|
||||
[AC_LANG_PUSH(C)dnl
|
||||
AC_ARG_VAR([CC], [C compiler command])dnl
|
||||
AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
|
||||
_AC_ARG_VAR_LDFLAGS()dnl
|
||||
_AC_ARG_VAR_LIBS()dnl
|
||||
_AC_ARG_VAR_CPPFLAGS()dnl
|
||||
m4_ifval([$1],
|
||||
[AC_CHECK_TOOLS(CC, [$1])],
|
||||
[AC_CHECK_TOOL(CC, gcc)
|
||||
if test -z "$CC"; then
|
||||
dnl Here we want:
|
||||
dnl AC_CHECK_TOOL(CC, cc)
|
||||
dnl but without the check for a tool without the prefix.
|
||||
dnl Until the check is removed from there, copy the code:
|
||||
if test -n "$ac_tool_prefix"; then
|
||||
AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
|
||||
fi
|
||||
fi
|
||||
if test -z "$CC"; then
|
||||
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
|
||||
fi
|
||||
if test -z "$CC"; then
|
||||
AC_CHECK_TOOLS(CC, cl.exe)
|
||||
fi
|
||||
if test -z "$CC"; then
|
||||
AC_CHECK_TOOL(CC, clang)
|
||||
fi
|
||||
])
|
||||
|
||||
test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
|
||||
|
||||
# Provide some information about the compiler.
|
||||
_AS_ECHO_LOG([checking for _AC_LANG compiler version])
|
||||
set X $ac_compile
|
||||
ac_compiler=$[2]
|
||||
for ac_option in --version -v -V -qversion -version; do
|
||||
_AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
|
||||
done
|
||||
|
||||
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
|
||||
m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
|
||||
_AC_LANG_COMPILER_GNU
|
||||
if test $ac_compiler_gnu = yes; then
|
||||
GCC=yes
|
||||
else
|
||||
GCC=
|
||||
fi
|
||||
_AC_PROG_CC_G
|
||||
dnl
|
||||
dnl Set ac_prog_cc_stdc to the supported C version.
|
||||
dnl Also set the documented variable ac_cv_prog_cc_stdc;
|
||||
dnl its name was chosen when it was cached, but it is no longer cached.
|
||||
_AC_PROG_CC_C11([ac_prog_cc_stdc=c11
|
||||
ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
|
||||
[_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
|
||||
ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
|
||||
[_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
|
||||
ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
|
||||
[ac_prog_cc_stdc=no
|
||||
ac_cv_prog_cc_stdc=no])])])
|
||||
dnl
|
||||
AC_LANG_POP(C)dnl
|
||||
])# AC_PROG_CC
|
||||
|
||||
|
||||
|
||||
# AC_PROG_CXX([LIST-OF-COMPILERS])
|
||||
# --------------------------------
|
||||
# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
|
||||
# for (if not specified, a default list is used). This just gives the
|
||||
# user an opportunity to specify an alternative search list for the C++
|
||||
# compiler.
|
||||
# aCC HP-UX C++ compiler much better than `CC', so test before.
|
||||
# FCC Fujitsu C++ compiler
|
||||
# KCC KAI C++ compiler
|
||||
# RCC Rational C++
|
||||
# xlC_r AIX C Set++ (with support for reentrant code)
|
||||
# xlC AIX C Set++
|
||||
AC_DEFUN([AC_PROG_CXX],
|
||||
[AC_LANG_PUSH(C++)dnl
|
||||
AC_ARG_VAR([CXX], [C++ compiler command])dnl
|
||||
AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
|
||||
_AC_ARG_VAR_LDFLAGS()dnl
|
||||
_AC_ARG_VAR_LIBS()dnl
|
||||
_AC_ARG_VAR_CPPFLAGS()dnl
|
||||
_AC_ARG_VAR_PRECIOUS([CCC])dnl
|
||||
if test -z "$CXX"; then
|
||||
if test -n "$CCC"; then
|
||||
CXX=$CCC
|
||||
else
|
||||
AC_CHECK_TOOLS(CXX,
|
||||
[m4_default([$1],
|
||||
[g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
|
||||
g++)
|
||||
fi
|
||||
fi
|
||||
# Provide some information about the compiler.
|
||||
_AS_ECHO_LOG([checking for _AC_LANG compiler version])
|
||||
set X $ac_compile
|
||||
ac_compiler=$[2]
|
||||
for ac_option in --version -v -V -qversion; do
|
||||
_AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
|
||||
done
|
||||
|
||||
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
|
||||
m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
|
||||
_AC_LANG_COMPILER_GNU
|
||||
if test $ac_compiler_gnu = yes; then
|
||||
GXX=yes
|
||||
else
|
||||
GXX=
|
||||
fi
|
||||
_AC_PROG_CXX_G
|
||||
_AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11
|
||||
ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
|
||||
ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11],
|
||||
[_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98
|
||||
ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
|
||||
[ac_prog_cxx_stdcxx=no
|
||||
ac_cv_prog_cxx_stdcxx=no])])
|
||||
AC_LANG_POP(C++)dnl
|
||||
])# AC_PROG_CXX
|
||||
|
||||
|
||||
# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
|
||||
# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
|
||||
# --------------------------------------------------------------
|
||||
# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
|
||||
# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
|
||||
# try again with each compiler option in the space-separated OPTION-LIST; if one
|
||||
# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
|
||||
# else ACTION-IF-UNAVAILABLE.
|
||||
AC_DEFUN([_AC_C_STD_TRY],
|
||||
[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features])
|
||||
AC_CACHE_VAL(ac_cv_prog_cc_$1,
|
||||
[ac_cv_prog_cc_$1=no
|
||||
ac_save_CC=$CC
|
||||
AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
|
||||
for ac_arg in '' $4
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
_AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
|
||||
test "x$ac_cv_prog_cc_$1" != "xno" && break
|
||||
done
|
||||
rm -f conftest.$ac_ext
|
||||
CC=$ac_save_CC
|
||||
])# AC_CACHE_VAL
|
||||
ac_prog_cc_stdc_options=
|
||||
case "x$ac_cv_prog_cc_$1" in
|
||||
x)
|
||||
AC_MSG_RESULT([none needed]) ;;
|
||||
xno)
|
||||
AC_MSG_RESULT([unsupported]) ;;
|
||||
*)
|
||||
ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
|
||||
CC=$CC$ac_prog_cc_stdc_options
|
||||
AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
|
||||
esac
|
||||
AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
|
||||
])# _AC_C_STD_TRY
|
||||
|
||||
# _AC_C_C99_TEST_HEADER
|
||||
# ---------------------
|
||||
# A C header suitable for testing for C99.
|
||||
AC_DEFUN([_AC_C_C99_TEST_HEADER],
|
||||
[[#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Check varargs macros. These examples are taken from C99 6.10.3.5.
|
||||
#define debug(...) fprintf (stderr, __VA_ARGS__)
|
||||
#define showlist(...) puts (#__VA_ARGS__)
|
||||
#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
|
||||
static void
|
||||
test_varargs_macros (void)
|
||||
{
|
||||
int x = 1234;
|
||||
int y = 5678;
|
||||
debug ("Flag");
|
||||
debug ("X = %d\n", x);
|
||||
showlist (The first, second, and third items.);
|
||||
report (x>y, "x is %d but y is %d", x, y);
|
||||
}
|
||||
|
||||
// Check long long types.
|
||||
#define BIG64 18446744073709551615ull
|
||||
#define BIG32 4294967295ul
|
||||
#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
|
||||
#if !BIG_OK
|
||||
your preprocessor is broken;
|
||||
#endif
|
||||
#if BIG_OK
|
||||
#else
|
||||
your preprocessor is broken;
|
||||
#endif
|
||||
static long long int bignum = -9223372036854775807LL;
|
||||
static unsigned long long int ubignum = BIG64;
|
||||
|
||||
struct incomplete_array
|
||||
{
|
||||
int datasize;
|
||||
double data[];
|
||||
};
|
||||
|
||||
struct named_init {
|
||||
int number;
|
||||
const wchar_t *name;
|
||||
double average;
|
||||
};
|
||||
|
||||
typedef const char *ccp;
|
||||
|
||||
static inline int
|
||||
test_restrict (ccp restrict text)
|
||||
{
|
||||
// See if C++-style comments work.
|
||||
// Iterate through items via the restricted pointer.
|
||||
// Also check for declarations in for loops.
|
||||
for (unsigned int i = 0; *(text+i) != '\0'; ++i)
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check varargs and va_copy.
|
||||
static bool
|
||||
test_varargs (const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
va_list args_copy;
|
||||
va_copy (args_copy, args);
|
||||
|
||||
const char *str = "";
|
||||
int number = 0;
|
||||
float fnumber = 0;
|
||||
|
||||
while (*format)
|
||||
{
|
||||
switch (*format++)
|
||||
{
|
||||
case 's': // string
|
||||
str = va_arg (args_copy, const char *);
|
||||
break;
|
||||
case 'd': // int
|
||||
number = va_arg (args_copy, int);
|
||||
break;
|
||||
case 'f': // float
|
||||
fnumber = va_arg (args_copy, double);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end (args_copy);
|
||||
va_end (args);
|
||||
|
||||
return *str && number && fnumber;
|
||||
}]])# _AC_C_C99_TEST_HEADER
|
||||
|
||||
# _AC_C_C99_TEST_BODY
|
||||
# -------------------
|
||||
# A C body suitable for testing for C99, assuming the corresponding header.
|
||||
AC_DEFUN([_AC_C_C99_TEST_BODY],
|
||||
[[
|
||||
// Check bool.
|
||||
_Bool success = false;
|
||||
|
||||
// Check restrict.
|
||||
if (test_restrict ("String literal") == 0)
|
||||
success = true;
|
||||
char *restrict newvar = "Another string";
|
||||
|
||||
// Check varargs.
|
||||
success &= test_varargs ("s, d' f .", "string", 65, 34.234);
|
||||
test_varargs_macros ();
|
||||
|
||||
// Check flexible array members.
|
||||
struct incomplete_array *ia =
|
||||
malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
|
||||
ia->datasize = 10;
|
||||
for (int i = 0; i < ia->datasize; ++i)
|
||||
ia->data[i] = i * 1.234;
|
||||
|
||||
// Check named initializers.
|
||||
struct named_init ni = {
|
||||
.number = 34,
|
||||
.name = L"Test wide string",
|
||||
.average = 543.34343,
|
||||
};
|
||||
|
||||
ni.number = 58;
|
||||
|
||||
int dynamic_array[ni.number];
|
||||
dynamic_array[ni.number - 1] = 543;
|
||||
|
||||
// work around unused variable warnings
|
||||
return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
|
||||
|| dynamic_array[ni.number - 1] != 543);
|
||||
]])
|
||||
|
||||
# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
|
||||
# ----------------------------------------------------------------
|
||||
# If the C compiler is not in ISO C99 mode by default, try to add an
|
||||
# option to output variable CC to make it so. This macro tries
|
||||
# various options that select ISO C99 on some system or another. It
|
||||
# considers the compiler to be in ISO C99 mode if it handles _Bool,
|
||||
# // comments, flexible array members, inline, long long int, mixed
|
||||
# code and declarations, named initialization of structs, restrict,
|
||||
# va_copy, varargs macros, variable declarations in for loops and
|
||||
# variable length arrays.
|
||||
AC_DEFUN([_AC_PROG_CC_C99],
|
||||
[_AC_C_STD_TRY([c99],
|
||||
[_AC_C_C99_TEST_HEADER],
|
||||
[_AC_C_C99_TEST_BODY],
|
||||
dnl Try
|
||||
dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
|
||||
dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
|
||||
dnl IBM XL C -qlanglvl=extc99
|
||||
dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
|
||||
dnl HP cc -AC99
|
||||
dnl Intel ICC -std=c99, -c99 (deprecated)
|
||||
dnl IRIX -c99
|
||||
dnl Solaris -D_STDC_C99=
|
||||
dnl cc's -xc99 option uses linker magic to define the external
|
||||
dnl symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
|
||||
dnl behavior for C library functions. This is not wanted here,
|
||||
dnl because it means that a single module compiled with -xc99
|
||||
dnl alters C runtime behavior for the entire program, not for
|
||||
dnl just the module. Instead, define the (private) symbol
|
||||
dnl _STDC_C99, which suppresses a bogus failure in <stdbool.h>.
|
||||
dnl The resulting compiler passes the test case here, and that's
|
||||
dnl good enough. For more, please see the thread starting at:
|
||||
dnl https://lists.gnu.org/r/autoconf/2010-12/msg00059.html
|
||||
dnl Tru64 -c99
|
||||
dnl with extended modes being tried first.
|
||||
[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl
|
||||
])# _AC_PROG_CC_C99
|
||||
|
||||
|
||||
# _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
|
||||
# ----------------------------------------------------------------
|
||||
# If the C compiler is not in ISO C11 mode by default, try to add an
|
||||
# option to output variable CC to make it so. This macro tries
|
||||
# various options that select ISO C11 on some system or another. It
|
||||
# considers the compiler to be in ISO C11 mode if it handles _Alignas,
|
||||
# _Alignof, _Noreturn, _Static_assert, UTF-8 string literals,
|
||||
# duplicate typedefs, and anonymous structures and unions.
|
||||
AC_DEFUN([_AC_PROG_CC_C11],
|
||||
[_AC_C_STD_TRY([c11],
|
||||
[_AC_C_C99_TEST_HEADER[
|
||||
// Check _Alignas.
|
||||
char _Alignas (double) aligned_as_double;
|
||||
char _Alignas (0) no_special_alignment;
|
||||
extern char aligned_as_int;
|
||||
char _Alignas (0) _Alignas (int) aligned_as_int;
|
||||
|
||||
// Check _Alignof.
|
||||
enum
|
||||
{
|
||||
int_alignment = _Alignof (int),
|
||||
int_array_alignment = _Alignof (int[100]),
|
||||
char_alignment = _Alignof (char)
|
||||
};
|
||||
_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
|
||||
|
||||
// Check _Noreturn.
|
||||
int _Noreturn does_not_return (void) { for (;;) continue; }
|
||||
|
||||
// Check _Static_assert.
|
||||
struct test_static_assert
|
||||
{
|
||||
int x;
|
||||
_Static_assert (sizeof (int) <= sizeof (long int),
|
||||
"_Static_assert does not work in struct");
|
||||
long int y;
|
||||
};
|
||||
|
||||
// Check UTF-8 literals.
|
||||
#define u8 syntax error!
|
||||
char const utf8_literal[] = u8"happens to be ASCII" "another string";
|
||||
|
||||
// Check duplicate typedefs.
|
||||
typedef long *long_ptr;
|
||||
typedef long int *long_ptr;
|
||||
typedef long_ptr long_ptr;
|
||||
|
||||
// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
|
||||
struct anonymous
|
||||
{
|
||||
union {
|
||||
struct { int i; int j; };
|
||||
struct { int k; long int l; } w;
|
||||
};
|
||||
int m;
|
||||
} v1;
|
||||
]],
|
||||
[_AC_C_C99_TEST_BODY[
|
||||
v1.i = 2;
|
||||
v1.w.k = 5;
|
||||
_Static_assert ((offsetof (struct anonymous, i)
|
||||
== offsetof (struct anonymous, w.k)),
|
||||
"Anonymous union alignment botch");
|
||||
]],
|
||||
dnl Try
|
||||
dnl GCC -std=gnu11 (unused restrictive mode: -std=c11)
|
||||
dnl with extended modes being tried first.
|
||||
dnl
|
||||
dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
|
||||
dnl of September 2012) does not pass the C11 test. For now, try extc1x when
|
||||
dnl compiling the C99 test instead, since it enables _Static_assert and
|
||||
dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes
|
||||
dnl the C11 test in some future version of IBM XL C, we'll add it here,
|
||||
dnl preferably extc11.
|
||||
[[-std=gnu11]], [$1], [$2])[]dnl
|
||||
])# _AC_PROG_CC_C11
|
||||
|
||||
|
||||
# AC_PROG_CC_C89
|
||||
# --------------
|
||||
# Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
|
||||
# as that'd be incompatible with how Automake redefines AC_PROG_CC. See
|
||||
# <https://lists.gnu.org/r/autoconf/2012-10/msg00048.html>.
|
||||
AU_DEFUN([AC_PROG_CC_C89],
|
||||
[AC_REQUIRE([AC_PROG_CC])],
|
||||
[$0 is obsolete; use AC_PROG_CC]
|
||||
)
|
||||
|
||||
# AC_PROG_CC_C99
|
||||
# --------------
|
||||
AU_DEFUN([AC_PROG_CC_C99],
|
||||
[AC_REQUIRE([AC_PROG_CC])],
|
||||
[$0 is obsolete; use AC_PROG_CC]
|
||||
)
|
||||
|
||||
# AC_PROG_CC_STDC
|
||||
# ---------------
|
||||
AU_DEFUN([AC_PROG_CC_STDC],
|
||||
[AC_REQUIRE([AC_PROG_CC])],
|
||||
[$0 is obsolete; use AC_PROG_CC]
|
||||
)
|
||||
|
||||
|
||||
# AC_C_PROTOTYPES
|
||||
# ---------------
|
||||
# Check if the C compiler supports prototypes, included if it needs
|
||||
# options.
|
||||
AC_DEFUN([AC_C_PROTOTYPES],
|
||||
[AC_REQUIRE([AC_PROG_CC])dnl
|
||||
if test "$ac_prog_cc_stdc" != no; then
|
||||
AC_DEFINE(PROTOTYPES, 1,
|
||||
[Define to 1 if the C compiler supports function prototypes.])
|
||||
AC_DEFINE(__PROTOTYPES, 1,
|
||||
[Define like PROTOTYPES; this can be used by system headers.])
|
||||
fi
|
||||
])# AC_C_PROTOTYPES
|
||||
|
||||
|
||||
# _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
|
||||
# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
|
||||
# ----------------------------------------------------------------
|
||||
# Check whether the C++ compiler accepts features of STANDARD (e.g
|
||||
# `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE
|
||||
# and TEST-BODY. If this fails, try again with each compiler option
|
||||
# in the space-separated OPTION-LIST; if one helps, append it to CXX.
|
||||
# If eventually successful, run ACTION-IF-AVAILABLE, else
|
||||
# ACTION-IF-UNAVAILABLE.
|
||||
AC_DEFUN([_AC_CXX_STD_TRY],
|
||||
[AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features])
|
||||
AC_LANG_PUSH(C++)dnl
|
||||
AC_CACHE_VAL(ac_cv_prog_cxx_$1,
|
||||
[ac_cv_prog_cxx_$1=no
|
||||
ac_save_CXX=$CXX
|
||||
AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
|
||||
for ac_arg in '' $4
|
||||
do
|
||||
CXX="$ac_save_CXX $ac_arg"
|
||||
_AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg])
|
||||
test "x$ac_cv_prog_cxx_$1" != "xno" && break
|
||||
done
|
||||
rm -f conftest.$ac_ext
|
||||
CXX=$ac_save_CXX
|
||||
])# AC_CACHE_VAL
|
||||
ac_prog_cxx_stdcxx_options=
|
||||
case "x$ac_cv_prog_cxx_$1" in
|
||||
x)
|
||||
AC_MSG_RESULT([none needed]) ;;
|
||||
xno)
|
||||
AC_MSG_RESULT([unsupported]) ;;
|
||||
*)
|
||||
ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1"
|
||||
CXX=$CXX$ac_prog_cxx_stdcxx_options
|
||||
AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;;
|
||||
esac
|
||||
AC_LANG_POP(C++)dnl
|
||||
AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6])
|
||||
])# _AC_CXX_STD_TRY
|
||||
|
||||
# _AC_CXX_CXX98_TEST_HEADER
|
||||
# -------------------------
|
||||
# A C++ header suitable for testing for CXX98.
|
||||
AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER],
|
||||
[[
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace test {
|
||||
typedef std::vector<std::string> string_vec;
|
||||
typedef std::pair<int,bool> map_value;
|
||||
typedef std::map<std::string,map_value> map_type;
|
||||
typedef std::set<int> set_type;
|
||||
|
||||
template<typename T>
|
||||
class printer {
|
||||
public:
|
||||
printer(std::ostringstream& os): os(os) {}
|
||||
void operator() (T elem) { os << elem << std::endl; }
|
||||
private:
|
||||
std::ostringstream& os;
|
||||
};
|
||||
}
|
||||
]])# _AC_CXX_CXX98_TEST_HEADER
|
||||
|
||||
# _AC_CXX_CXX98_TEST_BODY
|
||||
# -----------------------
|
||||
# A C++ body suitable for testing for CXX98, assuming the corresponding header.
|
||||
AC_DEFUN([_AC_CXX_CXX98_TEST_BODY],
|
||||
[[
|
||||
|
||||
try {
|
||||
// Basic string.
|
||||
std::string teststr("ASCII text");
|
||||
teststr += " string";
|
||||
|
||||
// Simple vector.
|
||||
test::string_vec testvec;
|
||||
testvec.push_back(teststr);
|
||||
testvec.push_back("foo");
|
||||
testvec.push_back("bar");
|
||||
if (testvec.size() != 3) {
|
||||
throw std::runtime_error("vector size is not 1");
|
||||
}
|
||||
|
||||
// Dump vector into stringstream and obtain string.
|
||||
std::ostringstream os;
|
||||
for (test::string_vec::const_iterator i = testvec.begin();
|
||||
i != testvec.end(); ++i) {
|
||||
if (i + 1 != testvec.end()) {
|
||||
os << teststr << '\n';
|
||||
}
|
||||
}
|
||||
// Check algorithms work.
|
||||
std::for_each(testvec.begin(), testvec.end(), test::printer<std::string>(os));
|
||||
std::string os_out = os.str();
|
||||
|
||||
// Test pair and map.
|
||||
test::map_type testmap;
|
||||
testmap.insert(std::make_pair(std::string("key"),
|
||||
std::make_pair(53,false)));
|
||||
|
||||
// Test set.
|
||||
int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
|
||||
test::set_type testset(values, values + sizeof(values)/sizeof(values[0]));
|
||||
std::list<int> testlist(testset.begin(), testset.end());
|
||||
std::copy(testset.begin(), testset.end(), std::back_inserter(testlist));
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Caught exception: " << e.what() << std::endl;
|
||||
|
||||
// Test fstream
|
||||
std::ofstream of("test.txt");
|
||||
of << "Test ASCII text\n" << std::flush;
|
||||
of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl;
|
||||
of.close();
|
||||
}
|
||||
std::exit(0);
|
||||
]])
|
||||
|
||||
# _AC_CXX_CXX11_TEST_HEADER
|
||||
# -------------------------
|
||||
# A C++ header suitable for testing for CXX11.
|
||||
AC_DEFUN([_AC_CXX_CXX11_TEST_HEADER],
|
||||
[[
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <array>
|
||||
#include <regex>
|
||||
#include <iostream>
|
||||
|
||||
namespace cxx11test
|
||||
{
|
||||
typedef std::shared_ptr<std::string> sptr;
|
||||
typedef std::weak_ptr<std::string> wptr;
|
||||
|
||||
typedef std::tuple<std::string,int,double> tp;
|
||||
typedef std::array<int, 20> int_array;
|
||||
|
||||
constexpr int get_val() { return 20; }
|
||||
|
||||
struct testinit
|
||||
{
|
||||
int i;
|
||||
double d;
|
||||
};
|
||||
|
||||
class delegate {
|
||||
public:
|
||||
delegate(int n) : n(n) {}
|
||||
delegate(): delegate(2354) {}
|
||||
|
||||
virtual int getval() { return this->n; };
|
||||
protected:
|
||||
int n;
|
||||
};
|
||||
|
||||
class overridden : public delegate {
|
||||
public:
|
||||
overridden(int n): delegate(n) {}
|
||||
virtual int getval() override final { return this->n * 2; }
|
||||
};
|
||||
|
||||
class nocopy {
|
||||
public:
|
||||
nocopy(int i): i(i) {}
|
||||
nocopy() = default;
|
||||
nocopy(const nocopy&) = delete;
|
||||
nocopy & operator=(const nocopy&) = delete;
|
||||
private:
|
||||
int i;
|
||||
};
|
||||
}
|
||||
]])# _AC_CXX_CXX11_TEST_HEADER
|
||||
|
||||
# _AC_CXX_CXX11_TEST_BODY
|
||||
# -----------------------
|
||||
# A C++ body suitable for testing for CXX11, assuming the corresponding header.
|
||||
AC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
|
||||
[[
|
||||
{
|
||||
// Test auto and decltype
|
||||
std::deque<int> d;
|
||||
d.push_front(43);
|
||||
d.push_front(484);
|
||||
d.push_front(3);
|
||||
d.push_front(844);
|
||||
int total = 0;
|
||||
for (auto i = d.begin(); i != d.end(); ++i) { total += *i; }
|
||||
|
||||
auto a1 = 6538;
|
||||
auto a2 = 48573953.4;
|
||||
auto a3 = "String literal";
|
||||
|
||||
decltype(a2) a4 = 34895.034;
|
||||
}
|
||||
{
|
||||
// Test constexpr
|
||||
short sa[cxx11test::get_val()] = { 0 };
|
||||
}
|
||||
{
|
||||
// Test initializer lists
|
||||
cxx11test::testinit il = { 4323, 435234.23544 };
|
||||
}
|
||||
{
|
||||
// Test range-based for and lambda
|
||||
cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
|
||||
for (int &x : array) { x += 23; }
|
||||
std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; });
|
||||
}
|
||||
{
|
||||
using cxx11test::sptr;
|
||||
using cxx11test::wptr;
|
||||
|
||||
sptr sp(new std::string("ASCII string"));
|
||||
wptr wp(sp);
|
||||
sptr sp2(wp);
|
||||
}
|
||||
{
|
||||
cxx11test::tp tuple("test", 54, 45.53434);
|
||||
double d = std::get<2>(tuple);
|
||||
std::string s;
|
||||
int i;
|
||||
std::tie(s,i,d) = tuple;
|
||||
}
|
||||
{
|
||||
static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$");
|
||||
std::string testmatch("Test if this string matches");
|
||||
bool match = std::regex_search(testmatch, filename_regex);
|
||||
}
|
||||
{
|
||||
cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
|
||||
cxx11test::int_array::size_type size = array.size();
|
||||
}
|
||||
{
|
||||
// Test constructor delegation
|
||||
cxx11test::delegate d1;
|
||||
cxx11test::delegate d2();
|
||||
cxx11test::delegate d3(45);
|
||||
}
|
||||
{
|
||||
// Test override and final
|
||||
cxx11test::overridden o1(55464);
|
||||
}
|
||||
{
|
||||
// Test nullptr
|
||||
char *c = nullptr;
|
||||
}
|
||||
{
|
||||
// Test template brackets
|
||||
std::vector<std::pair<int,char*>> v1;
|
||||
}
|
||||
{
|
||||
// Unicode literals
|
||||
char const *utf8 = u8"UTF-8 string \u2500";
|
||||
char16_t const *utf16 = u"UTF-8 string \u2500";
|
||||
char32_t const *utf32 = U"UTF-32 string \u2500";
|
||||
}
|
||||
]])
|
||||
|
||||
# _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
# If the C++ compiler is not in ISO C++98 mode by default, try to add
|
||||
# an option to output variable CXX to make it so. This macro tries
|
||||
# various options that select ISO C++98 on some system or another. It
|
||||
# considers the compiler to be in ISO C++98 mode if it handles basic
|
||||
# features of the std namespace including: string, containers (list,
|
||||
# map, set, vector), streams (fstreams, iostreams, stringstreams,
|
||||
# iomanip), pair, exceptions and algorithms.
|
||||
|
||||
|
||||
AC_DEFUN([_AC_PROG_CXX_CXX98],
|
||||
[_AC_CXX_STD_TRY([cxx98],
|
||||
[_AC_CXX_CXX98_TEST_HEADER],
|
||||
[_AC_CXX_CXX98_TEST_BODY],
|
||||
dnl Try
|
||||
dnl GCC -std=gnu++98 (unused restrictive mode: -std=c++98)
|
||||
dnl IBM XL C -qlanglvl=extended
|
||||
dnl HP aC++ -AA
|
||||
dnl Intel ICC -std=gnu++98
|
||||
dnl Solaris N/A (default)
|
||||
dnl Tru64 N/A (default, but -std gnu could be used)
|
||||
dnl with extended modes being tried first.
|
||||
[[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl
|
||||
])# _AC_PROG_CXX_CXX98
|
||||
|
||||
# _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
|
||||
# -------------------------------------------------------------------
|
||||
# If the C++ compiler is not in ISO CXX11 mode by default, try to add
|
||||
# an option to output variable CXX to make it so. This macro tries
|
||||
# various options that select ISO C++11 on some system or another. It
|
||||
# considers the compiler to be in ISO C++11 mode if it handles all the
|
||||
# tests from the C++98 checks, plus the following: Language features
|
||||
# (auto, constexpr, decltype, default/deleted constructors, delegate
|
||||
# constructors, final, initializer lists, lambda functions, nullptr,
|
||||
# override, range-based for loops, template brackets without spaces,
|
||||
# unicode literals) and library features (array, memory (shared_ptr,
|
||||
# weak_ptr), regex and tuple types).
|
||||
AC_DEFUN([_AC_PROG_CXX_CXX11],
|
||||
[_AC_CXX_STD_TRY([cxx11],
|
||||
[_AC_CXX_CXX11_TEST_HEADER
|
||||
_AC_CXX_CXX98_TEST_HEADER],
|
||||
[_AC_CXX_CXX11_TEST_BODY
|
||||
_AC_CXX_CXX98_TEST_BODY],
|
||||
dnl Try
|
||||
dnl GCC -std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants]
|
||||
dnl IBM XL C -qlanglvl=extended0x
|
||||
dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11)
|
||||
dnl HP aC++ -AA
|
||||
dnl Intel ICC -std=c++11 -std=c++0x
|
||||
dnl Solaris N/A (no support)
|
||||
dnl Tru64 N/A (no support)
|
||||
dnl with extended modes being tried first.
|
||||
[[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl
|
||||
])# _AC_PROG_CXX_CXX11
|
||||
|
||||
|
||||
])# m4_version_prereq
|
|
@ -1,72 +0,0 @@
|
|||
# Check for variable-length arrays.
|
||||
|
||||
# serial 6
|
||||
|
||||
# From Paul Eggert
|
||||
|
||||
# Copyright (C) 2001, 2009-2023 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
m4_version_prereq([2.70], [], [
|
||||
|
||||
# AC_C_VARARRAYS
|
||||
# --------------
|
||||
# Check whether the C compiler supports variable-length arrays.
|
||||
AC_DEFUN([AC_C_VARARRAYS],
|
||||
[
|
||||
AC_CACHE_CHECK([for variable-length arrays],
|
||||
ac_cv_c_vararrays,
|
||||
[AC_EGREP_CPP([defined],
|
||||
[#ifdef __STDC_NO_VLA__
|
||||
defined
|
||||
#endif
|
||||
],
|
||||
[ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[/* Test for VLA support. This test is partly inspired
|
||||
from examples in the C standard. Use at least two VLA
|
||||
functions to detect the GCC 3.4.3 bug described in:
|
||||
https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
|
||||
*/
|
||||
#ifdef __STDC_NO_VLA__
|
||||
syntax error;
|
||||
#else
|
||||
extern int n;
|
||||
int B[100];
|
||||
int fvla (int m, int C[m][m]);
|
||||
|
||||
int
|
||||
simple (int count, int all[static count])
|
||||
{
|
||||
return all[count - 1];
|
||||
}
|
||||
|
||||
int
|
||||
fvla (int m, int C[m][m])
|
||||
{
|
||||
typedef int VLA[m][m];
|
||||
VLA x;
|
||||
int D[m];
|
||||
static int (*q)[m] = &B;
|
||||
int (*s)[n] = q;
|
||||
return C && &x[0][0] == &D[0] && &D[0] == s[0];
|
||||
}
|
||||
#endif
|
||||
]])],
|
||||
[ac_cv_c_vararrays=yes],
|
||||
[ac_cv_c_vararrays=no])])])
|
||||
if test "$ac_cv_c_vararrays" = yes; then
|
||||
dnl This is for compatibility with Autoconf 2.61-2.69.
|
||||
AC_DEFINE([HAVE_C_VARARRAYS], 1,
|
||||
[Define to 1 if C supports variable-length arrays.])
|
||||
elif test "$ac_cv_c_vararrays" = no; then
|
||||
AC_DEFINE([__STDC_NO_VLA__], 1,
|
||||
[Define to 1 if C does not support variable-length arrays, and
|
||||
if the compiler does not already define this.])
|
||||
fi
|
||||
])
|
||||
|
||||
])
|
|
@ -1,7 +1,7 @@
|
|||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -165,8 +165,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/nocrash.m4 $(top_srcdir)/gl/m4/off_t.m4 \
|
||||
$(top_srcdir)/gl/m4/open-cloexec.m4 \
|
||||
$(top_srcdir)/gl/m4/open-slash.m4 $(top_srcdir)/gl/m4/open.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/pid_t.m4 \
|
||||
$(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pthread_rwlock_rdlock.m4 \
|
||||
$(top_srcdir)/gl/m4/realloc.m4 \
|
||||
$(top_srcdir)/gl/m4/reallocarray.m4 \
|
||||
|
@ -179,7 +178,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/sockets.m4 $(top_srcdir)/gl/m4/socklen.m4 \
|
||||
$(top_srcdir)/gl/m4/sockpfaf.m4 $(top_srcdir)/gl/m4/ssize_t.m4 \
|
||||
$(top_srcdir)/gl/m4/stat-time.m4 $(top_srcdir)/gl/m4/stat.m4 \
|
||||
$(top_srcdir)/gl/m4/std-gnu11.m4 \
|
||||
$(top_srcdir)/gl/m4/stdalign.m4 \
|
||||
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
|
||||
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
|
||||
|
@ -197,7 +195,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/time_r.m4 $(top_srcdir)/gl/m4/timegm.m4 \
|
||||
$(top_srcdir)/gl/m4/ungetc.m4 $(top_srcdir)/gl/m4/unistd_h.m4 \
|
||||
$(top_srcdir)/gl/m4/unlocked-io.m4 \
|
||||
$(top_srcdir)/gl/m4/vararrays.m4 \
|
||||
$(top_srcdir)/gl/m4/vasnprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/vasprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/visibility.m4 \
|
||||
|
@ -312,8 +309,6 @@ am__define_uniq_tagged_files = \
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in \
|
||||
$(top_srcdir)/build-aux/depcomp \
|
||||
|
@ -370,6 +365,8 @@ CFLAGS = @CFLAGS@
|
|||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DBILIBS = @DBILIBS@
|
||||
DEFS = @DEFS@
|
||||
|
@ -389,6 +386,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
|
|||
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
|
||||
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
|
||||
ERRNO_H = @ERRNO_H@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTRAS = @EXTRAS@
|
||||
EXTRAS_ROOT = @EXTRAS_ROOT@
|
||||
|
@ -1760,6 +1758,8 @@ install_sh = @install_sh@
|
|||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localedir_c = @localedir_c@
|
||||
localedir_c_make = @localedir_c_make@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
|
@ -1974,7 +1974,6 @@ cscopelist-am: $(am__tagged_files)
|
|||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
*/
|
||||
typedef struct {
|
||||
char *file;
|
||||
bool file_string_on_heap;
|
||||
char *stanza;
|
||||
} np_ini_info;
|
||||
|
||||
|
@ -95,16 +96,22 @@ parse_locator(const char *locator, const char *def_stanza, np_ini_info *i)
|
|||
i->stanza = malloc(sizeof(char) * (stanza_len + 1));
|
||||
strncpy(i->stanza, locator, stanza_len);
|
||||
i->stanza[stanza_len] = '\0';
|
||||
} else /* otherwise we use the default stanza */
|
||||
} else {/* otherwise we use the default stanza */
|
||||
i->stanza = strdup(def_stanza);
|
||||
}
|
||||
|
||||
if (i->stanza == NULL)
|
||||
die(STATE_UNKNOWN, _("malloc() failed!\n"));
|
||||
|
||||
/* check whether there's an @file part */
|
||||
i->file = stanza_len == locator_len
|
||||
? default_file()
|
||||
: strdup(&(locator[stanza_len + 1]));
|
||||
if (stanza_len == locator_len) {
|
||||
i->file = default_file();
|
||||
i->file_string_on_heap = false;
|
||||
} else {
|
||||
i->file = strdup(&(locator[stanza_len + 1]));
|
||||
i->file_string_on_heap = true;
|
||||
}
|
||||
|
||||
if (i->file == NULL || i->file[0] == '\0')
|
||||
die(STATE_UNKNOWN,
|
||||
_("Cannot find config file in any standard location.\n"));
|
||||
|
@ -136,7 +143,10 @@ np_get_defaults(const char *locator, const char *default_section)
|
|||
_("Invalid section '%s' in config file '%s'\n"), i.stanza,
|
||||
i.file);
|
||||
|
||||
free(i.file);
|
||||
if (i.file_string_on_heap) {
|
||||
free(i.file);
|
||||
}
|
||||
|
||||
if (inifile != stdin)
|
||||
fclose(inifile);
|
||||
free(i.stanza);
|
||||
|
@ -358,14 +368,18 @@ add_option(FILE *f, np_arg_list **optlst)
|
|||
static char *
|
||||
default_file(void)
|
||||
{
|
||||
char **p, *ini_file;
|
||||
char *ini_file;
|
||||
|
||||
if ((ini_file = getenv("MP_CONFIG_FILE")) != NULL ||
|
||||
(ini_file = default_file_in_path()) != NULL)
|
||||
(ini_file = default_file_in_path()) != NULL) {
|
||||
return ini_file;
|
||||
for (p = default_ini_path_names; *p != NULL; p++)
|
||||
if (access(*p, F_OK) == 0)
|
||||
}
|
||||
|
||||
for (char **p = default_ini_path_names; *p != NULL; p++) {
|
||||
if (access(*p, F_OK) == 0) {
|
||||
return *p;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -168,8 +168,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/nocrash.m4 $(top_srcdir)/gl/m4/off_t.m4 \
|
||||
$(top_srcdir)/gl/m4/open-cloexec.m4 \
|
||||
$(top_srcdir)/gl/m4/open-slash.m4 $(top_srcdir)/gl/m4/open.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/pid_t.m4 \
|
||||
$(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pthread_rwlock_rdlock.m4 \
|
||||
$(top_srcdir)/gl/m4/realloc.m4 \
|
||||
$(top_srcdir)/gl/m4/reallocarray.m4 \
|
||||
|
@ -182,7 +181,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/sockets.m4 $(top_srcdir)/gl/m4/socklen.m4 \
|
||||
$(top_srcdir)/gl/m4/sockpfaf.m4 $(top_srcdir)/gl/m4/ssize_t.m4 \
|
||||
$(top_srcdir)/gl/m4/stat-time.m4 $(top_srcdir)/gl/m4/stat.m4 \
|
||||
$(top_srcdir)/gl/m4/std-gnu11.m4 \
|
||||
$(top_srcdir)/gl/m4/stdalign.m4 \
|
||||
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
|
||||
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
|
||||
|
@ -200,7 +198,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/time_r.m4 $(top_srcdir)/gl/m4/timegm.m4 \
|
||||
$(top_srcdir)/gl/m4/ungetc.m4 $(top_srcdir)/gl/m4/unistd_h.m4 \
|
||||
$(top_srcdir)/gl/m4/unlocked-io.m4 \
|
||||
$(top_srcdir)/gl/m4/vararrays.m4 \
|
||||
$(top_srcdir)/gl/m4/vasnprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/vasprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/visibility.m4 \
|
||||
|
@ -339,8 +336,6 @@ am__define_uniq_tagged_files = \
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__tty_colors_dummy = \
|
||||
mgn= red= grn= lgn= blu= brg= std=; \
|
||||
am__color_tests=no
|
||||
|
@ -575,6 +570,8 @@ CFLAGS = @CFLAGS@
|
|||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DBILIBS = @DBILIBS@
|
||||
DEFS = @DEFS@
|
||||
|
@ -594,6 +591,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
|
|||
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
|
||||
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
|
||||
ERRNO_H = @ERRNO_H@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTRAS = @EXTRAS@
|
||||
EXTRAS_ROOT = @EXTRAS_ROOT@
|
||||
|
@ -1965,6 +1963,8 @@ install_sh = @install_sh@
|
|||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localedir_c = @localedir_c@
|
||||
localedir_c_make = @localedir_c_make@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
|
@ -2352,7 +2352,6 @@ recheck: all $(check_PROGRAMS)
|
|||
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
||||
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
|
||||
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
monitoring_plugin *this_monitoring_plugin=NULL;
|
||||
|
||||
unsigned int timeout_state = STATE_CRITICAL;
|
||||
int timeout_state = STATE_CRITICAL;
|
||||
unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
|
||||
|
||||
bool _np_state_read_file(FILE *);
|
||||
|
|
|
@ -65,7 +65,7 @@ bool check_range(double, range *);
|
|||
int get_status(double, thresholds *);
|
||||
|
||||
/* Handle timeouts */
|
||||
extern unsigned int timeout_state;
|
||||
extern int timeout_state;
|
||||
extern unsigned int timeout_interval;
|
||||
|
||||
/* All possible characters in a threshold range */
|
||||
|
|
|
@ -390,13 +390,12 @@ cmd_file_read ( char *filename, output *out, int flags)
|
|||
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);
|
||||
|
||||
long maxfd = mp_open_max();
|
||||
if(_cmd_pids) for(i = 0; i < maxfd; i++) {
|
||||
if(_cmd_pids) for(long int i = 0; i < maxfd; i++) {
|
||||
if(_cmd_pids[i] != 0) kill(_cmd_pids[i], SIGKILL);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ PKG="NGOSplugin"
|
|||
NAME="monitoring-plugins"
|
||||
DESC="Network Monitoring Plugins for Nagios and compatible"
|
||||
ARCH="unknown"
|
||||
VERSION="2.3.5,REV=2023.10.18.09.15"
|
||||
VERSION="2.4.0,REV=2024.07.23.19.37"
|
||||
CATEGORY="application"
|
||||
VENDOR="Monitoring Plugins Development Team"
|
||||
EMAIL="devel@monitoring-plugins.org"
|
||||
PSTAMP="nag20231018091518"
|
||||
PSTAMP="nag20240723193729"
|
||||
BASEDIR="/"
|
||||
CLASSES="none"
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ EXTRA_PROGRAMS = pst3
|
|||
|
||||
EXTRA_DIST = t pst3.c
|
||||
|
||||
BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO)
|
||||
BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a
|
||||
NETOBJS = ../plugins/netutils.o $(BASEOBJS) $(EXTRA_NETOBJS)
|
||||
NETLIBS = $(NETOBJS) $(SOCKETLIBS)
|
||||
|
||||
|
@ -80,8 +80,8 @@ install-exec-local: $(noinst_PROGRAMS)
|
|||
|
||||
##############################################################################
|
||||
# the actual targets
|
||||
check_dhcp_LDADD = @LTLIBINTL@ $(NETLIBS)
|
||||
check_icmp_LDADD = @LTLIBINTL@ $(NETLIBS) $(SOCKETLIBS)
|
||||
check_dhcp_LDADD = @LTLIBINTL@ $(NETLIBS) $(LIB_CRYPTO)
|
||||
check_icmp_LDADD = @LTLIBINTL@ $(NETLIBS) $(SOCKETLIBS) $(LIB_CRYPTO)
|
||||
|
||||
# -m64 needed at compiler and linker phase
|
||||
pst3_CFLAGS = @PST3CFLAGS@
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -166,8 +166,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/nocrash.m4 $(top_srcdir)/gl/m4/off_t.m4 \
|
||||
$(top_srcdir)/gl/m4/open-cloexec.m4 \
|
||||
$(top_srcdir)/gl/m4/open-slash.m4 $(top_srcdir)/gl/m4/open.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/pid_t.m4 \
|
||||
$(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pthread_rwlock_rdlock.m4 \
|
||||
$(top_srcdir)/gl/m4/realloc.m4 \
|
||||
$(top_srcdir)/gl/m4/reallocarray.m4 \
|
||||
|
@ -180,7 +179,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/sockets.m4 $(top_srcdir)/gl/m4/socklen.m4 \
|
||||
$(top_srcdir)/gl/m4/sockpfaf.m4 $(top_srcdir)/gl/m4/ssize_t.m4 \
|
||||
$(top_srcdir)/gl/m4/stat-time.m4 $(top_srcdir)/gl/m4/stat.m4 \
|
||||
$(top_srcdir)/gl/m4/std-gnu11.m4 \
|
||||
$(top_srcdir)/gl/m4/stdalign.m4 \
|
||||
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
|
||||
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
|
||||
|
@ -198,7 +196,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/time_r.m4 $(top_srcdir)/gl/m4/timegm.m4 \
|
||||
$(top_srcdir)/gl/m4/ungetc.m4 $(top_srcdir)/gl/m4/unistd_h.m4 \
|
||||
$(top_srcdir)/gl/m4/unlocked-io.m4 \
|
||||
$(top_srcdir)/gl/m4/vararrays.m4 \
|
||||
$(top_srcdir)/gl/m4/vasnprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/vasprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/visibility.m4 \
|
||||
|
@ -220,11 +217,9 @@ PROGRAMS = $(noinst_PROGRAMS)
|
|||
check_dhcp_SOURCES = check_dhcp.c
|
||||
check_dhcp_OBJECTS = check_dhcp.$(OBJEXT)
|
||||
am__DEPENDENCIES_1 =
|
||||
am__DEPENDENCIES_2 = ../plugins/utils.o ../lib/libmonitoringplug.a \
|
||||
../gl/libgnu.a $(am__DEPENDENCIES_1)
|
||||
am__DEPENDENCIES_3 = ../plugins/netutils.o $(am__DEPENDENCIES_2) \
|
||||
am__DEPENDENCIES_2 = ../plugins/netutils.o $(BASEOBJS) \
|
||||
$(am__DEPENDENCIES_1)
|
||||
am__DEPENDENCIES_4 = $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_1)
|
||||
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
|
@ -297,8 +292,6 @@ am__define_uniq_tagged_files = \
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__tty_colors_dummy = \
|
||||
mgn= red= grn= lgn= blu= brg= std=; \
|
||||
am__color_tests=no
|
||||
|
@ -534,6 +527,8 @@ CFLAGS = @CFLAGS@
|
|||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DBILIBS = @DBILIBS@
|
||||
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
|
||||
|
@ -553,6 +548,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
|
|||
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
|
||||
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
|
||||
ERRNO_H = @ERRNO_H@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTRAS = @EXTRAS@
|
||||
EXTRAS_ROOT = @EXTRAS_ROOT@
|
||||
|
@ -1924,6 +1920,8 @@ install_sh = @install_sh@
|
|||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = $(datadir)/locale
|
||||
localedir_c = @localedir_c@
|
||||
localedir_c_make = @localedir_c_make@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
|
@ -1947,7 +1945,7 @@ with_trusted_path = @with_trusted_path@
|
|||
AM_CFLAGS = -DNP_VERSION='"$(NP_VERSION)"'
|
||||
AM_CPPFLAGS = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins @SSLINCLUDE@
|
||||
EXTRA_DIST = t pst3.c
|
||||
BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO)
|
||||
BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a
|
||||
NETOBJS = ../plugins/netutils.o $(BASEOBJS) $(EXTRA_NETOBJS)
|
||||
NETLIBS = $(NETOBJS) $(SOCKETLIBS)
|
||||
TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir)
|
||||
|
@ -1971,8 +1969,8 @@ INSTALL_SUID = \
|
|||
|
||||
##############################################################################
|
||||
# the actual targets
|
||||
check_dhcp_LDADD = @LTLIBINTL@ $(NETLIBS)
|
||||
check_icmp_LDADD = @LTLIBINTL@ $(NETLIBS) $(SOCKETLIBS)
|
||||
check_dhcp_LDADD = @LTLIBINTL@ $(NETLIBS) $(LIB_CRYPTO)
|
||||
check_icmp_LDADD = @LTLIBINTL@ $(NETLIBS) $(SOCKETLIBS) $(LIB_CRYPTO)
|
||||
|
||||
# -m64 needed at compiler and linker phase
|
||||
pst3_CFLAGS = @PST3CFLAGS@
|
||||
|
@ -2300,7 +2298,6 @@ recheck: all
|
|||
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
||||
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
|
||||
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
|
|
@ -497,7 +497,7 @@ int send_dhcp_discover(int sock){
|
|||
memcpy(&discover_packet.options[opts],&requested_address,sizeof(requested_address));
|
||||
opts += sizeof(requested_address);
|
||||
}
|
||||
discover_packet.options[opts++]=DHCP_OPTION_END;
|
||||
discover_packet.options[opts++]= (char)DHCP_OPTION_END;
|
||||
|
||||
/* unicast fields */
|
||||
if(unicast)
|
||||
|
|
|
@ -1547,46 +1547,66 @@ finish(int sig)
|
|||
while(host) {
|
||||
if(debug) puts("");
|
||||
|
||||
if (rta_mode && host->pl<100) {
|
||||
printf("%srta=%0.3fms;%0.3f;%0.3f;0; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",
|
||||
(targets > 1) ? host->name : "",
|
||||
host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000,
|
||||
(targets > 1) ? host->name : "", (float)host->rtmax / 1000,
|
||||
(targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0);
|
||||
if (rta_mode) {
|
||||
if (host->pl<100) {
|
||||
printf("%srta=%0.3fms;%0.3f;%0.3f;0; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",
|
||||
(targets > 1) ? host->name : "",
|
||||
host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000,
|
||||
(targets > 1) ? host->name : "", (float)host->rtmax / 1000,
|
||||
(targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0);
|
||||
} else {
|
||||
printf("%srta=U;;;; %srtmax=U;;;; %srtmin=U;;;; ",
|
||||
(targets > 1) ? host->name : "",
|
||||
(targets > 1) ? host->name : "",
|
||||
(targets > 1) ? host->name : "");
|
||||
}
|
||||
}
|
||||
|
||||
if (pl_mode) {
|
||||
printf("%spl=%u%%;%u;%u;0;100 ", (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl);
|
||||
}
|
||||
|
||||
if (jitter_mode && host->pl<100) {
|
||||
printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; %sjitter_min=%0.3fms;;;; ",
|
||||
(targets > 1) ? host->name : "",
|
||||
(float)host->jitter,
|
||||
(float)warn.jitter,
|
||||
(float)crit.jitter,
|
||||
(targets > 1) ? host->name : "",
|
||||
(float)host->jitter_max / 1000, (targets > 1) ? host->name : "",
|
||||
(float)host->jitter_min / 1000
|
||||
);
|
||||
if (jitter_mode) {
|
||||
if (host->pl<100) {
|
||||
printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; %sjitter_min=%0.3fms;;;; ",
|
||||
(targets > 1) ? host->name : "",
|
||||
(float)host->jitter,
|
||||
(float)warn.jitter,
|
||||
(float)crit.jitter,
|
||||
(targets > 1) ? host->name : "",
|
||||
(float)host->jitter_max / 1000, (targets > 1) ? host->name : "",
|
||||
(float)host->jitter_min / 1000
|
||||
);
|
||||
} else {
|
||||
printf("%sjitter_avg=U;;;; %sjitter_max=U;;;; %sjitter_min=U;;;; ",
|
||||
(targets > 1) ? host->name : "",
|
||||
(targets > 1) ? host->name : "",
|
||||
(targets > 1) ? host->name : "");
|
||||
}
|
||||
}
|
||||
|
||||
if (mos_mode && host->pl<100) {
|
||||
printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ",
|
||||
(targets > 1) ? host->name : "",
|
||||
(float)host->mos,
|
||||
(float)warn.mos,
|
||||
(float)crit.mos
|
||||
);
|
||||
if (mos_mode) {
|
||||
if (host->pl<100) {
|
||||
printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ",
|
||||
(targets > 1) ? host->name : "",
|
||||
(float)host->mos,
|
||||
(float)warn.mos,
|
||||
(float)crit.mos);
|
||||
} else {
|
||||
printf("%smos=U;;;; ", (targets > 1) ? host->name : "");
|
||||
}
|
||||
}
|
||||
|
||||
if (score_mode && host->pl<100) {
|
||||
printf("%sscore=%u;%u;%u;0;100 ",
|
||||
(targets > 1) ? host->name : "",
|
||||
(int)host->score,
|
||||
(int)warn.score,
|
||||
(int)crit.score
|
||||
);
|
||||
if (score_mode) {
|
||||
if (host->pl<100) {
|
||||
printf("%sscore=%u;%u;%u;0;100 ",
|
||||
(targets > 1) ? host->name : "",
|
||||
(int)host->score,
|
||||
(int)warn.score,
|
||||
(int)crit.score);
|
||||
} else {
|
||||
printf("%sscore=U;;;; ", (targets > 1) ? host->name : "");
|
||||
}
|
||||
}
|
||||
|
||||
host = host->next;
|
||||
|
|
|
@ -12,7 +12,7 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO",
|
|||
"no" );
|
||||
|
||||
if ($allow_sudo eq "yes" or $> == 0) {
|
||||
plan tests => 39;
|
||||
plan tests => 40;
|
||||
} else {
|
||||
plan skip_all => "Need sudo to test check_icmp";
|
||||
}
|
||||
|
@ -57,7 +57,8 @@ $res = NPTest->testCmd(
|
|||
"$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -t 2"
|
||||
);
|
||||
is( $res->return_code, 2, "Timeout - host nonresponsive" );
|
||||
like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" );
|
||||
like( $res->output, '/pl=100%/', "Error contains 'pl=100%' string (for 100% packet loss)" );
|
||||
like( $res->output, '/rta=U/', "Error contains 'rta=U' string" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -163,8 +163,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/nocrash.m4 $(top_srcdir)/gl/m4/off_t.m4 \
|
||||
$(top_srcdir)/gl/m4/open-cloexec.m4 \
|
||||
$(top_srcdir)/gl/m4/open-slash.m4 $(top_srcdir)/gl/m4/open.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/pid_t.m4 \
|
||||
$(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pthread_rwlock_rdlock.m4 \
|
||||
$(top_srcdir)/gl/m4/realloc.m4 \
|
||||
$(top_srcdir)/gl/m4/reallocarray.m4 \
|
||||
|
@ -177,7 +176,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/sockets.m4 $(top_srcdir)/gl/m4/socklen.m4 \
|
||||
$(top_srcdir)/gl/m4/sockpfaf.m4 $(top_srcdir)/gl/m4/ssize_t.m4 \
|
||||
$(top_srcdir)/gl/m4/stat-time.m4 $(top_srcdir)/gl/m4/stat.m4 \
|
||||
$(top_srcdir)/gl/m4/std-gnu11.m4 \
|
||||
$(top_srcdir)/gl/m4/stdalign.m4 \
|
||||
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
|
||||
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
|
||||
|
@ -195,7 +193,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/time_r.m4 $(top_srcdir)/gl/m4/timegm.m4 \
|
||||
$(top_srcdir)/gl/m4/ungetc.m4 $(top_srcdir)/gl/m4/unistd_h.m4 \
|
||||
$(top_srcdir)/gl/m4/unlocked-io.m4 \
|
||||
$(top_srcdir)/gl/m4/vararrays.m4 \
|
||||
$(top_srcdir)/gl/m4/vasnprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/vasprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/visibility.m4 \
|
||||
|
@ -469,6 +466,8 @@ CFLAGS = @CFLAGS@
|
|||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DBILIBS = @DBILIBS@
|
||||
DEFS = @DEFS@
|
||||
|
@ -488,6 +487,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
|
|||
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
|
||||
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
|
||||
ERRNO_H = @ERRNO_H@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTRAS = @EXTRAS@
|
||||
EXTRAS_ROOT = @EXTRAS_ROOT@
|
||||
|
@ -1859,6 +1859,8 @@ install_sh = @install_sh@
|
|||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localedir_c = @localedir_c@
|
||||
localedir_c_make = @localedir_c_make@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
|
@ -2141,7 +2143,6 @@ recheck: all
|
|||
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
||||
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
|
||||
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
|
|
@ -40,15 +40,16 @@
|
|||
|
||||
# ----------------------------------------------------------------[ Require ]--
|
||||
|
||||
require 5.004;
|
||||
require 5.14.0;
|
||||
|
||||
# -------------------------------------------------------------------[ Uses ]--
|
||||
|
||||
use Socket;
|
||||
use strict;
|
||||
use IO::Socket::IP;
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose);
|
||||
use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $opt_4 $opt_6 $verbose);
|
||||
use vars qw($PROGNAME);
|
||||
use vars qw($ClientSocket);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
|
||||
|
@ -58,7 +59,6 @@ use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
|
|||
sub print_help ();
|
||||
sub print_usage ();
|
||||
sub connection ($$$$);
|
||||
sub bindRemote ($$);
|
||||
|
||||
# -------------------------------------------------------------[ Environment ]--
|
||||
|
||||
|
@ -104,7 +104,7 @@ sub connection ($$$$)
|
|||
$answer = "Server $in_remotehost has less than 0 users! Something is Really WRONG!\n";
|
||||
}
|
||||
|
||||
print ClientSocket "quit\n";
|
||||
print $ClientSocket "quit\n";
|
||||
print $answer;
|
||||
exit $ERRORS{$state};
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ sub connection ($$$$)
|
|||
# ------------------------------------------------------------[ print_usage ]--
|
||||
|
||||
sub print_usage () {
|
||||
print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>] [-p <port>]\n";
|
||||
print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>] [-p <port>] [ -4|-6 ]\n";
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------[ print_help ]--
|
||||
|
@ -135,33 +135,15 @@ Perl Check IRCD plugin for monitoring
|
|||
Number of connected users which generates a critical state (Default: 100)
|
||||
-p, --port=INTEGER
|
||||
Port that the ircd daemon is running on <host> (Default: 6667)
|
||||
-4, --use-ipv4
|
||||
Use IPv4 connection
|
||||
-6, --use-ipv6
|
||||
Use IPv6 connection
|
||||
-v, --verbose
|
||||
Print extra debugging information
|
||||
";
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------[ bindRemote ]--
|
||||
|
||||
sub bindRemote ($$)
|
||||
{
|
||||
my ($in_remotehost, $in_remoteport) = @_;
|
||||
my $proto = getprotobyname('tcp');
|
||||
my $that;
|
||||
my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost);
|
||||
|
||||
if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) {
|
||||
print "IRCD UNKNOWN: Could not start socket ($!)\n";
|
||||
exit $ERRORS{"UNKNOWN"};
|
||||
}
|
||||
$that = pack_sockaddr_in ($in_remoteport, $thataddr);
|
||||
if (!connect(ClientSocket, $that)) {
|
||||
print "IRCD UNKNOWN: Could not connect socket ($!)\n";
|
||||
exit $ERRORS{"UNKNOWN"};
|
||||
}
|
||||
select(ClientSocket); $| = 1; select(STDOUT);
|
||||
return \*ClientSocket;
|
||||
}
|
||||
|
||||
# ===================================================================[ MAIN ]==
|
||||
|
||||
MAIN:
|
||||
|
@ -177,6 +159,8 @@ MAIN:
|
|||
"w=i" => \$opt_w, "warning=i" => \$opt_w,
|
||||
"c=i" => \$opt_c, "critical=i" => \$opt_c,
|
||||
"p=i" => \$opt_p, "port=i" => \$opt_p,
|
||||
"4" => \$opt_4, "use-ipv4" => \$opt_4,
|
||||
"6" => \$opt_6, "use-ipv6" => \$opt_6,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
|
@ -187,7 +171,7 @@ MAIN:
|
|||
if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};}
|
||||
|
||||
($opt_H) || ($opt_H = shift @ARGV) || usage("Host name/address not specified\n");
|
||||
my $remotehost = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
|
||||
my $remotehost = $1 if ($opt_H =~ /([-.:%A-Za-z0-9]+)/);
|
||||
($remotehost) || usage("Invalid host: $opt_H\n");
|
||||
|
||||
($opt_w) || ($opt_w = shift @ARGV) || ($opt_w = 50);
|
||||
|
@ -212,21 +196,28 @@ MAIN:
|
|||
|
||||
alarm($TIMEOUT);
|
||||
|
||||
my ($name, $alias, $proto) = getprotobyname('tcp');
|
||||
|
||||
print "MAIN(debug): binding to remote host: $remotehost -> $remoteport\n" if $verbose;
|
||||
my $ClientSocket = &bindRemote($remotehost,$remoteport);
|
||||
$ClientSocket = IO::Socket::IP->new(
|
||||
PeerHost => $remotehost,
|
||||
PeerService => $remoteport,
|
||||
Family => $opt_4 ? AF_INET : $opt_6 ? AF_INET6 : undef,
|
||||
Type => SOCK_STREAM,
|
||||
);
|
||||
if (!$ClientSocket) {
|
||||
print "IRCD UNKNOWN: Could not start socket ($!)\n";
|
||||
exit $ERRORS{"UNKNOWN"};
|
||||
}
|
||||
|
||||
print ClientSocket "NICK $NICK\nUSER $USER_INFO\n";
|
||||
print $ClientSocket "NICK $NICK\nUSER $USER_INFO\n";
|
||||
|
||||
while (<ClientSocket>) {
|
||||
while (<$ClientSocket>) {
|
||||
print "MAIN(debug): default var = $_\n" if $verbose;
|
||||
|
||||
# DALnet,LagNet,UnderNet etc. Require this!
|
||||
# Replies with a PONG when presented with a PING query.
|
||||
# If a server doesn't require it, it will be ignored.
|
||||
|
||||
if (m/^PING (.*)/) {print ClientSocket "PONG $1\n";}
|
||||
if (m/^PING (.*)/) {print $ClientSocket "PONG $1\n";}
|
||||
|
||||
alarm(0);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -47,7 +47,7 @@ print_help() {
|
|||
echo "--cache"
|
||||
echo " Check local database for library and buffer cache hit ratios"
|
||||
echo " ---> Requires Oracle user/password and SID specified."
|
||||
echo " ---> Requires select on v_$sysstat and v_$librarycache"
|
||||
echo " ---> Requires select on v_\$sysstat and v_\$librarycache"
|
||||
echo "--tablespace"
|
||||
echo " Check local database for tablespace capacity in ORACLE_SID"
|
||||
echo " ---> Requires Oracle user/password specified."
|
||||
|
@ -109,14 +109,14 @@ if [ -z "$ORACLE_HOME" ] ; then
|
|||
for oratab in /var/opt/oracle/oratab /etc/oratab
|
||||
do
|
||||
[ ! -f $oratab ] && continue
|
||||
ORACLE_HOME=`IFS=:
|
||||
while read -r SID ORACLE_HOME junk;
|
||||
ORACLE_HOME=$(IFS=:
|
||||
while read -r SID ORACLE_HOME _;
|
||||
do
|
||||
if [ "$SID" = "$2" ] || [ "$SID" = "*" ] ; then
|
||||
echo "$ORACLE_HOME";
|
||||
exit;
|
||||
fi;
|
||||
done < $oratab`
|
||||
done < $oratab)
|
||||
[ -n "$ORACLE_HOME" ] && break
|
||||
done
|
||||
fi
|
||||
|
@ -209,7 +209,7 @@ case "$cmd" in
|
|||
echo "UNKNOWN - Warning level is less then Crit"
|
||||
exit "$STATE_UNKNOWN"
|
||||
fi
|
||||
result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
|
||||
result=$(sqlplus -s "${3}"/"${4}"@"${2}" << EOF
|
||||
set pagesize 0
|
||||
set numf '9999999.99'
|
||||
select (1-(pr.value/(dbg.value+cg.value)))*100
|
||||
|
@ -217,7 +217,8 @@ from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg
|
|||
where pr.name='physical reads'
|
||||
and dbg.name='db block gets'
|
||||
and cg.name='consistent gets';
|
||||
EOF`
|
||||
EOF
|
||||
)
|
||||
|
||||
if echo "$result" | grep -q 'ORA-' ; then
|
||||
error=$(echo "$result" | grep "ORA-" | head -1)
|
||||
|
@ -227,12 +228,13 @@ EOF`
|
|||
|
||||
buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
|
||||
buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
|
||||
result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
|
||||
result=$(sqlplus -s "${3}"/"${4}"@"${2}" << EOF
|
||||
set pagesize 0
|
||||
set numf '9999999.99'
|
||||
select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
|
||||
from v\\$librarycache lc;
|
||||
EOF`
|
||||
EOF
|
||||
)
|
||||
|
||||
if echo "$result" | grep -q 'ORA-' ; then
|
||||
error=$(echo "$result" | grep "ORA-" | head -1)
|
||||
|
@ -260,7 +262,7 @@ EOF`
|
|||
echo "UNKNOWN - Warning level is more then Crit"
|
||||
exit "$STATE_UNKNOWN"
|
||||
fi
|
||||
result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
|
||||
result=$(sqlplus -s "${3}"/"${4}"@"${2}" << EOF
|
||||
set pagesize 0
|
||||
set numf '9999999.99'
|
||||
select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
|
||||
|
@ -271,7 +273,8 @@ LEFT OUTER JOIN
|
|||
( select tablespace_name,sum(bytes)/1024/1024 free
|
||||
from dba_free_space group by tablespace_name) B
|
||||
ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
|
||||
EOF`
|
||||
EOF
|
||||
)
|
||||
|
||||
if echo "$result" | grep -q 'ORA-' ; then
|
||||
error=$(echo "$result" | grep "ORA-" | head -1)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -182,8 +182,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/nocrash.m4 $(top_srcdir)/gl/m4/off_t.m4 \
|
||||
$(top_srcdir)/gl/m4/open-cloexec.m4 \
|
||||
$(top_srcdir)/gl/m4/open-slash.m4 $(top_srcdir)/gl/m4/open.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/pid_t.m4 \
|
||||
$(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pathmax.m4 $(top_srcdir)/gl/m4/printf.m4 \
|
||||
$(top_srcdir)/gl/m4/pthread_rwlock_rdlock.m4 \
|
||||
$(top_srcdir)/gl/m4/realloc.m4 \
|
||||
$(top_srcdir)/gl/m4/reallocarray.m4 \
|
||||
|
@ -196,7 +195,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/sockets.m4 $(top_srcdir)/gl/m4/socklen.m4 \
|
||||
$(top_srcdir)/gl/m4/sockpfaf.m4 $(top_srcdir)/gl/m4/ssize_t.m4 \
|
||||
$(top_srcdir)/gl/m4/stat-time.m4 $(top_srcdir)/gl/m4/stat.m4 \
|
||||
$(top_srcdir)/gl/m4/std-gnu11.m4 \
|
||||
$(top_srcdir)/gl/m4/stdalign.m4 \
|
||||
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
|
||||
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
|
||||
|
@ -214,7 +212,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
|
|||
$(top_srcdir)/gl/m4/time_r.m4 $(top_srcdir)/gl/m4/timegm.m4 \
|
||||
$(top_srcdir)/gl/m4/ungetc.m4 $(top_srcdir)/gl/m4/unistd_h.m4 \
|
||||
$(top_srcdir)/gl/m4/unlocked-io.m4 \
|
||||
$(top_srcdir)/gl/m4/vararrays.m4 \
|
||||
$(top_srcdir)/gl/m4/vasnprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/vasprintf.m4 \
|
||||
$(top_srcdir)/gl/m4/visibility.m4 \
|
||||
|
@ -520,8 +517,6 @@ am__define_uniq_tagged_files = \
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__tty_colors_dummy = \
|
||||
mgn= red= grn= lgn= blu= brg= std=; \
|
||||
am__color_tests=no
|
||||
|
@ -782,6 +777,8 @@ CFLAGS = @CFLAGS@
|
|||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DBILIBS = @DBILIBS@
|
||||
# gettext docs say to use AM_CPPFLAGS, but per module_CPPFLAGS override this
|
||||
|
@ -802,6 +799,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
|
|||
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
|
||||
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
|
||||
ERRNO_H = @ERRNO_H@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTRAS = @EXTRAS@
|
||||
EXTRAS_ROOT = @EXTRAS_ROOT@
|
||||
|
@ -2174,6 +2172,8 @@ install_sh = @install_sh@
|
|||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = $(datadir)/locale
|
||||
localedir_c = @localedir_c@
|
||||
localedir_c_make = @localedir_c_make@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
|
@ -2908,7 +2908,6 @@ recheck: all
|
|||
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
||||
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
|
||||
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ 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, i=0;
|
||||
int result=STATE_UNKNOWN, packages_available=0, sec_count=0;
|
||||
char **packages_list=NULL, **secpackages_list=NULL;
|
||||
|
||||
/* Parse extra opts if any */
|
||||
|
@ -142,10 +142,11 @@ int main (int argc, char **argv) {
|
|||
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++)
|
||||
for(int i = 0; i < sec_count; i++)
|
||||
printf("%s (security)\n", secpackages_list[i]);
|
||||
|
||||
if (only_critical == false) {
|
||||
for(i = 0; i < packages_available - sec_count; i++)
|
||||
for(int i = 0; i < packages_available - sec_count; i++)
|
||||
printf("%s\n", packages_list[i]);
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +252,7 @@ int process_arguments (int argc, char **argv) {
|
|||
|
||||
/* run an apt-get upgrade */
|
||||
int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist){
|
||||
int i=0, result=STATE_UNKNOWN, regres=0, pc=0, spc=0;
|
||||
int result=STATE_UNKNOWN, regres=0, pc=0, spc=0;
|
||||
struct output chld_out, chld_err;
|
||||
regex_t ireg, ereg, sreg;
|
||||
char *cmdline=NULL, rerrbuf[64];
|
||||
|
@ -320,7 +321,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
|
|||
* we may need to switch to the --print-uris output format,
|
||||
* in which case the logic here will slightly change.
|
||||
*/
|
||||
for(i = 0; i < chld_out.lines; i++) {
|
||||
for(size_t i = 0; i < chld_out.lines; i++) {
|
||||
if(verbose){
|
||||
printf("%s\n", chld_out.line[i]);
|
||||
}
|
||||
|
@ -353,7 +354,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
|
|||
stderr_warning=1;
|
||||
result = max_state(result, STATE_WARNING);
|
||||
if(verbose){
|
||||
for(i = 0; i < chld_err.lines; i++) {
|
||||
for(size_t i = 0; i < chld_err.lines; i++) {
|
||||
fprintf(stderr, "%s\n", chld_err.line[i]);
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +368,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
|
|||
|
||||
/* run an apt-get update (needs root) */
|
||||
int run_update(void){
|
||||
int i=0, result=STATE_UNKNOWN;
|
||||
int result=STATE_UNKNOWN;
|
||||
struct output chld_out, chld_err;
|
||||
char *cmdline;
|
||||
|
||||
|
@ -385,7 +386,7 @@ int run_update(void){
|
|||
}
|
||||
|
||||
if(verbose){
|
||||
for(i = 0; i < chld_out.lines; i++) {
|
||||
for(size_t i = 0; i < chld_out.lines; i++) {
|
||||
printf("%s\n", chld_out.line[i]);
|
||||
}
|
||||
}
|
||||
|
@ -395,7 +396,7 @@ int run_update(void){
|
|||
stderr_warning=1;
|
||||
result = max_state(result, STATE_WARNING);
|
||||
if(verbose){
|
||||
for(i = 0; i < chld_err.lines; i++) {
|
||||
for(size_t i = 0; i < chld_err.lines; i++) {
|
||||
fprintf(stderr, "%s\n", chld_err.line[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ unsigned int services = 0;
|
|||
int skip_stdout = 0;
|
||||
int skip_stderr = 0;
|
||||
int warn_on_stderr = 0;
|
||||
bool unknown_timeout = FALSE;
|
||||
bool unknown_timeout = false;
|
||||
char *remotecmd = NULL;
|
||||
char **commargv = NULL;
|
||||
int commargc = 0;
|
||||
|
@ -58,8 +58,8 @@ char *hostname = NULL;
|
|||
char *outputfile = NULL;
|
||||
char *host_shortname = NULL;
|
||||
char **service;
|
||||
int passive = FALSE;
|
||||
int verbose = FALSE;
|
||||
bool passive = false;
|
||||
bool verbose = false;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -68,7 +68,6 @@ main (int argc, char **argv)
|
|||
char *status_text;
|
||||
int cresult;
|
||||
int result = STATE_UNKNOWN;
|
||||
int i;
|
||||
time_t local_time;
|
||||
FILE *fp = NULL;
|
||||
output chld_out, chld_err;
|
||||
|
@ -96,7 +95,7 @@ main (int argc, char **argv)
|
|||
/* run the command */
|
||||
if (verbose) {
|
||||
printf ("Command: %s\n", commargv[0]);
|
||||
for (i=1; i<commargc; i++)
|
||||
for (int i = 1; i < commargc; i++)
|
||||
printf ("Argument %i: %s\n", i, commargv[i]);
|
||||
}
|
||||
|
||||
|
@ -110,9 +109,9 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
if (verbose) {
|
||||
for(i = 0; i < chld_out.lines; i++)
|
||||
for(size_t i = 0; i < chld_out.lines; i++)
|
||||
printf("stdout: %s\n", chld_out.line[i]);
|
||||
for(i = 0; i < chld_err.lines; i++)
|
||||
for(size_t i = 0; i < chld_err.lines; i++)
|
||||
printf("stderr: %s\n", chld_err.line[i]);
|
||||
}
|
||||
|
||||
|
@ -122,7 +121,7 @@ main (int argc, char **argv)
|
|||
skip_stderr = chld_err.lines;
|
||||
|
||||
/* UNKNOWN or worse if (non-skipped) output found on stderr */
|
||||
if(chld_err.lines > skip_stderr) {
|
||||
if(chld_err.lines > (size_t)skip_stderr) {
|
||||
printf (_("Remote command execution failed: %s\n"),
|
||||
chld_err.line[skip_stderr]);
|
||||
if ( warn_on_stderr )
|
||||
|
@ -134,8 +133,8 @@ main (int argc, char **argv)
|
|||
/* this is simple if we're not supposed to be passive.
|
||||
* Wrap up quickly and keep the tricks below */
|
||||
if(!passive) {
|
||||
if (chld_out.lines > skip_stdout)
|
||||
for (i = skip_stdout; i < chld_out.lines; i++)
|
||||
if (chld_out.lines > (size_t)skip_stdout)
|
||||
for (size_t i = skip_stdout; i < chld_out.lines; i++)
|
||||
puts (chld_out.line[i]);
|
||||
else
|
||||
printf (_("%s - check_by_ssh: Remote command '%s' returned status %d\n"),
|
||||
|
@ -156,7 +155,7 @@ main (int argc, char **argv)
|
|||
|
||||
local_time = time (NULL);
|
||||
commands = 0;
|
||||
for(i = skip_stdout; i < chld_out.lines; i++) {
|
||||
for(size_t i = skip_stdout; i < chld_out.lines; i++) {
|
||||
status_text = chld_out.line[i++];
|
||||
if (i == chld_out.lines || strstr (chld_out.line[i], "STATUS CODE: ") == NULL)
|
||||
die (STATE_UNKNOWN, _("%s: Error parsing output\n"), progname);
|
||||
|
@ -235,7 +234,7 @@ process_arguments (int argc, char **argv)
|
|||
print_help ();
|
||||
exit (STATE_UNKNOWN);
|
||||
case 'v': /* help */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 't': /* timeout period */
|
||||
if (!is_integer (optarg))
|
||||
|
@ -244,7 +243,7 @@ process_arguments (int argc, char **argv)
|
|||
timeout_interval = atoi (optarg);
|
||||
break;
|
||||
case 'U':
|
||||
unknown_timeout = TRUE;
|
||||
unknown_timeout = true;
|
||||
break;
|
||||
case 'H': /* host */
|
||||
hostname = optarg;
|
||||
|
@ -257,7 +256,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'O': /* output file */
|
||||
outputfile = optarg;
|
||||
passive = TRUE;
|
||||
passive = true;
|
||||
break;
|
||||
case 's': /* description of service to check */
|
||||
p1 = optarg;
|
||||
|
|
|
@ -134,6 +134,7 @@ char regexp[MAX_RE_SIZE];
|
|||
int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE;
|
||||
int errcode;
|
||||
bool invert_regex = false;
|
||||
int state_regex = STATE_CRITICAL;
|
||||
|
||||
char *server_address = NULL;
|
||||
char *host_name = NULL;
|
||||
|
@ -223,6 +224,7 @@ curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN;
|
|||
int curl_http_version = CURL_HTTP_VERSION_NONE;
|
||||
bool automatic_decompression = false;
|
||||
char *cookie_jar_file = NULL;
|
||||
bool haproxy_protocol = false;
|
||||
|
||||
bool process_arguments (int, char**);
|
||||
void handle_curl_option_return_code (CURLcode res, const char* option);
|
||||
|
@ -395,7 +397,7 @@ lookup_host (const char *host, char *buf, size_t buflen)
|
|||
char addrstr[100];
|
||||
size_t addrstr_len;
|
||||
int errcode;
|
||||
void *ptr;
|
||||
void *ptr = { 0 };
|
||||
size_t buflen_remaining = buflen - 1;
|
||||
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
|
@ -520,6 +522,11 @@ check_http (void)
|
|||
handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, socket_timeout), "CURLOPT_CONNECTTIMEOUT");
|
||||
handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_TIMEOUT, socket_timeout), "CURLOPT_TIMEOUT");
|
||||
|
||||
/* enable haproxy protocol */
|
||||
if (haproxy_protocol) {
|
||||
handle_curl_option_return_code(curl_easy_setopt(curl, CURLOPT_HAPROXYPROTOCOL, 1L), "CURLOPT_HAPROXYPROTOCOL");
|
||||
}
|
||||
|
||||
// fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy
|
||||
if(use_ssl && host_name != NULL) {
|
||||
if ( (res=lookup_host (server_address, addrstr, DEFAULT_BUFFER_SIZE/2)) != 0) {
|
||||
|
@ -1127,7 +1134,7 @@ GOT_FIRST_CERT:
|
|||
strcpy(msg, tmp);
|
||||
|
||||
}
|
||||
result = STATE_CRITICAL;
|
||||
result = state_regex;
|
||||
} else {
|
||||
regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
|
||||
|
||||
|
@ -1186,16 +1193,16 @@ int
|
|||
uri_strcmp (const UriTextRangeA range, const char* s)
|
||||
{
|
||||
if (!range.first) return -1;
|
||||
if (range.afterLast - range.first < strlen (s)) return -1;
|
||||
return strncmp (s, range.first, min( range.afterLast - range.first, strlen (s)));
|
||||
if ( (size_t)(range.afterLast - range.first) < strlen (s) ) return -1;
|
||||
return strncmp (s, range.first, min( (size_t)(range.afterLast - range.first), strlen (s)));
|
||||
}
|
||||
|
||||
char*
|
||||
uri_string (const UriTextRangeA range, char* buf, size_t buflen)
|
||||
{
|
||||
if (!range.first) return "(null)";
|
||||
strncpy (buf, range.first, max (buflen-1, range.afterLast - range.first));
|
||||
buf[max (buflen-1, range.afterLast - range.first)] = '\0';
|
||||
strncpy (buf, range.first, max (buflen-1, (size_t)(range.afterLast - range.first)));
|
||||
buf[max (buflen-1, (size_t)(range.afterLast - range.first))] = '\0';
|
||||
buf[range.afterLast - range.first] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
@ -1384,7 +1391,9 @@ process_arguments (int argc, char **argv)
|
|||
CA_CERT_OPTION,
|
||||
HTTP_VERSION_OPTION,
|
||||
AUTOMATIC_DECOMPRESSION,
|
||||
COOKIE_JAR
|
||||
COOKIE_JAR,
|
||||
HAPROXY_PROTOCOL,
|
||||
STATE_REGEX
|
||||
};
|
||||
|
||||
int option = 0;
|
||||
|
@ -1423,6 +1432,7 @@ process_arguments (int argc, char **argv)
|
|||
{"content-type", required_argument, 0, 'T'},
|
||||
{"pagesize", required_argument, 0, 'm'},
|
||||
{"invert-regex", no_argument, NULL, INVERT_REGEX},
|
||||
{"state-regex", required_argument, 0, STATE_REGEX},
|
||||
{"use-ipv4", no_argument, 0, '4'},
|
||||
{"use-ipv6", no_argument, 0, '6'},
|
||||
{"extended-perfdata", no_argument, 0, 'E'},
|
||||
|
@ -1431,6 +1441,7 @@ process_arguments (int argc, char **argv)
|
|||
{"http-version", required_argument, 0, HTTP_VERSION_OPTION},
|
||||
{"enable-automatic-decompression", no_argument, 0, AUTOMATIC_DECOMPRESSION},
|
||||
{"cookie-jar", required_argument, 0, COOKIE_JAR},
|
||||
{"haproxy-protocol", no_argument, 0, HAPROXY_PROTOCOL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -1757,6 +1768,13 @@ process_arguments (int argc, char **argv)
|
|||
case INVERT_REGEX:
|
||||
invert_regex = true;
|
||||
break;
|
||||
case STATE_REGEX:
|
||||
if (!strcmp (optarg, "critical"))
|
||||
state_regex = STATE_CRITICAL;
|
||||
else if (!strcmp (optarg, "warning"))
|
||||
state_regex = STATE_WARNING;
|
||||
else usage2 (_("Invalid state-regex option"), optarg);
|
||||
break;
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
|
@ -1841,6 +1859,9 @@ process_arguments (int argc, char **argv)
|
|||
case COOKIE_JAR:
|
||||
cookie_jar_file = optarg;
|
||||
break;
|
||||
case HAPROXY_PROTOCOL:
|
||||
haproxy_protocol = true;
|
||||
break;
|
||||
case '?':
|
||||
/* print short usage statement if args not parsable */
|
||||
usage5 ();
|
||||
|
@ -2011,7 +2032,7 @@ print_help (void)
|
|||
printf (" %s\n", "-u, --url=PATH");
|
||||
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", _("URL decoded http POST data"));
|
||||
printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)");
|
||||
printf (" %s\n", _("Set HTTP method."));
|
||||
printf (" %s\n", "-N, --no-body");
|
||||
|
@ -2029,7 +2050,10 @@ print_help (void)
|
|||
printf (" %s\n", "-R, --eregi=STRING");
|
||||
printf (" %s\n", _("Search page for case-insensitive regex STRING"));
|
||||
printf (" %s\n", "--invert-regex");
|
||||
printf (" %s\n", _("Return CRITICAL if found, OK if not\n"));
|
||||
printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)"));
|
||||
printf (" %s\n", _("can be changed with --state--regex)"));
|
||||
printf (" %s\n", "--regex-state=STATE");
|
||||
printf (" %s\n", _("Return STATE if regex is found, OK if not\n"));
|
||||
printf (" %s\n", "-a, --authorization=AUTH_PAIR");
|
||||
printf (" %s\n", _("Username:password on sites with basic authentication"));
|
||||
printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR");
|
||||
|
@ -2060,6 +2084,8 @@ print_help (void)
|
|||
printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)"));
|
||||
printf (" %s\n", "--enable-automatic-decompression");
|
||||
printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING)."));
|
||||
printf(" %s\n", "--haproxy-protocol");
|
||||
printf(" %s\n", _("Send HAProxy proxy protocol v1 header (CURLOPT_HAPROXYPROTOCOL)."));
|
||||
printf (" %s\n", "---cookie-jar=FILE");
|
||||
printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested."));
|
||||
printf ("\n");
|
||||
|
@ -2144,7 +2170,7 @@ print_usage (void)
|
|||
printf (" [-b proxy_auth] [-f <ok|warning|critical|follow|sticky|stickyport|curl>]\n");
|
||||
printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
|
||||
printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
|
||||
printf (" [-A string] [-k string] [-S <version>] [--sni]\n");
|
||||
printf (" [-A string] [-k string] [-S <version>] [--sni] [--haproxy-protocol]\n");
|
||||
printf (" [-T <content-type>] [-j method]\n");
|
||||
printf (" [--http-version=<version>] [--enable-automatic-decompression]\n");
|
||||
printf (" [--cookie-jar=<cookie jar file>\n");
|
||||
|
@ -2368,8 +2394,7 @@ remove_newlines (char *s)
|
|||
char *
|
||||
get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < nof_headers; i++ ) {
|
||||
for(size_t i = 0; i < nof_headers; i++ ) {
|
||||
if(headers[i].name != NULL && strncasecmp( header, headers[i].name, max( headers[i].name_len, 4 ) ) == 0 ) {
|
||||
return strndup( headers[i].value, headers[i].value_len );
|
||||
}
|
||||
|
@ -2471,7 +2496,7 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA
|
|||
int
|
||||
get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf)
|
||||
{
|
||||
int content_length = 0;
|
||||
size_t content_length = 0;
|
||||
struct phr_header headers[255];
|
||||
size_t nof_headers = 255;
|
||||
size_t msglen;
|
||||
|
|
|
@ -141,7 +141,7 @@ main (int argc, char **argv)
|
|||
if (verbose > 2)
|
||||
printf ("Initializing DBI\n");
|
||||
|
||||
dbi_inst *instance_p;
|
||||
dbi_inst *instance_p = { 0 };
|
||||
|
||||
if (dbi_initialize_r(NULL, instance_p) < 0) {
|
||||
printf ("UNKNOWN - failed to initialize DBI; possibly you don't have any drivers installed.\n");
|
||||
|
|
|
@ -56,7 +56,7 @@ char *expected_address = NULL;
|
|||
char *dns_server = NULL;
|
||||
char *dig_args = "";
|
||||
char *query_transport = "";
|
||||
int verbose = FALSE;
|
||||
bool verbose = false;
|
||||
int server_port = DEFAULT_PORT;
|
||||
int number_tries = DEFAULT_TRIES;
|
||||
double warning_interval = UNDEFINED;
|
||||
|
@ -176,11 +176,11 @@ main (int argc, char **argv)
|
|||
state_text (result), elapsed_time,
|
||||
msg ? msg : _("Probably a non-existent host/domain"),
|
||||
fperfdata("time", elapsed_time, "s",
|
||||
(warning_interval>UNDEFINED?TRUE:FALSE),
|
||||
(warning_interval>UNDEFINED ? true:false),
|
||||
warning_interval,
|
||||
(critical_interval>UNDEFINED?TRUE:FALSE),
|
||||
(critical_interval>UNDEFINED ? true:false),
|
||||
critical_interval,
|
||||
TRUE, 0, FALSE, 0));
|
||||
true, 0, false, 0));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ process_arguments (int argc, char **argv)
|
|||
dig_args = strdup(optarg);
|
||||
break;
|
||||
case 'v': /* verbose */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 'T':
|
||||
record_type = optarg;
|
||||
|
|
|
@ -46,7 +46,7 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
#include <stdarg.h>
|
||||
#include "fsusage.h"
|
||||
#include "mountlist.h"
|
||||
#include "intprops.h" /* necessary for TYPE_MAXIMUM */
|
||||
#include <float.h>
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
@ -112,8 +112,7 @@ enum
|
|||
{
|
||||
SYNC_OPTION = CHAR_MAX + 1,
|
||||
NO_SYNC_OPTION,
|
||||
BLOCK_SIZE_OPTION,
|
||||
IGNORE_MISSING
|
||||
BLOCK_SIZE_OPTION
|
||||
};
|
||||
|
||||
#ifdef _AIX
|
||||
|
@ -135,12 +134,12 @@ char *exclude_device;
|
|||
char *units;
|
||||
uintmax_t mult = 1024 * 1024;
|
||||
int verbose = 0;
|
||||
int erronly = FALSE;
|
||||
int display_mntp = FALSE;
|
||||
int exact_match = FALSE;
|
||||
bool erronly = false;
|
||||
bool display_mntp = false;
|
||||
bool exact_match = false;
|
||||
bool ignore_missing = false;
|
||||
int freespace_ignore_reserved = FALSE;
|
||||
int display_inodes_perfdata = FALSE;
|
||||
bool freespace_ignore_reserved = false;
|
||||
bool display_inodes_perfdata = false;
|
||||
char *warn_freespace_units = NULL;
|
||||
char *crit_freespace_units = NULL;
|
||||
char *warn_freespace_percent = NULL;
|
||||
|
@ -153,7 +152,7 @@ char *warn_usedinodes_percent = NULL;
|
|||
char *crit_usedinodes_percent = NULL;
|
||||
char *warn_freeinodes_percent = NULL;
|
||||
char *crit_freeinodes_percent = NULL;
|
||||
int path_selected = FALSE;
|
||||
bool path_selected = false;
|
||||
bool path_ignored = false;
|
||||
char *group = NULL;
|
||||
struct stat *stat_buf;
|
||||
|
@ -205,7 +204,7 @@ main (int argc, char **argv)
|
|||
/* If a list of paths has not been selected, find entire
|
||||
mount list and create list of paths
|
||||
*/
|
||||
if (path_selected == FALSE && path_ignored == false) {
|
||||
if (path_selected == false && path_ignored == false) {
|
||||
for (me = mount_list; me; me = me->me_next) {
|
||||
if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) {
|
||||
path = np_add_parameter(&path_select_list, me->me_mountdir);
|
||||
|
@ -326,7 +325,7 @@ main (int argc, char **argv)
|
|||
get_stats (path, &fsp);
|
||||
|
||||
if (verbose >= 3) {
|
||||
printf ("For %s, used_pct=%g free_pct=%g used_units=%lu free_units=%lu total_units=%lu used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%lu mult=%lu\n",
|
||||
printf ("For %s, used_pct=%f free_pct=%f used_units=%lu free_units=%lu total_units=%lu used_inodes_pct=%f free_inodes_pct=%f fsp.fsu_blocksize=%lu mult=%lu\n",
|
||||
me->me_mountdir,
|
||||
path->dused_pct,
|
||||
path->dfree_pct,
|
||||
|
@ -396,10 +395,10 @@ main (int argc, char **argv)
|
|||
perfdata_uint64 (
|
||||
(!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
|
||||
path->dused_units * mult, "B",
|
||||
(warning_high_tide == UINT64_MAX ? FALSE : TRUE), warning_high_tide,
|
||||
(critical_high_tide == UINT64_MAX ? FALSE : TRUE), critical_high_tide,
|
||||
TRUE, 0,
|
||||
TRUE, path->dtotal_units * mult));
|
||||
(warning_high_tide == UINT64_MAX ? false : true), warning_high_tide,
|
||||
(critical_high_tide == UINT64_MAX ? false : true), critical_high_tide,
|
||||
true, 0,
|
||||
true, path->dtotal_units * mult));
|
||||
|
||||
if (display_inodes_perfdata) {
|
||||
/* *_high_tide must be reinitialized at each run */
|
||||
|
@ -418,10 +417,10 @@ main (int argc, char **argv)
|
|||
xasprintf (&perf, "%s %s", perf,
|
||||
perfdata_uint64 (perf_ilabel,
|
||||
path->inodes_used, "",
|
||||
(warning_high_tide != UINT64_MAX ? TRUE : FALSE), warning_high_tide,
|
||||
(critical_high_tide != UINT64_MAX ? TRUE : FALSE), critical_high_tide,
|
||||
TRUE, 0,
|
||||
TRUE, path->inodes_total));
|
||||
(warning_high_tide != UINT64_MAX ? true : false), warning_high_tide,
|
||||
(critical_high_tide != UINT64_MAX ? true : false), critical_high_tide,
|
||||
true, 0,
|
||||
true, path->inodes_total));
|
||||
}
|
||||
|
||||
if (disk_result==STATE_OK && erronly && !verbose)
|
||||
|
@ -432,7 +431,7 @@ main (int argc, char **argv)
|
|||
} else {
|
||||
xasprintf(&flag_header, "");
|
||||
}
|
||||
xasprintf (&output, "%s%s %s %llu%s (%.0f%%",
|
||||
xasprintf (&output, "%s%s %s %llu%s (%.1f%%",
|
||||
output, flag_header,
|
||||
(!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
|
||||
path->dfree_units,
|
||||
|
@ -452,7 +451,7 @@ main (int argc, char **argv)
|
|||
|
||||
if (strcmp(output, "") == 0 && ! erronly) {
|
||||
preamble = "";
|
||||
xasprintf (&output, " - No disks were found for provided parameters;");
|
||||
xasprintf (&output, " - No disks were found for provided parameters");
|
||||
}
|
||||
|
||||
printf ("DISK %s%s%s%s%s|%s\n", state_text (result), ((erronly && result==STATE_OK)) ? "" : preamble, output, (strcmp(ignored, "") == 0) ? "" : ignored_preamble, ignored, perf);
|
||||
|
@ -462,24 +461,8 @@ main (int argc, char **argv)
|
|||
|
||||
double calculate_percent(uintmax_t value, uintmax_t total) {
|
||||
double pct = -1;
|
||||
/* I don't understand the below, but it is taken from coreutils' df */
|
||||
/* Seems to be calculating pct, in the best possible way */
|
||||
if (value <= TYPE_MAXIMUM(uintmax_t) / 100
|
||||
&& total != 0) {
|
||||
uintmax_t u100 = value * 100;
|
||||
pct = u100 / total + (u100 % total != 0);
|
||||
} else {
|
||||
/* Possible rounding errors - see coreutils' df for more explanation */
|
||||
double u = value;
|
||||
double t = total;
|
||||
if (t) {
|
||||
long int lipct = pct = u * 100 / t;
|
||||
double ipct = lipct;
|
||||
|
||||
/* Like 'pct = ceil (dpct);', but without ceil - from coreutils again */
|
||||
if (ipct - 1 < pct && pct <= ipct + 1)
|
||||
pct = ipct + (ipct < pct);
|
||||
}
|
||||
if(value <= DBL_MAX && total != 0) {
|
||||
pct = (double)value / total * 100.0;
|
||||
}
|
||||
return pct;
|
||||
}
|
||||
|
@ -524,7 +507,7 @@ process_arguments (int argc, char **argv)
|
|||
{"ignore-ereg-partition", required_argument, 0, 'i'},
|
||||
{"ignore-eregi-path", required_argument, 0, 'I'},
|
||||
{"ignore-eregi-partition", required_argument, 0, 'I'},
|
||||
{"ignore-missing", no_argument, 0, IGNORE_MISSING},
|
||||
{"ignore-missing", no_argument, 0, 'n'},
|
||||
{"local", no_argument, 0, 'l'},
|
||||
{"stat-remote-fs", no_argument, 0, 'L'},
|
||||
{"iperfdata", no_argument, 0, 'P'},
|
||||
|
@ -550,7 +533,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:mklLPg: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:MEAn", longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF)
|
||||
break;
|
||||
|
@ -567,6 +550,10 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
/* See comments for 'c' */
|
||||
case 'w': /* warning threshold */
|
||||
if (!is_percentage_expression(optarg) && !is_numeric(optarg)) {
|
||||
die(STATE_UNKNOWN, "Argument for --warning invalid or missing: %s\n", optarg);
|
||||
}
|
||||
|
||||
if (strstr(optarg, "%")) {
|
||||
if (*optarg == '@') {
|
||||
warn_freespace_percent = optarg;
|
||||
|
@ -588,6 +575,10 @@ process_arguments (int argc, char **argv)
|
|||
force @ at the beginning of the range, so that it is backwards compatible
|
||||
*/
|
||||
case 'c': /* critical threshold */
|
||||
if (!is_percentage_expression(optarg) && !is_numeric(optarg)) {
|
||||
die(STATE_UNKNOWN, "Argument for --critical invalid or missing: %s\n", optarg);
|
||||
}
|
||||
|
||||
if (strstr(optarg, "%")) {
|
||||
if (*optarg == '@') {
|
||||
crit_freespace_percent = optarg;
|
||||
|
@ -710,7 +701,7 @@ process_arguments (int argc, char **argv)
|
|||
mount_list = read_file_system_list (0);
|
||||
np_set_best_match(se, mount_list, exact_match);
|
||||
|
||||
path_selected = TRUE;
|
||||
path_selected = true;
|
||||
break;
|
||||
case 'x': /* exclude path or partition */
|
||||
np_add_name(&dp_exclude_list, optarg);
|
||||
|
@ -734,18 +725,18 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'q': /* TODO: this function should eventually go away (removed 2007-09-20) */
|
||||
/* verbose--; **replaced by line below**. -q was only a broken way of implementing -e */
|
||||
erronly = TRUE;
|
||||
erronly = true;
|
||||
break;
|
||||
case 'e':
|
||||
erronly = TRUE;
|
||||
erronly = true;
|
||||
break;
|
||||
case 'E':
|
||||
if (path_selected)
|
||||
die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set -E before selecting paths\n"));
|
||||
exact_match = TRUE;
|
||||
exact_match = true;
|
||||
break;
|
||||
case 'f':
|
||||
freespace_ignore_reserved = TRUE;
|
||||
freespace_ignore_reserved = true;
|
||||
break;
|
||||
case 'g':
|
||||
if (path_selected)
|
||||
|
@ -792,7 +783,7 @@ process_arguments (int argc, char **argv)
|
|||
cflags = default_cflags;
|
||||
break;
|
||||
|
||||
case IGNORE_MISSING:
|
||||
case 'n':
|
||||
ignore_missing = true;
|
||||
break;
|
||||
case 'A':
|
||||
|
@ -817,7 +808,7 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
for (me = mount_list; me; me = me->me_next) {
|
||||
if (np_regex_match_mount_entry(me, &re)) {
|
||||
fnd = TRUE;
|
||||
fnd = true;
|
||||
if (verbose >= 3)
|
||||
printf("%s %s matching expression %s\n", me->me_devname, me->me_mountdir, optarg);
|
||||
|
||||
|
@ -832,24 +823,24 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
if (!fnd && ignore_missing == true) {
|
||||
path_ignored = true;
|
||||
/* path_selected = TRUE;*/
|
||||
path_selected = true;
|
||||
break;
|
||||
} else if (!fnd)
|
||||
die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"),
|
||||
_("Regular expression did not match any path or disk"), optarg);
|
||||
|
||||
fnd = FALSE;
|
||||
path_selected = TRUE;
|
||||
fnd = false;
|
||||
path_selected = true;
|
||||
np_set_best_match(path_select_list, mount_list, exact_match);
|
||||
cflags = default_cflags;
|
||||
|
||||
break;
|
||||
case 'M': /* display mountpoint */
|
||||
display_mntp = TRUE;
|
||||
display_mntp = true;
|
||||
break;
|
||||
case 'C':
|
||||
/* add all mount entries to path_select list if no partitions have been explicitly defined using -p */
|
||||
if (path_selected == FALSE) {
|
||||
if (path_selected == false) {
|
||||
struct parameter_list *path;
|
||||
for (me = mount_list; me; me = me->me_next) {
|
||||
if (! (path = np_find_parameter(path_select_list, me->me_mountdir)))
|
||||
|
@ -872,7 +863,7 @@ process_arguments (int argc, char **argv)
|
|||
warn_freeinodes_percent = NULL;
|
||||
crit_freeinodes_percent = NULL;
|
||||
|
||||
path_selected = FALSE;
|
||||
path_selected = false;
|
||||
group = NULL;
|
||||
break;
|
||||
case 'V': /* version */
|
||||
|
@ -896,7 +887,7 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
if (argc > c) {
|
||||
se = np_add_parameter(&path_select_list, strdup(argv[c++]));
|
||||
path_selected = TRUE;
|
||||
path_selected = true;
|
||||
set_all_thresholds(se);
|
||||
}
|
||||
|
||||
|
@ -905,7 +896,7 @@ process_arguments (int argc, char **argv)
|
|||
mult = (uintmax_t)1024 * 1024;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1004,7 +995,7 @@ print_help (void)
|
|||
printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)"));
|
||||
printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION");
|
||||
printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)"));
|
||||
printf (" %s\n", "--ignore-missing");
|
||||
printf (" %s\n", "-n, --ignore-missing");
|
||||
printf (" %s\n", _("Return OK if no filesystem matches, filesystem does not exist or is inaccessible."));
|
||||
printf (" %s\n", _("(Provide this option before -p / -r / --ereg-path if used)"));
|
||||
printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
||||
|
@ -1131,7 +1122,7 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
|
|||
}
|
||||
/* finally calculate percentages for either plain FS or summed up group */
|
||||
p->dused_pct = calculate_percent( p->used, p->used + p->available ); /* used + available can never be > uintmax */
|
||||
p->dfree_pct = 100 - p->dused_pct;
|
||||
p->dfree_pct = 100.0 - p->dused_pct;
|
||||
p->dused_inodes_percent = calculate_percent(p->inodes_total - p->inodes_free, p->inodes_total);
|
||||
p->dfree_inodes_percent = 100 - p->dused_inodes_percent;
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
|
||||
int process_arguments (int, char **);
|
||||
int validate_arguments (void);
|
||||
int error_scan (char *, int *);
|
||||
int ip_match_cidr(const char *, const char *);
|
||||
int error_scan (char *, bool *);
|
||||
bool ip_match_cidr(const char *, const char *);
|
||||
unsigned long ip2long(const char *);
|
||||
void print_help (void);
|
||||
void print_usage (void);
|
||||
|
@ -51,13 +51,13 @@ void print_usage (void);
|
|||
char query_address[ADDRESS_LENGTH] = "";
|
||||
char dns_server[ADDRESS_LENGTH] = "";
|
||||
char ptr_server[ADDRESS_LENGTH] = "";
|
||||
int verbose = FALSE;
|
||||
bool verbose = false;
|
||||
char **expected_address = NULL;
|
||||
int expected_address_cnt = 0;
|
||||
int expect_nxdomain = FALSE;
|
||||
bool expect_nxdomain = false;
|
||||
|
||||
int expect_authority = FALSE;
|
||||
int all_match = FALSE;
|
||||
bool expect_authority = false;
|
||||
bool all_match = false;
|
||||
thresholds *time_thresholds = NULL;
|
||||
|
||||
static int
|
||||
|
@ -80,15 +80,14 @@ main (int argc, char **argv)
|
|||
int n_addresses = 0;
|
||||
char *msg = NULL;
|
||||
char *temp_buffer = NULL;
|
||||
int non_authoritative = FALSE;
|
||||
bool non_authoritative = false;
|
||||
int result = STATE_UNKNOWN;
|
||||
double elapsed_time;
|
||||
long microsec;
|
||||
struct timeval tv;
|
||||
int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
|
||||
bool parse_address = false; /* This flag scans for Address: but only after Name: */
|
||||
output chld_out, chld_err;
|
||||
size_t i;
|
||||
int is_nxdomain = FALSE;
|
||||
bool is_nxdomain = false;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
|
@ -122,7 +121,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* scan stdout */
|
||||
for(i = 0; i < chld_out.lines; i++) {
|
||||
for(size_t i = 0; i < chld_out.lines; i++) {
|
||||
if (addresses == NULL)
|
||||
addresses = malloc(sizeof(*addresses)*10);
|
||||
else if (!(n_addresses % 10))
|
||||
|
@ -164,8 +163,8 @@ main (int argc, char **argv)
|
|||
|
||||
/* the server is responding, we just got the host name... */
|
||||
if (strstr (chld_out.line[i], "Name:"))
|
||||
parse_address = TRUE;
|
||||
else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") ||
|
||||
parse_address = true;
|
||||
else if (parse_address && (strstr (chld_out.line[i], "Address:") ||
|
||||
strstr (chld_out.line[i], "Addresses:"))) {
|
||||
temp_buffer = index (chld_out.line[i], ':');
|
||||
temp_buffer++;
|
||||
|
@ -184,7 +183,7 @@ main (int argc, char **argv)
|
|||
addresses[n_addresses++] = strdup(temp_buffer);
|
||||
}
|
||||
else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {
|
||||
non_authoritative = TRUE;
|
||||
non_authoritative = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,7 +196,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* scan stderr */
|
||||
for(i = 0; i < chld_err.lines; i++) {
|
||||
for(size_t i = 0; i < chld_err.lines; i++) {
|
||||
if (verbose)
|
||||
puts(chld_err.line[i]);
|
||||
|
||||
|
@ -241,7 +240,7 @@ main (int argc, char **argv)
|
|||
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++) {
|
||||
for (int i=0; i<expected_address_cnt; i++) {
|
||||
int j;
|
||||
/* check if we get a match on 'raw' ip or cidr */
|
||||
for (j=0; j<n_addresses; j++) {
|
||||
|
@ -298,21 +297,21 @@ main (int argc, char **argv)
|
|||
printf (_(". %s returns %s"), query_address, address);
|
||||
if ((time_thresholds->warning != NULL) && (time_thresholds->critical != NULL)) {
|
||||
printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
|
||||
TRUE, time_thresholds->warning->end,
|
||||
TRUE, time_thresholds->critical->end,
|
||||
TRUE, 0, FALSE, 0));
|
||||
true, time_thresholds->warning->end,
|
||||
true, time_thresholds->critical->end,
|
||||
true, 0, false, 0));
|
||||
} else if ((time_thresholds->warning == NULL) && (time_thresholds->critical != NULL)) {
|
||||
printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
|
||||
FALSE, 0,
|
||||
TRUE, time_thresholds->critical->end,
|
||||
TRUE, 0, FALSE, 0));
|
||||
false, 0,
|
||||
true, time_thresholds->critical->end,
|
||||
true, 0, false, 0));
|
||||
} else if ((time_thresholds->warning != NULL) && (time_thresholds->critical == NULL)) {
|
||||
printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
|
||||
TRUE, time_thresholds->warning->end,
|
||||
FALSE, 0,
|
||||
TRUE, 0, FALSE, 0));
|
||||
true, time_thresholds->warning->end,
|
||||
false, 0,
|
||||
true, 0, false, 0));
|
||||
} else
|
||||
printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
|
||||
printf ("|%s\n", fperfdata ("time", elapsed_time, "s", false, 0, false, 0, true, 0, false, 0));
|
||||
}
|
||||
else if (result == STATE_WARNING)
|
||||
printf (_("DNS WARNING - %s\n"),
|
||||
|
@ -327,15 +326,14 @@ main (int argc, char **argv)
|
|||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
ip_match_cidr(const char *addr, const char *cidr_ro)
|
||||
{
|
||||
bool 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;
|
||||
if (!subnet || !mask_c) {
|
||||
return false;
|
||||
}
|
||||
mask = atoi(mask_c);
|
||||
|
||||
/* https://www.cryptobells.com/verifying-ips-in-a-subnet-in-php/ */
|
||||
|
@ -355,14 +353,14 @@ ip2long(const char* src) {
|
|||
}
|
||||
|
||||
int
|
||||
error_scan (char *input_buffer, int *is_nxdomain)
|
||||
error_scan (char *input_buffer, bool *is_nxdomain)
|
||||
{
|
||||
|
||||
const int nxdomain = strstr (input_buffer, "Non-existent") ||
|
||||
strstr (input_buffer, "** server can't find") ||
|
||||
strstr (input_buffer, "** Can't find") ||
|
||||
strstr (input_buffer, "NXDOMAIN");
|
||||
if (nxdomain) *is_nxdomain = TRUE;
|
||||
if (nxdomain) *is_nxdomain = true;
|
||||
|
||||
/* the DNS lookup timed out */
|
||||
if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) ||
|
||||
|
@ -461,7 +459,7 @@ process_arguments (int argc, char **argv)
|
|||
print_revision (progname, NP_VERSION);
|
||||
exit (STATE_UNKNOWN);
|
||||
case 'v': /* version */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 't': /* timeout period */
|
||||
timeout_interval = atoi (optarg);
|
||||
|
@ -508,13 +506,13 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
break;
|
||||
case 'n': /* expect NXDOMAIN */
|
||||
expect_nxdomain = TRUE;
|
||||
expect_nxdomain = true;
|
||||
break;
|
||||
case 'A': /* expect authority */
|
||||
expect_authority = TRUE;
|
||||
expect_authority = true;
|
||||
break;
|
||||
case 'L': /* all must match */
|
||||
all_match = TRUE;
|
||||
all_match = true;
|
||||
break;
|
||||
case 'w':
|
||||
warning = optarg;
|
||||
|
|
|
@ -59,16 +59,16 @@ int packet_size = PACKET_SIZE;
|
|||
int packet_count = PACKET_COUNT;
|
||||
int target_timeout = 0;
|
||||
int packet_interval = 0;
|
||||
int verbose = FALSE;
|
||||
bool verbose = false;
|
||||
int cpl;
|
||||
int wpl;
|
||||
double crta;
|
||||
double wrta;
|
||||
int cpl_p = FALSE;
|
||||
int wpl_p = FALSE;
|
||||
bool alive_p = FALSE;
|
||||
int crta_p = FALSE;
|
||||
int wrta_p = FALSE;
|
||||
bool cpl_p = false;
|
||||
bool wpl_p = false;
|
||||
bool alive_p = false;
|
||||
bool crta_p = false;
|
||||
bool wrta_p = false;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -194,8 +194,8 @@ int textscan (char *buf) {
|
|||
_("FPING %s - %s (rta=%f ms)|%s\n"),
|
||||
state_text (STATE_OK), server_name,rta,
|
||||
/* No loss since we only waited for the first reply
|
||||
perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), */
|
||||
fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0));
|
||||
perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100), */
|
||||
fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, true, 0, false, 0));
|
||||
}
|
||||
|
||||
if (strstr (buf, "not found")) {
|
||||
|
@ -228,21 +228,21 @@ int textscan (char *buf) {
|
|||
rtastr = 1 + index (rtastr, '/');
|
||||
loss = strtod (losstr, NULL);
|
||||
rta = strtod (rtastr, NULL);
|
||||
if (cpl_p == TRUE && loss > cpl)
|
||||
if (cpl_p && loss > cpl)
|
||||
status = STATE_CRITICAL;
|
||||
else if (crta_p == TRUE && rta > crta)
|
||||
else if (crta_p && rta > crta)
|
||||
status = STATE_CRITICAL;
|
||||
else if (wpl_p == TRUE && loss > wpl)
|
||||
else if (wpl_p && loss > wpl)
|
||||
status = STATE_WARNING;
|
||||
else if (wrta_p == TRUE && rta > wrta)
|
||||
else if (wrta_p && rta > wrta)
|
||||
status = STATE_WARNING;
|
||||
else
|
||||
status = STATE_OK;
|
||||
die (status,
|
||||
_("FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"),
|
||||
state_text (status), server_name, loss, rta,
|
||||
perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100),
|
||||
fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0));
|
||||
perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100),
|
||||
fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, true, 0, false, 0));
|
||||
|
||||
}
|
||||
else if(strstr (buf, "xmt/rcv/%loss") ) {
|
||||
|
@ -258,16 +258,16 @@ int textscan (char *buf) {
|
|||
loss = strtod (losstr, NULL);
|
||||
if (atoi(losstr) == 100)
|
||||
status = STATE_CRITICAL;
|
||||
else if (cpl_p == TRUE && loss > cpl)
|
||||
else if (cpl_p && loss > cpl)
|
||||
status = STATE_CRITICAL;
|
||||
else if (wpl_p == TRUE && loss > wpl)
|
||||
else if (wpl_p && loss > wpl)
|
||||
status = STATE_WARNING;
|
||||
else
|
||||
status = STATE_OK;
|
||||
/* loss=%.0f%%;%d;%d;0;100 */
|
||||
die (status, _("FPING %s - %s (loss=%.0f%% )|%s\n"),
|
||||
state_text (status), server_name, loss ,
|
||||
perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100));
|
||||
perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100));
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -329,7 +329,7 @@ process_arguments (int argc, char **argv)
|
|||
case '?': /* print short usage statement if args not parsable */
|
||||
usage5 ();
|
||||
case 'a': /* host alive mode */
|
||||
alive_p = TRUE;
|
||||
alive_p = true;
|
||||
break;
|
||||
case 'h': /* help */
|
||||
print_help ();
|
||||
|
@ -338,16 +338,16 @@ process_arguments (int argc, char **argv)
|
|||
print_revision (progname, NP_VERSION);
|
||||
exit (STATE_UNKNOWN);
|
||||
case 'v': /* verbose mode */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 'H': /* hostname */
|
||||
if (is_host (optarg) == FALSE) {
|
||||
if (is_host (optarg) == false) {
|
||||
usage2 (_("Invalid hostname/address"), optarg);
|
||||
}
|
||||
server_name = strscpy (server_name, optarg);
|
||||
break;
|
||||
case 'S': /* sourceip */
|
||||
if (is_host (optarg) == FALSE) {
|
||||
if (is_host (optarg) == false) {
|
||||
usage2 (_("Invalid hostname/address"), optarg);
|
||||
}
|
||||
sourceip = strscpy (sourceip, optarg);
|
||||
|
@ -369,12 +369,12 @@ process_arguments (int argc, char **argv)
|
|||
get_threshold (optarg, rv);
|
||||
if (rv[RTA]) {
|
||||
crta = strtod (rv[RTA], NULL);
|
||||
crta_p = TRUE;
|
||||
crta_p = true;
|
||||
rv[RTA] = NULL;
|
||||
}
|
||||
if (rv[PL]) {
|
||||
cpl = atoi (rv[PL]);
|
||||
cpl_p = TRUE;
|
||||
cpl_p = true;
|
||||
rv[PL] = NULL;
|
||||
}
|
||||
break;
|
||||
|
@ -382,12 +382,12 @@ process_arguments (int argc, char **argv)
|
|||
get_threshold (optarg, rv);
|
||||
if (rv[RTA]) {
|
||||
wrta = strtod (rv[RTA], NULL);
|
||||
wrta_p = TRUE;
|
||||
wrta_p = true;
|
||||
rv[RTA] = NULL;
|
||||
}
|
||||
if (rv[PL]) {
|
||||
wpl = atoi (rv[PL]);
|
||||
wpl_p = TRUE;
|
||||
wpl_p = true;
|
||||
rv[PL] = NULL;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -53,7 +53,7 @@ char *server_ip;
|
|||
char *game_type;
|
||||
int port = 0;
|
||||
|
||||
int verbose;
|
||||
bool verbose = false;
|
||||
|
||||
int qstat_game_players_max = -1;
|
||||
int qstat_game_players = -1;
|
||||
|
@ -90,7 +90,7 @@ main (int argc, char **argv)
|
|||
if (port)
|
||||
xasprintf (&command_line, "%s:%-d", command_line, port);
|
||||
|
||||
if (verbose > 0)
|
||||
if (verbose)
|
||||
printf ("%s\n", command_line);
|
||||
|
||||
/* run the command. historically, this plugin ignores output on stderr,
|
||||
|
@ -142,11 +142,11 @@ main (int argc, char **argv)
|
|||
ret[qstat_map_field],
|
||||
ret[qstat_ping_field],
|
||||
perfdata ("players", atol(ret[qstat_game_players]), "",
|
||||
FALSE, 0, FALSE, 0,
|
||||
TRUE, 0, TRUE, atol(ret[qstat_game_players_max])),
|
||||
false, 0, false, 0,
|
||||
true, 0, true, atol(ret[qstat_game_players_max])),
|
||||
fperfdata ("ping", strtod(ret[qstat_ping_field], NULL), "",
|
||||
FALSE, 0, FALSE, 0,
|
||||
TRUE, 0, FALSE, 0));
|
||||
false, 0, false, 0,
|
||||
true, 0, false, 0));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -201,7 +201,7 @@ process_arguments (int argc, char **argv)
|
|||
print_revision (progname, NP_VERSION);
|
||||
exit (STATE_UNKNOWN);
|
||||
case 'v': /* version */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 't': /* timeout period */
|
||||
timeout_interval = atoi (optarg);
|
||||
|
|
|
@ -85,6 +85,7 @@ char errbuf[MAX_INPUT_BUFFER];
|
|||
int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE;
|
||||
int errcode;
|
||||
int invert_regex = 0;
|
||||
int state_regex = STATE_CRITICAL;
|
||||
|
||||
struct timeval tv;
|
||||
struct timeval tv_temp;
|
||||
|
@ -210,7 +211,8 @@ bool process_arguments (int argc, char **argv)
|
|||
INVERT_REGEX = CHAR_MAX + 1,
|
||||
SNI_OPTION,
|
||||
MAX_REDIRS_OPTION,
|
||||
CONTINUE_AFTER_CHECK_CERT
|
||||
CONTINUE_AFTER_CHECK_CERT,
|
||||
STATE_REGEX
|
||||
};
|
||||
|
||||
int option = 0;
|
||||
|
@ -246,6 +248,7 @@ bool process_arguments (int argc, char **argv)
|
|||
{"content-type", required_argument, 0, 'T'},
|
||||
{"pagesize", required_argument, 0, 'm'},
|
||||
{"invert-regex", no_argument, NULL, INVERT_REGEX},
|
||||
{"state-regex", required_argument, 0, STATE_REGEX},
|
||||
{"use-ipv4", no_argument, 0, '4'},
|
||||
{"use-ipv6", no_argument, 0, '6'},
|
||||
{"extended-perfdata", no_argument, 0, 'E'},
|
||||
|
@ -471,10 +474,9 @@ bool process_arguments (int argc, char **argv)
|
|||
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;
|
||||
if ((tmp = strstr(http_method, ":")) != NULL) {
|
||||
tmp[0] = '\0'; // set the ":" in the middle to 0
|
||||
http_method_proxy = ++tmp; // this points to the second part
|
||||
}
|
||||
break;
|
||||
case 'd': /* string or substring */
|
||||
|
@ -512,6 +514,13 @@ bool process_arguments (int argc, char **argv)
|
|||
case INVERT_REGEX:
|
||||
invert_regex = 1;
|
||||
break;
|
||||
case STATE_REGEX:
|
||||
if (!strcmp (optarg, "critical"))
|
||||
state_regex = STATE_CRITICAL;
|
||||
else if (!strcmp (optarg, "warning"))
|
||||
state_regex = STATE_WARNING;
|
||||
else usage2 (_("Invalid state-regex option"), optarg);
|
||||
break;
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
|
@ -1318,7 +1327,7 @@ check_http (void)
|
|||
xasprintf (&msg, _("%spattern not found, "), msg);
|
||||
else
|
||||
xasprintf (&msg, _("%spattern found, "), msg);
|
||||
result = STATE_CRITICAL;
|
||||
result = state_regex;
|
||||
}
|
||||
else {
|
||||
/* FIXME: Shouldn't that be UNKNOWN? */
|
||||
|
@ -1775,7 +1784,7 @@ print_help (void)
|
|||
printf (" %s\n", "-u, --url=PATH");
|
||||
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", _("URL decoded http POST data"));
|
||||
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");
|
||||
|
@ -1794,7 +1803,10 @@ print_help (void)
|
|||
printf (" %s\n", "-R, --eregi=STRING");
|
||||
printf (" %s\n", _("Search page for case-insensitive regex STRING"));
|
||||
printf (" %s\n", "--invert-regex");
|
||||
printf (" %s\n", _("Return CRITICAL if found, OK if not\n"));
|
||||
printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)"));
|
||||
printf (" %s\n", _("can be changed with --state--regex)"));
|
||||
printf (" %s\n", "--regex-state=STATE");
|
||||
printf (" %s\n", _("Return STATE if regex is found, OK if not\n"));
|
||||
|
||||
printf (" %s\n", "-a, --authorization=AUTH_PAIR");
|
||||
printf (" %s\n", _("Username:password on sites with basic authentication"));
|
||||
|
|
|
@ -73,10 +73,6 @@ void print_usage (void);
|
|||
|
||||
#define NR_ATTRIBUTES 30
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif /* */
|
||||
|
||||
#define PREFAILURE 2
|
||||
#define ADVISORY 1
|
||||
#define OPERATIONAL 0
|
||||
|
@ -169,9 +165,9 @@ int smart_read_values (int, values_t *);
|
|||
int nagios (values_t *, thresholds_t *);
|
||||
void print_value (value_t *, threshold_t *);
|
||||
void print_values (values_t *, thresholds_t *);
|
||||
int smart_cmd_simple (int, enum SmartCommand, __u8, char);
|
||||
int smart_cmd_simple (int, enum SmartCommand, __u8, bool);
|
||||
int smart_read_thresholds (int, thresholds_t *);
|
||||
int verbose = FALSE;
|
||||
bool verbose = false;
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
|
@ -203,7 +199,7 @@ main (int argc, char *argv[])
|
|||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
|
||||
o = getopt_long (argc, argv, "+d:iq10nhVv", longopts, &longindex);
|
||||
|
||||
|
@ -229,7 +225,7 @@ main (int argc, char *argv[])
|
|||
fprintf (stderr, "%s\n", _("default and will be removed from future releases."));
|
||||
break;
|
||||
case 'v': /* verbose */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 'h':
|
||||
print_help ();
|
||||
|
@ -258,7 +254,7 @@ main (int argc, char *argv[])
|
|||
return STATE_CRITICAL;
|
||||
}
|
||||
|
||||
if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, FALSE)) {
|
||||
if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, false)) {
|
||||
printf (_("CRITICAL - SMART_CMD_ENABLE\n"));
|
||||
return STATE_CRITICAL;
|
||||
}
|
||||
|
@ -447,9 +443,7 @@ print_values (values_t * p, thresholds_t * t)
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error)
|
||||
{
|
||||
int smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, bool show_error) {
|
||||
int e = STATE_UNKNOWN;
|
||||
#ifdef __linux__
|
||||
__u8 args[4];
|
||||
|
|
|
@ -71,9 +71,9 @@ thresholds *entries_thresholds = NULL;
|
|||
struct timeval tv;
|
||||
char* warn_entries = NULL;
|
||||
char* crit_entries = NULL;
|
||||
int starttls = FALSE;
|
||||
int ssl_on_connect = FALSE;
|
||||
int verbose = 0;
|
||||
bool starttls = false;
|
||||
bool ssl_on_connect = false;
|
||||
bool verbose = false;
|
||||
|
||||
/* for ldap tls */
|
||||
|
||||
|
@ -115,7 +115,7 @@ main (int argc, char *argv[])
|
|||
usage4 (_("Could not parse arguments"));
|
||||
|
||||
if (strstr(argv[0],"check_ldaps") && ! starttls && ! ssl_on_connect)
|
||||
starttls = TRUE;
|
||||
starttls = true;
|
||||
|
||||
/* initialize alarm signal handling */
|
||||
signal (SIGALRM, socket_timeout_alarm_handler);
|
||||
|
@ -253,11 +253,11 @@ main (int argc, char *argv[])
|
|||
fperfdata ("time", elapsed_time, "s",
|
||||
(int)warn_time, warn_time,
|
||||
(int)crit_time, crit_time,
|
||||
TRUE, 0, FALSE, 0),
|
||||
true, 0, false, 0),
|
||||
sperfdata ("entries", (double)num_entries, "",
|
||||
warn_entries,
|
||||
crit_entries,
|
||||
TRUE, 0.0, FALSE, 0.0));
|
||||
true, 0.0, false, 0.0));
|
||||
} else {
|
||||
printf (_("LDAP %s - %.3f seconds response time|%s\n"),
|
||||
state_text (status),
|
||||
|
@ -265,7 +265,7 @@ main (int argc, char *argv[])
|
|||
fperfdata ("time", elapsed_time, "s",
|
||||
(int)warn_time, warn_time,
|
||||
(int)crit_time, crit_time,
|
||||
TRUE, 0, FALSE, 0));
|
||||
true, 0, false, 0));
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -313,7 +313,7 @@ process_arguments (int argc, char **argv)
|
|||
strcpy (argv[c], "-t");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
c = getopt_long (argc, argv, "hvV234TS6t:c:w:H:b:p:a:D:P:C:W:", longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF)
|
||||
|
@ -374,17 +374,17 @@ process_arguments (int argc, char **argv)
|
|||
address_family = AF_INET;
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
verbose = true;
|
||||
break;
|
||||
case 'T':
|
||||
if (! ssl_on_connect)
|
||||
starttls = TRUE;
|
||||
starttls = true;
|
||||
else
|
||||
usage_va(_("%s cannot be combined with %s"), "-T/--starttls", "-S/--ssl");
|
||||
break;
|
||||
case 'S':
|
||||
if (! starttls) {
|
||||
ssl_on_connect = TRUE;
|
||||
ssl_on_connect = true;
|
||||
if (ld_port == -1)
|
||||
ld_port = LDAPS_PORT;
|
||||
} else
|
||||
|
|
|
@ -110,10 +110,6 @@ main (int argc, char **argv)
|
|||
double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about uninitialized arrays */
|
||||
#ifndef HAVE_GETLOADAVG
|
||||
char input_buffer[MAX_INPUT_BUFFER];
|
||||
# ifdef HAVE_PROC_LOADAVG
|
||||
FILE *fp;
|
||||
char *str, *next;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
@ -132,23 +128,6 @@ main (int argc, char **argv)
|
|||
if (result != 3)
|
||||
return STATE_UNKNOWN;
|
||||
#else
|
||||
# ifdef HAVE_PROC_LOADAVG
|
||||
fp = fopen (PROC_LOADAVG, "r");
|
||||
if (fp == NULL) {
|
||||
printf (_("Error opening %s\n"), PROC_LOADAVG);
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
|
||||
str = (char *)input_buffer;
|
||||
for(i = 0; i < 3; i++) {
|
||||
la[i] = strtod(str, &next);
|
||||
str = next;
|
||||
}
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
# else
|
||||
child_process = spopen (PATH_TO_UPTIME);
|
||||
if (child_process == NULL) {
|
||||
printf (_("Error opening %s\n"), PATH_TO_UPTIME);
|
||||
|
@ -175,18 +154,13 @@ main (int argc, char **argv)
|
|||
printf (_("Error code %d returned in %s\n"), result, PATH_TO_UPTIME);
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if ((la[0] < 0.0) || (la[1] < 0.0) || (la[2] < 0.0)) {
|
||||
#ifdef HAVE_GETLOADAVG
|
||||
printf (_("Error in getloadavg()\n"));
|
||||
#else
|
||||
# ifdef HAVE_PROC_LOADAVG
|
||||
printf (_("Error processing %s\n"), PROC_LOADAVG);
|
||||
# else
|
||||
printf (_("Error processing %s\n"), PATH_TO_UPTIME);
|
||||
# endif
|
||||
#endif
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ void print_usage (void);
|
|||
|
||||
char *log_file = NULL;
|
||||
int expire_minutes = 0;
|
||||
int use_average = TRUE;
|
||||
bool use_average = true;
|
||||
int variable_number = -1;
|
||||
unsigned long value_warning_threshold = 0L;
|
||||
unsigned long value_critical_threshold = 0L;
|
||||
|
@ -138,7 +138,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* else check the incoming/outgoing rates */
|
||||
if (use_average == TRUE)
|
||||
if (use_average)
|
||||
rate = average_value_rate;
|
||||
else
|
||||
rate = maximum_value_rate;
|
||||
|
@ -149,7 +149,7 @@ main (int argc, char **argv)
|
|||
result = STATE_WARNING;
|
||||
|
||||
printf("%s. %s = %lu %s|%s\n",
|
||||
(use_average == TRUE) ? _("Avg") : _("Max"),
|
||||
(use_average) ? _("Avg") : _("Max"),
|
||||
label, rate, units,
|
||||
perfdata(label, (long) rate, units,
|
||||
(int) value_warning_threshold, (long) value_warning_threshold,
|
||||
|
@ -211,9 +211,9 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'a': /* port */
|
||||
if (!strcmp (optarg, "MAX"))
|
||||
use_average = FALSE;
|
||||
use_average = false;
|
||||
else
|
||||
use_average = TRUE;
|
||||
use_average = true;
|
||||
break;
|
||||
case 'v':
|
||||
variable_number = atoi (optarg);
|
||||
|
@ -258,11 +258,11 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
if (argc > c && strcmp (argv[c], "MAX") == 0) {
|
||||
use_average = FALSE;
|
||||
use_average = false;
|
||||
c++;
|
||||
}
|
||||
else if (argc > c && strcmp (argv[c], "AVG") == 0) {
|
||||
use_average = TRUE;
|
||||
use_average = true;
|
||||
c++;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void print_usage(void);
|
|||
|
||||
char *log_file = NULL;
|
||||
int expire_minutes = -1;
|
||||
int use_average = TRUE;
|
||||
bool use_average = true;
|
||||
unsigned long incoming_warning_threshold = 0L;
|
||||
unsigned long incoming_critical_threshold = 0L;
|
||||
unsigned long outgoing_warning_threshold = 0L;
|
||||
|
@ -137,7 +137,7 @@ main (int argc, char **argv)
|
|||
(int) ((current_time - timestamp) / 60));
|
||||
|
||||
/* else check the incoming/outgoing rates */
|
||||
if (use_average == TRUE) {
|
||||
if (use_average) {
|
||||
incoming_rate = average_incoming_rate;
|
||||
outgoing_rate = average_outgoing_rate;
|
||||
}
|
||||
|
@ -192,17 +192,17 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
xasprintf (&error_message, _("%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"),
|
||||
(use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate,
|
||||
incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"),
|
||||
(use_average) ? _("Avg") : _("Max"), adjusted_incoming_rate,
|
||||
incoming_speed_rating, (use_average) ? _("Avg") : _("Max"),
|
||||
adjusted_outgoing_rate, outgoing_speed_rating,
|
||||
fperfdata("in", adjusted_incoming_rate, incoming_speed_rating,
|
||||
(int)incoming_warning_threshold, incoming_warning_threshold,
|
||||
(int)incoming_critical_threshold, incoming_critical_threshold,
|
||||
TRUE, 0, FALSE, 0),
|
||||
true, 0, false, 0),
|
||||
fperfdata("out", adjusted_outgoing_rate, outgoing_speed_rating,
|
||||
(int)outgoing_warning_threshold, outgoing_warning_threshold,
|
||||
(int)outgoing_critical_threshold, outgoing_critical_threshold,
|
||||
TRUE, 0, FALSE, 0));
|
||||
true, 0, false, 0));
|
||||
|
||||
printf (_("Traffic %s - %s\n"), state_text(result), error_message);
|
||||
|
||||
|
@ -256,9 +256,9 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'a': /* aggregation (AVE or MAX) */
|
||||
if (!strcmp (optarg, "MAX"))
|
||||
use_average = FALSE;
|
||||
use_average = false;
|
||||
else
|
||||
use_average = TRUE;
|
||||
use_average = true;
|
||||
break;
|
||||
case 'c': /* warning threshold */
|
||||
sscanf (optarg, "%lu,%lu", &incoming_critical_threshold,
|
||||
|
@ -289,11 +289,11 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
if (argc > c && strcmp (argv[c], "MAX") == 0) {
|
||||
use_average = FALSE;
|
||||
use_average = false;
|
||||
c++;
|
||||
}
|
||||
else if (argc > c && strcmp (argv[c], "AVG") == 0) {
|
||||
use_average = TRUE;
|
||||
use_average = true;
|
||||
c++;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ main (int argc, char **argv)
|
|||
char slaveresult[SLAVERESULTSIZE] = { 0 };
|
||||
char* perf;
|
||||
|
||||
perf = strdup ("");
|
||||
perf = strdup ("");
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
|
@ -193,14 +193,14 @@ main (int argc, char **argv)
|
|||
for(i = 0; i < LENGTH_METRIC_UNIT; i++) {
|
||||
if (strcmp(row[0], metric_unit[i]) == 0) {
|
||||
xasprintf(&perf, "%s%s ", perf, perfdata(metric_unit[i],
|
||||
atol(row[1]), "", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0));
|
||||
atol(row[1]), "", false, 0, false, 0, false, 0, false, 0));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < LENGTH_METRIC_COUNTER; i++) {
|
||||
if (strcmp(row[0], metric_counter[i]) == 0) {
|
||||
xasprintf(&perf, "%s%s ", perf, perfdata(metric_counter[i],
|
||||
atol(row[1]), "c", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0));
|
||||
atol(row[1]), "c", false, 0, false, 0, false, 0, false, 0));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -322,10 +322,10 @@ main (int argc, char **argv)
|
|||
status = get_status(value, my_threshold);
|
||||
|
||||
xasprintf (&perf, "%s %s", perf, fperfdata ("seconds behind master", value, "s",
|
||||
TRUE, (double) warning_time,
|
||||
TRUE, (double) critical_time,
|
||||
FALSE, 0,
|
||||
FALSE, 0));
|
||||
true, (double) warning_time,
|
||||
true, (double) critical_time,
|
||||
false, 0,
|
||||
false, 0));
|
||||
|
||||
if (status == STATE_WARNING) {
|
||||
printf("SLOW_SLAVE %s: %s|%s\n", _("WARNING"), slaveresult, perf);
|
||||
|
|
|
@ -162,10 +162,10 @@ main (int argc, char **argv)
|
|||
}
|
||||
printf(_("'%s' returned %f | %s"), sql_query, value,
|
||||
fperfdata("result", value, "",
|
||||
my_thresholds->warning?TRUE:FALSE, my_thresholds->warning?my_thresholds->warning->end:0,
|
||||
my_thresholds->critical?TRUE:FALSE, my_thresholds->critical?my_thresholds->critical->end:0,
|
||||
FALSE, 0,
|
||||
FALSE, 0)
|
||||
my_thresholds->warning?true:false, my_thresholds->warning?my_thresholds->warning->end:0,
|
||||
my_thresholds->critical?true:false, my_thresholds->critical?my_thresholds->critical->end:0,
|
||||
false, 0,
|
||||
false, 0)
|
||||
);
|
||||
printf("\n");
|
||||
|
||||
|
|
|
@ -67,17 +67,17 @@ char *req_password=NULL;
|
|||
unsigned long lvalue_list[MAX_VALUE_LIST];
|
||||
unsigned long warning_value=0L;
|
||||
unsigned long critical_value=0L;
|
||||
int check_warning_value=FALSE;
|
||||
int check_critical_value=FALSE;
|
||||
bool check_warning_value=false;
|
||||
bool check_critical_value=false;
|
||||
enum checkvars vars_to_check = CHECK_NONE;
|
||||
int show_all=FALSE;
|
||||
bool show_all = false;
|
||||
|
||||
char recv_buffer[MAX_INPUT_BUFFER];
|
||||
|
||||
void fetch_data (const char* address, int port, const char* sendb);
|
||||
int process_arguments(int, char **);
|
||||
void preparelist(char *string);
|
||||
int strtoularray(unsigned long *array, char *string, const char *delim);
|
||||
bool strtoularray(unsigned long *array, char *string, const char *delim);
|
||||
void print_help(void);
|
||||
void print_usage(void);
|
||||
|
||||
|
@ -113,8 +113,8 @@ int main(int argc, char **argv){
|
|||
int uphours=0;
|
||||
int upminutes=0;
|
||||
|
||||
int isPercent = FALSE;
|
||||
int allRight = FALSE;
|
||||
bool isPercent = false;
|
||||
bool allRight = false;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
|
@ -151,7 +151,7 @@ int main(int argc, char **argv){
|
|||
|
||||
if (value_list==NULL)
|
||||
output_message = strdup (_("missing -l parameters"));
|
||||
else if (strtoularray(lvalue_list,value_list,",")==FALSE)
|
||||
else if (! strtoularray(lvalue_list,value_list,","))
|
||||
output_message = strdup (_("wrong -l parameter."));
|
||||
else {
|
||||
/* -l parameters is present with only integers */
|
||||
|
@ -224,9 +224,9 @@ int main(int argc, char **argv){
|
|||
|
||||
xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"),updays, uphours, upminutes, uptime);
|
||||
|
||||
if (check_critical_value==TRUE && uptime <= critical_value)
|
||||
if (check_critical_value && uptime <= critical_value)
|
||||
return_code=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && uptime <= warning_value)
|
||||
else if (check_warning_value && uptime <= warning_value)
|
||||
return_code=STATE_WARNING;
|
||||
else
|
||||
return_code=STATE_OK;
|
||||
|
@ -261,9 +261,9 @@ int main(int argc, char **argv){
|
|||
(total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
|
||||
critical_used_space / 1073741824, total_disk_space / 1073741824);
|
||||
|
||||
if(check_critical_value==TRUE && percent_used_space >= critical_value)
|
||||
if(check_critical_value && percent_used_space >= critical_value)
|
||||
return_code=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && percent_used_space >= warning_value)
|
||||
else if (check_warning_value && percent_used_space >= warning_value)
|
||||
return_code=STATE_WARNING;
|
||||
else
|
||||
return_code=STATE_OK;
|
||||
|
@ -285,7 +285,7 @@ int main(int argc, char **argv){
|
|||
else {
|
||||
preparelist(value_list); /* replace , between services with & to send the request */
|
||||
xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
|
||||
(show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
|
||||
(show_all) ? "ShowAll" : "ShowFail",value_list);
|
||||
fetch_data (server_address, server_port, send_buffer);
|
||||
numstr = strtok(recv_buffer,"&");
|
||||
if (numstr == NULL)
|
||||
|
@ -321,9 +321,9 @@ int main(int argc, char **argv){
|
|||
warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
|
||||
|
||||
return_code=STATE_OK;
|
||||
if(check_critical_value==TRUE && percent_used_space >= critical_value)
|
||||
if(check_critical_value && percent_used_space >= critical_value)
|
||||
return_code=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && percent_used_space >= warning_value)
|
||||
else if (check_warning_value && percent_used_space >= warning_value)
|
||||
return_code=STATE_WARNING;
|
||||
|
||||
break;
|
||||
|
@ -371,7 +371,7 @@ int main(int argc, char **argv){
|
|||
else if (isPercent)
|
||||
{
|
||||
counter_unit = strdup ("%");
|
||||
allRight = TRUE;
|
||||
allRight = true;
|
||||
}
|
||||
|
||||
if ((counter_unit != NULL) && (!allRight))
|
||||
|
@ -391,7 +391,7 @@ int main(int argc, char **argv){
|
|||
if ((fmaxval == 0) && (maxval == errcvt))
|
||||
output_message = strdup (_("Maximum value contains non-numbers"));
|
||||
else
|
||||
allRight = TRUE; /* Everything is OK. */
|
||||
allRight = true; /* Everything is OK. */
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -418,9 +418,9 @@ int main(int argc, char **argv){
|
|||
|
||||
if (critical_value > warning_value)
|
||||
{ /* Normal thresholds */
|
||||
if (check_critical_value == TRUE && counter_value >= critical_value)
|
||||
if (check_critical_value && counter_value >= critical_value)
|
||||
return_code = STATE_CRITICAL;
|
||||
else if (check_warning_value == TRUE && counter_value >= warning_value)
|
||||
else if (check_warning_value && counter_value >= warning_value)
|
||||
return_code = STATE_WARNING;
|
||||
else
|
||||
return_code = STATE_OK;
|
||||
|
@ -428,9 +428,9 @@ int main(int argc, char **argv){
|
|||
else
|
||||
{ /* inverse thresholds */
|
||||
return_code = STATE_OK;
|
||||
if (check_critical_value == TRUE && counter_value <= critical_value)
|
||||
if (check_critical_value && counter_value <= critical_value)
|
||||
return_code = STATE_CRITICAL;
|
||||
else if (check_warning_value == TRUE && counter_value <= warning_value)
|
||||
else if (check_warning_value && counter_value <= warning_value)
|
||||
return_code = STATE_WARNING;
|
||||
}
|
||||
break;
|
||||
|
@ -448,17 +448,17 @@ int main(int argc, char **argv){
|
|||
output_message = strdup (description);
|
||||
|
||||
if (critical_value > warning_value) { /* Normal thresholds */
|
||||
if(check_critical_value==TRUE && age_in_minutes >= critical_value)
|
||||
if(check_critical_value && age_in_minutes >= critical_value)
|
||||
return_code=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
|
||||
else if (check_warning_value && age_in_minutes >= warning_value)
|
||||
return_code=STATE_WARNING;
|
||||
else
|
||||
return_code=STATE_OK;
|
||||
}
|
||||
else { /* inverse thresholds */
|
||||
if(check_critical_value==TRUE && age_in_minutes <= critical_value)
|
||||
if(check_critical_value && age_in_minutes <= critical_value)
|
||||
return_code=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
|
||||
else if (check_warning_value && age_in_minutes <= warning_value)
|
||||
return_code=STATE_WARNING;
|
||||
else
|
||||
return_code=STATE_OK;
|
||||
|
@ -600,15 +600,15 @@ int process_arguments(int argc, char **argv){
|
|||
break;
|
||||
case 'w': /* warning threshold */
|
||||
warning_value=strtoul(optarg,NULL,10);
|
||||
check_warning_value=TRUE;
|
||||
check_warning_value=true;
|
||||
break;
|
||||
case 'c': /* critical threshold */
|
||||
critical_value=strtoul(optarg,NULL,10);
|
||||
check_critical_value=TRUE;
|
||||
check_critical_value=true;
|
||||
break;
|
||||
case 'd': /* Display select for services */
|
||||
if (!strcmp(optarg,"SHOWALL"))
|
||||
show_all = TRUE;
|
||||
show_all = true;
|
||||
break;
|
||||
case 'u':
|
||||
socket_timeout_state=STATE_UNKNOWN;
|
||||
|
@ -646,7 +646,7 @@ void fetch_data (const char *address, int port, const char *sendb) {
|
|||
die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer);
|
||||
}
|
||||
|
||||
int strtoularray(unsigned long *array, char *string, const char *delim) {
|
||||
bool strtoularray(unsigned long *array, char *string, const char *delim) {
|
||||
/* split a <delim> delimited string into a long array */
|
||||
int idx=0;
|
||||
char *t1;
|
||||
|
@ -660,9 +660,9 @@ int strtoularray(unsigned long *array, char *string, const char *delim) {
|
|||
array[idx]=strtoul(t1,NULL,10);
|
||||
idx++;
|
||||
} else
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void preparelist(char *string) {
|
||||
|
|
|
@ -40,10 +40,10 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
|
||||
static char *server_address=NULL;
|
||||
static int verbose=0;
|
||||
static short do_offset=0;
|
||||
static bool do_offset = false;
|
||||
static char *owarn="60";
|
||||
static char *ocrit="120";
|
||||
static short do_jitter=0;
|
||||
static bool do_jitter = false;
|
||||
static char *jwarn="5000";
|
||||
static char *jcrit="10000";
|
||||
|
||||
|
@ -513,7 +513,8 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
|
|||
|
||||
/* XXX handle responses with the error bit set */
|
||||
double jitter_request(int *status){
|
||||
int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
|
||||
int conn=-1, i, npeers=0, num_candidates=0;
|
||||
bool syncsource_found = false;
|
||||
int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
|
||||
int peers_size=0, peer_offset=0;
|
||||
ntp_assoc_status_pair *peers=NULL;
|
||||
|
@ -570,7 +571,7 @@ double jitter_request(int *status){
|
|||
if (PEER_SEL(peers[i].status) >= PEER_INCLUDED){
|
||||
num_candidates++;
|
||||
if(PEER_SEL(peers[i].status) >= PEER_SYNCSOURCE){
|
||||
syncsource_found=1;
|
||||
syncsource_found = true;
|
||||
min_peer_sel=PEER_SYNCSOURCE;
|
||||
}
|
||||
}
|
||||
|
@ -699,23 +700,23 @@ int process_arguments(int argc, char **argv){
|
|||
verbose++;
|
||||
break;
|
||||
case 'w':
|
||||
do_offset=1;
|
||||
do_offset = true;
|
||||
owarn = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
do_offset=1;
|
||||
do_offset = true;
|
||||
ocrit = optarg;
|
||||
break;
|
||||
case 'j':
|
||||
do_jitter=1;
|
||||
do_jitter = true;
|
||||
jwarn = optarg;
|
||||
break;
|
||||
case 'k':
|
||||
do_jitter=1;
|
||||
do_jitter = true;
|
||||
jcrit = optarg;
|
||||
break;
|
||||
case 'H':
|
||||
if(is_host(optarg) == FALSE)
|
||||
if(!is_host(optarg))
|
||||
usage2(_("Invalid hostname/address"), optarg);
|
||||
server_address = strdup(optarg);
|
||||
break;
|
||||
|
@ -749,9 +750,9 @@ int process_arguments(int argc, char **argv){
|
|||
char *perfd_offset (double offset)
|
||||
{
|
||||
return fperfdata ("offset", offset, "s",
|
||||
TRUE, offset_thresholds->warning->end,
|
||||
TRUE, offset_thresholds->critical->end,
|
||||
FALSE, 0, FALSE, 0);
|
||||
true, offset_thresholds->warning->end,
|
||||
true, offset_thresholds->critical->end,
|
||||
false, 0, false, 0);
|
||||
}
|
||||
|
||||
char *perfd_jitter (double jitter)
|
||||
|
@ -759,7 +760,7 @@ char *perfd_jitter (double jitter)
|
|||
return fperfdata ("jitter", jitter, "s",
|
||||
do_jitter, jitter_thresholds->warning->end,
|
||||
do_jitter, jitter_thresholds->critical->end,
|
||||
TRUE, 0, FALSE, 0);
|
||||
true, 0, false, 0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
|
|
|
@ -46,21 +46,20 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
static char *server_address=NULL;
|
||||
static int port=123;
|
||||
static int verbose=0;
|
||||
static int quiet=0;
|
||||
static short do_offset=0;
|
||||
static bool quiet = false;
|
||||
static char *owarn="60";
|
||||
static char *ocrit="120";
|
||||
static short do_stratum=0;
|
||||
static bool do_stratum = false;
|
||||
static char *swarn="-1:16";
|
||||
static char *scrit="-1:16";
|
||||
static short do_jitter=0;
|
||||
static bool do_jitter = false;
|
||||
static char *jwarn="-1:5000";
|
||||
static char *jcrit="-1:10000";
|
||||
static short do_truechimers=0;
|
||||
static bool do_truechimers = false;
|
||||
static char *twarn="0:";
|
||||
static char *tcrit="0:";
|
||||
static int syncsource_found=0;
|
||||
static int li_alarm=0;
|
||||
static bool syncsource_found = false;
|
||||
static bool li_alarm = false;
|
||||
|
||||
int process_arguments (int, char **);
|
||||
thresholds *offset_thresholds = NULL;
|
||||
|
@ -254,7 +253,7 @@ int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum
|
|||
die(STATE_CRITICAL, "NTP CRITICAL: Invalid packet received from NTP server\n");
|
||||
} while (!(req.op&OP_READSTAT && ntohs(req.seq) == 1));
|
||||
|
||||
if (LI(req.flags) == LI_ALARM) li_alarm = 1;
|
||||
if (LI(req.flags) == LI_ALARM) li_alarm = true;
|
||||
/* Each peer identifier is 4 bytes in the data section, which
|
||||
* we represent as a ntp_assoc_status_pair datatype.
|
||||
*/
|
||||
|
@ -276,7 +275,7 @@ int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum
|
|||
if(PEER_SEL(peers[i].status) >= PEER_INCLUDED){
|
||||
num_candidates++;
|
||||
if(PEER_SEL(peers[i].status) >= PEER_SYNCSOURCE){
|
||||
syncsource_found=1;
|
||||
syncsource_found = true;
|
||||
min_peer_sel=PEER_SYNCSOURCE;
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +439,7 @@ int process_arguments(int argc, char **argv){
|
|||
if (argc < 2)
|
||||
usage ("\n");
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
c = getopt_long (argc, argv, "Vhv46qw:c:W:C:j:k:m:n:t:H:p:", longopts, &option);
|
||||
if (c == -1 || c == EOF || c == 1)
|
||||
break;
|
||||
|
@ -458,42 +457,40 @@ int process_arguments(int argc, char **argv){
|
|||
verbose++;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
quiet = true;
|
||||
break;
|
||||
case 'w':
|
||||
do_offset=1;
|
||||
owarn = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
do_offset=1;
|
||||
ocrit = optarg;
|
||||
break;
|
||||
case 'W':
|
||||
do_stratum=1;
|
||||
do_stratum = true;
|
||||
swarn = optarg;
|
||||
break;
|
||||
case 'C':
|
||||
do_stratum=1;
|
||||
do_stratum = true;
|
||||
scrit = optarg;
|
||||
break;
|
||||
case 'j':
|
||||
do_jitter=1;
|
||||
do_jitter = true;
|
||||
jwarn = optarg;
|
||||
break;
|
||||
case 'k':
|
||||
do_jitter=1;
|
||||
do_jitter = true;
|
||||
jcrit = optarg;
|
||||
break;
|
||||
case 'm':
|
||||
do_truechimers=1;
|
||||
do_truechimers = true;
|
||||
twarn = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
do_truechimers=1;
|
||||
do_truechimers = true;
|
||||
tcrit = optarg;
|
||||
break;
|
||||
case 'H':
|
||||
if(is_host(optarg) == FALSE)
|
||||
if(!is_host(optarg))
|
||||
usage2(_("Invalid hostname/address"), optarg);
|
||||
server_address = strdup(optarg);
|
||||
break;
|
||||
|
@ -530,9 +527,9 @@ int process_arguments(int argc, char **argv){
|
|||
char *perfd_offset (double offset)
|
||||
{
|
||||
return fperfdata ("offset", offset, "s",
|
||||
TRUE, offset_thresholds->warning->end,
|
||||
TRUE, offset_thresholds->critical->end,
|
||||
FALSE, 0, FALSE, 0);
|
||||
true, offset_thresholds->warning->end,
|
||||
true, offset_thresholds->critical->end,
|
||||
false, 0, false, 0);
|
||||
}
|
||||
|
||||
char *perfd_jitter (double jitter)
|
||||
|
@ -540,7 +537,7 @@ char *perfd_jitter (double jitter)
|
|||
return fperfdata ("jitter", jitter, "",
|
||||
do_jitter, jitter_thresholds->warning->end,
|
||||
do_jitter, jitter_thresholds->critical->end,
|
||||
TRUE, 0, FALSE, 0);
|
||||
true, 0, false, 0);
|
||||
}
|
||||
|
||||
char *perfd_stratum (int stratum)
|
||||
|
@ -548,7 +545,7 @@ char *perfd_stratum (int stratum)
|
|||
return perfdata ("stratum", stratum, "",
|
||||
do_stratum, (int)stratum_thresholds->warning->end,
|
||||
do_stratum, (int)stratum_thresholds->critical->end,
|
||||
TRUE, 0, TRUE, 16);
|
||||
true, 0, true, 16);
|
||||
}
|
||||
|
||||
char *perfd_truechimers (int num_truechimers)
|
||||
|
@ -556,11 +553,11 @@ char *perfd_truechimers (int num_truechimers)
|
|||
return perfdata ("truechimers", num_truechimers, "",
|
||||
do_truechimers, (int)truechimer_thresholds->warning->end,
|
||||
do_truechimers, (int)truechimer_thresholds->critical->end,
|
||||
TRUE, 0, FALSE, 0);
|
||||
true, 0, false, 0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int result, offset_result, stratum, num_truechimers, oresult, jresult, sresult, tresult;
|
||||
int result, offset_result, stratum, num_truechimers;
|
||||
double offset=0, jitter=0;
|
||||
char *result_line, *perfdata_line;
|
||||
|
||||
|
@ -590,25 +587,35 @@ int main(int argc, char *argv[]){
|
|||
|
||||
if(offset_result == STATE_UNKNOWN) {
|
||||
/* if there's no sync peer (this overrides ntp_request output): */
|
||||
result = (quiet == 1 ? STATE_UNKNOWN : STATE_CRITICAL);
|
||||
result = (quiet ? STATE_UNKNOWN : STATE_CRITICAL);
|
||||
} else {
|
||||
/* Be quiet if there's no candidates either */
|
||||
if (quiet == 1 && result == STATE_WARNING)
|
||||
if (quiet && result == STATE_WARNING)
|
||||
result = STATE_UNKNOWN;
|
||||
result = max_state_alt(result, get_status(fabs(offset), offset_thresholds));
|
||||
}
|
||||
oresult = result;
|
||||
|
||||
int oresult = result;
|
||||
|
||||
|
||||
int tresult = STATE_UNKNOWN;
|
||||
|
||||
if(do_truechimers) {
|
||||
tresult = get_status(num_truechimers, truechimer_thresholds);
|
||||
result = max_state_alt(result, tresult);
|
||||
}
|
||||
|
||||
|
||||
int sresult = STATE_UNKNOWN;
|
||||
|
||||
if(do_stratum) {
|
||||
sresult = get_status(stratum, stratum_thresholds);
|
||||
result = max_state_alt(result, sresult);
|
||||
}
|
||||
|
||||
|
||||
int jresult = STATE_UNKNOWN;
|
||||
|
||||
if(do_jitter) {
|
||||
jresult = get_status(jitter, jitter_thresholds);
|
||||
result = max_state_alt(result, jresult);
|
||||
|
|
|
@ -45,7 +45,7 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
static char *server_address=NULL;
|
||||
static char *port="123";
|
||||
static int verbose=0;
|
||||
static int quiet=0;
|
||||
static bool quiet = false;
|
||||
static char *owarn="60";
|
||||
static char *ocrit="120";
|
||||
static int time_offset=0;
|
||||
|
@ -485,7 +485,7 @@ int process_arguments(int argc, char **argv){
|
|||
verbose++;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
quiet = true;
|
||||
break;
|
||||
case 'w':
|
||||
owarn = optarg;
|
||||
|
@ -494,7 +494,7 @@ int process_arguments(int argc, char **argv){
|
|||
ocrit = optarg;
|
||||
break;
|
||||
case 'H':
|
||||
if(is_host(optarg) == FALSE)
|
||||
if(!is_host(optarg))
|
||||
usage2(_("Invalid hostname/address"), optarg);
|
||||
server_address = strdup(optarg);
|
||||
break;
|
||||
|
@ -531,12 +531,11 @@ int process_arguments(int argc, char **argv){
|
|||
return 0;
|
||||
}
|
||||
|
||||
char *perfd_offset (double offset)
|
||||
{
|
||||
char *perfd_offset (double offset) {
|
||||
return fperfdata ("offset", offset, "s",
|
||||
TRUE, offset_thresholds->warning->end,
|
||||
TRUE, offset_thresholds->critical->end,
|
||||
FALSE, 0, FALSE, 0);
|
||||
true, offset_thresholds->warning->end,
|
||||
true, offset_thresholds->critical->end,
|
||||
false, 0, false, 0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
|
@ -566,7 +565,7 @@ int main(int argc, char *argv[]){
|
|||
|
||||
offset = offset_request(server_address, &offset_result);
|
||||
if (offset_result == STATE_UNKNOWN) {
|
||||
result = (quiet == 1 ? STATE_UNKNOWN : STATE_CRITICAL);
|
||||
result = ( (!quiet) ? STATE_UNKNOWN : STATE_CRITICAL);
|
||||
} else {
|
||||
result = get_status(fabs(offset), offset_thresholds);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ enum checkvar {
|
|||
VPF, /* check % free space on volume */
|
||||
VMF, /* check MB free space on volume */
|
||||
VMU, /* check MB used space on volume */
|
||||
VPU, /* check % used space on volume */
|
||||
VMP, /* check MB purgeable space on volume */
|
||||
VKF, /* check KB free space on volume */
|
||||
LTCH, /* check long-term cache hit percentage */
|
||||
|
@ -104,9 +105,9 @@ char *nss7_name=NULL;
|
|||
int server_port=PORT;
|
||||
unsigned long warning_value=0L;
|
||||
unsigned long critical_value=0L;
|
||||
int check_warning_value=FALSE;
|
||||
int check_critical_value=FALSE;
|
||||
int check_netware_version=FALSE;
|
||||
bool check_warning_value = false;
|
||||
bool check_critical_value = false;
|
||||
bool check_netware_version = false;
|
||||
enum checkvar vars_to_check = NONE;
|
||||
int sap_number=-1;
|
||||
|
||||
|
@ -146,6 +147,8 @@ main(int argc, char **argv) {
|
|||
unsigned long nss6_value=0L;
|
||||
unsigned long nss7_value=0L;
|
||||
unsigned long total_disk_space=0L;
|
||||
unsigned long used_disk_space=0L;
|
||||
unsigned long percent_used_disk_space=0L;
|
||||
unsigned long purgeable_disk_space=0L;
|
||||
unsigned long non_purgeable_disk_space=0L;
|
||||
unsigned long percent_free_space=0;
|
||||
|
@ -182,7 +185,7 @@ main(int argc, char **argv) {
|
|||
my_tcp_connect (server_address, server_port, &sd);
|
||||
|
||||
/* get OS version string */
|
||||
if (check_netware_version==TRUE) {
|
||||
if (check_netware_version) {
|
||||
send_buffer = strdup ("S19\r\n");
|
||||
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
|
||||
if (result!=STATE_OK)
|
||||
|
@ -231,9 +234,9 @@ main(int argc, char **argv) {
|
|||
recv_buffer[strlen(recv_buffer)-1]=0;
|
||||
sprintf(uptime,_("Up %s,"),recv_buffer);
|
||||
|
||||
if (check_critical_value==TRUE && utilization >= critical_value)
|
||||
if (check_critical_value && utilization >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && utilization >= warning_value)
|
||||
else if (check_warning_value && utilization >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,
|
||||
|
@ -259,9 +262,9 @@ main(int argc, char **argv) {
|
|||
return result;
|
||||
current_connections=strtoul(recv_buffer,NULL,10);
|
||||
|
||||
if (check_critical_value==TRUE && current_connections >= critical_value)
|
||||
if (check_critical_value && current_connections >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && current_connections >= warning_value)
|
||||
else if (check_warning_value && current_connections >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,
|
||||
|
@ -284,9 +287,9 @@ main(int argc, char **argv) {
|
|||
return result;
|
||||
cache_hits=atoi(recv_buffer);
|
||||
|
||||
if (check_critical_value==TRUE && cache_hits <= critical_value)
|
||||
if (check_critical_value && cache_hits <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && cache_hits <= warning_value)
|
||||
else if (check_warning_value && cache_hits <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,
|
||||
|
@ -306,9 +309,9 @@ main(int argc, char **argv) {
|
|||
return result;
|
||||
cache_buffers=strtoul(recv_buffer,NULL,10);
|
||||
|
||||
if (check_critical_value==TRUE && cache_buffers <= critical_value)
|
||||
if (check_critical_value && cache_buffers <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && cache_buffers <= warning_value)
|
||||
else if (check_warning_value && cache_buffers <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,
|
||||
|
@ -331,9 +334,9 @@ main(int argc, char **argv) {
|
|||
return result;
|
||||
cache_buffers=strtoul(recv_buffer,NULL,10);
|
||||
|
||||
if (check_critical_value==TRUE && cache_buffers >= critical_value)
|
||||
if (check_critical_value && cache_buffers >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && cache_buffers >= warning_value)
|
||||
else if (check_warning_value && cache_buffers >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,
|
||||
|
@ -356,9 +359,9 @@ main(int argc, char **argv) {
|
|||
return result;
|
||||
lru_time=strtoul(recv_buffer,NULL,10);
|
||||
|
||||
if (check_critical_value==TRUE && lru_time <= critical_value)
|
||||
if (check_critical_value && lru_time <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && lru_time <= warning_value)
|
||||
else if (check_warning_value && lru_time <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,
|
||||
|
@ -383,9 +386,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
free_disk_space=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && free_disk_space <= critical_value)
|
||||
if (check_critical_value && free_disk_space <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && free_disk_space <= warning_value)
|
||||
else if (check_warning_value && free_disk_space <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"),
|
||||
|
@ -411,9 +414,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
free_disk_space=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && free_disk_space <= critical_value)
|
||||
if (check_critical_value && free_disk_space <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && free_disk_space <= warning_value)
|
||||
else if (check_warning_value && free_disk_space <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"),
|
||||
|
@ -438,9 +441,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
free_disk_space=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && free_disk_space <= critical_value)
|
||||
if (check_critical_value && free_disk_space <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && free_disk_space <= warning_value)
|
||||
else if (check_warning_value && free_disk_space <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"),
|
||||
|
@ -452,7 +455,50 @@ main(int argc, char **argv) {
|
|||
warning_value,
|
||||
critical_value);
|
||||
}
|
||||
/* check % used space on volume */
|
||||
} else if (vars_to_check==VPU) {
|
||||
close(sd);
|
||||
my_tcp_connect (server_address, server_port, &sd);
|
||||
|
||||
asprintf (&send_buffer,"VMU%s\r\n",volume_name);
|
||||
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
|
||||
|
||||
if (result!=STATE_OK)
|
||||
return result;
|
||||
|
||||
if (!strcmp(recv_buffer,"-1\n")) {
|
||||
asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
|
||||
result=STATE_CRITICAL;
|
||||
|
||||
} else {
|
||||
used_disk_space=strtoul(recv_buffer,NULL,10);
|
||||
close(sd);
|
||||
my_tcp_connect (server_address, server_port, &sd);
|
||||
/* get total volume in MB */
|
||||
asprintf (&send_buffer,"VMS%s\r\n",volume_name);
|
||||
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
|
||||
if (result!=STATE_OK)
|
||||
return result;
|
||||
total_disk_space=strtoul(recv_buffer,NULL,10);
|
||||
/* calculate percent used on volume */
|
||||
percent_used_disk_space=(unsigned long)(((double)used_disk_space/(double)total_disk_space)*100.0);
|
||||
|
||||
if (check_critical_value && percent_used_disk_space >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value && percent_used_disk_space >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
asprintf (&output_message,_("%lu MB (%lu%%) used on volume %s - total %lu MB|Used space in percent on %s=%lu;%lu;%lu;0;100"),
|
||||
used_disk_space,
|
||||
percent_used_disk_space,
|
||||
volume_name,
|
||||
total_disk_space,
|
||||
volume_name,
|
||||
percent_used_disk_space,
|
||||
warning_value,
|
||||
critical_value
|
||||
);
|
||||
}
|
||||
|
||||
/* check % free space on volume */
|
||||
} else if (vars_to_check==VPF) {
|
||||
|
@ -485,9 +531,9 @@ main(int argc, char **argv) {
|
|||
|
||||
percent_free_space=(unsigned long)(((double)free_disk_space/(double)total_disk_space)*100.0);
|
||||
|
||||
if (check_critical_value==TRUE && percent_free_space <= critical_value)
|
||||
if (check_critical_value && percent_free_space <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && percent_free_space <= warning_value)
|
||||
else if (check_warning_value && percent_free_space <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
free_disk_space/=1024;
|
||||
total_disk_space/=1024;
|
||||
|
@ -596,14 +642,14 @@ main(int argc, char **argv) {
|
|||
percent_used_packet_receive_buffers=(unsigned long)(((double)used_packet_receive_buffers/(double)max_packet_receive_buffers)*100.0);
|
||||
|
||||
if (vars_to_check==UPRB) {
|
||||
if (check_critical_value==TRUE && used_packet_receive_buffers >= critical_value)
|
||||
if (check_critical_value && used_packet_receive_buffers >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && used_packet_receive_buffers >= warning_value)
|
||||
else if (check_warning_value && used_packet_receive_buffers >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
} else {
|
||||
if (check_critical_value==TRUE && percent_used_packet_receive_buffers >= critical_value)
|
||||
if (check_critical_value && percent_used_packet_receive_buffers >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && percent_used_packet_receive_buffers >= warning_value)
|
||||
else if (check_warning_value && percent_used_packet_receive_buffers >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
}
|
||||
|
||||
|
@ -625,9 +671,9 @@ main(int argc, char **argv) {
|
|||
|
||||
sap_entries=atoi(recv_buffer);
|
||||
|
||||
if (check_critical_value==TRUE && sap_entries >= critical_value)
|
||||
if (check_critical_value && sap_entries >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && sap_entries >= warning_value)
|
||||
else if (check_warning_value && sap_entries >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
if (sap_number==-1)
|
||||
|
@ -651,9 +697,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
purgeable_disk_space=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && purgeable_disk_space >= critical_value)
|
||||
if (check_critical_value && purgeable_disk_space >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value)
|
||||
else if (check_warning_value && purgeable_disk_space >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,_("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
|
||||
(result==STATE_OK)?"":_("Only "),
|
||||
|
@ -677,9 +723,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
purgeable_disk_space=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && purgeable_disk_space >= critical_value)
|
||||
if (check_critical_value && purgeable_disk_space >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value)
|
||||
else if (check_warning_value && purgeable_disk_space >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,_("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
|
||||
(result==STATE_OK)?"":_("Only "),
|
||||
|
@ -722,9 +768,9 @@ main(int argc, char **argv) {
|
|||
|
||||
percent_purgeable_space=(unsigned long)(((double)purgeable_disk_space/(double)total_disk_space)*100.0);
|
||||
|
||||
if (check_critical_value==TRUE && percent_purgeable_space >= critical_value)
|
||||
if (check_critical_value && percent_purgeable_space >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && percent_purgeable_space >= warning_value)
|
||||
else if (check_warning_value && percent_purgeable_space >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
purgeable_disk_space/=1024;
|
||||
xasprintf (&output_message,_("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"),
|
||||
|
@ -754,9 +800,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
non_purgeable_disk_space=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && non_purgeable_disk_space >= critical_value)
|
||||
if (check_critical_value && non_purgeable_disk_space >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && non_purgeable_disk_space >= warning_value)
|
||||
else if (check_warning_value && non_purgeable_disk_space >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,_("%s%lu KB not yet purgeable on volume %s"),(result==STATE_OK)?"":_("Only "),non_purgeable_disk_space,volume_name);
|
||||
}
|
||||
|
@ -792,9 +838,9 @@ main(int argc, char **argv) {
|
|||
|
||||
percent_non_purgeable_space=(unsigned long)(((double)non_purgeable_disk_space/(double)total_disk_space)*100.0);
|
||||
|
||||
if (check_critical_value==TRUE && percent_non_purgeable_space >= critical_value)
|
||||
if (check_critical_value && percent_non_purgeable_space >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && percent_non_purgeable_space >= warning_value)
|
||||
else if (check_warning_value && percent_non_purgeable_space >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
purgeable_disk_space/=1024;
|
||||
xasprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name);
|
||||
|
@ -813,9 +859,9 @@ main(int argc, char **argv) {
|
|||
|
||||
open_files=atoi(recv_buffer);
|
||||
|
||||
if (check_critical_value==TRUE && open_files >= critical_value)
|
||||
if (check_critical_value && open_files >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && open_files >= warning_value)
|
||||
else if (check_warning_value && open_files >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,_("%lu open files|Openfiles=%lu;%lu;%lu;0,0"),
|
||||
|
@ -838,9 +884,9 @@ main(int argc, char **argv) {
|
|||
|
||||
abended_threads=atoi(recv_buffer);
|
||||
|
||||
if (check_critical_value==TRUE && abended_threads >= critical_value)
|
||||
if (check_critical_value && abended_threads >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && abended_threads >= warning_value)
|
||||
else if (check_warning_value && abended_threads >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,_("%lu abended threads|Abends=%lu;%lu;%lu;;"),
|
||||
|
@ -872,9 +918,9 @@ main(int argc, char **argv) {
|
|||
|
||||
current_service_processes=atoi(recv_buffer);
|
||||
|
||||
if (check_critical_value==TRUE && current_service_processes >= critical_value)
|
||||
if (check_critical_value && current_service_processes >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && current_service_processes >= warning_value)
|
||||
else if (check_warning_value && current_service_processes >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
|
||||
xasprintf (&output_message,
|
||||
|
@ -923,9 +969,9 @@ main(int argc, char **argv) {
|
|||
return result;
|
||||
lru_time=strtoul(recv_buffer,NULL,10);
|
||||
|
||||
if (check_critical_value==TRUE && lru_time <= critical_value)
|
||||
if (check_critical_value && lru_time <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && lru_time <= warning_value)
|
||||
else if (check_warning_value && lru_time <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,_("LRU sitting time = %lu seconds"),lru_time);
|
||||
|
||||
|
@ -942,9 +988,9 @@ main(int argc, char **argv) {
|
|||
return result;
|
||||
dirty_cache_buffers=atoi(recv_buffer);
|
||||
|
||||
if (check_critical_value==TRUE && dirty_cache_buffers <= critical_value)
|
||||
if (check_critical_value && dirty_cache_buffers <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && dirty_cache_buffers <= warning_value)
|
||||
else if (check_warning_value && dirty_cache_buffers <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,_("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"),
|
||||
dirty_cache_buffers,
|
||||
|
@ -964,9 +1010,9 @@ main(int argc, char **argv) {
|
|||
return result;
|
||||
total_cache_buffers=atoi(recv_buffer);
|
||||
|
||||
if (check_critical_value==TRUE && total_cache_buffers <= critical_value)
|
||||
if (check_critical_value && total_cache_buffers <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && total_cache_buffers <= warning_value)
|
||||
else if (check_warning_value && total_cache_buffers <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,_("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"),
|
||||
total_cache_buffers,
|
||||
|
@ -1034,9 +1080,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nrmp_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nrmp_value <= critical_value)
|
||||
if (check_critical_value && nrmp_value <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nrmp_value <= warning_value)
|
||||
else if (check_warning_value && nrmp_value <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1060,9 +1106,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nrmm_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nrmm_value <= critical_value)
|
||||
if (check_critical_value && nrmm_value <= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nrmm_value <= warning_value)
|
||||
else if (check_warning_value && nrmm_value <= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1086,9 +1132,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nrms_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nrms_value >= critical_value)
|
||||
if (check_critical_value && nrms_value >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nrms_value >= warning_value)
|
||||
else if (check_warning_value && nrms_value >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1112,9 +1158,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nss1_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nss1_value >= critical_value)
|
||||
if (check_critical_value && nss1_value >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nss1_value >= warning_value)
|
||||
else if (check_warning_value && nss1_value >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1138,9 +1184,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nss2_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nss2_value >= critical_value)
|
||||
if (check_critical_value && nss2_value >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nss2_value >= warning_value)
|
||||
else if (check_warning_value && nss2_value >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1164,9 +1210,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nss3_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nss3_value >= critical_value)
|
||||
if (check_critical_value && nss3_value >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nss3_value >= warning_value)
|
||||
else if (check_warning_value && nss3_value >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1190,9 +1236,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nss4_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nss4_value >= critical_value)
|
||||
if (check_critical_value && nss4_value >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nss4_value >= warning_value)
|
||||
else if (check_warning_value && nss4_value >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1216,9 +1262,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nss5_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nss5_value >= critical_value)
|
||||
if (check_critical_value && nss5_value >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nss5_value >= warning_value)
|
||||
else if (check_warning_value && nss5_value >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1242,9 +1288,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nss6_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nss6_value >= critical_value)
|
||||
if (check_critical_value && nss6_value >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nss6_value >= warning_value)
|
||||
else if (check_warning_value && nss6_value >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1268,9 +1314,9 @@ main(int argc, char **argv) {
|
|||
result=STATE_CRITICAL;
|
||||
} else {
|
||||
nss7_value=strtoul(recv_buffer,NULL,10);
|
||||
if (check_critical_value==TRUE && nss7_value >= critical_value)
|
||||
if (check_critical_value && nss7_value >= critical_value)
|
||||
result=STATE_CRITICAL;
|
||||
else if (check_warning_value==TRUE && nss7_value >= warning_value)
|
||||
else if (check_warning_value && nss7_value >= warning_value)
|
||||
result=STATE_WARNING;
|
||||
xasprintf (&output_message,
|
||||
_("%s is %lu|%s=%lu;%lu;%lu;;"),
|
||||
|
@ -1362,7 +1408,7 @@ int process_arguments(int argc, char **argv) {
|
|||
server_address=optarg;
|
||||
break;
|
||||
case 'o': /* display nos version */
|
||||
check_netware_version=TRUE;
|
||||
check_netware_version = true;
|
||||
break;
|
||||
case 'p': /* port */
|
||||
if (is_intnonneg(optarg))
|
||||
|
@ -1450,6 +1496,12 @@ int process_arguments(int argc, char **argv) {
|
|||
if (!strcmp(volume_name,""))
|
||||
volume_name = strdup ("SYS");
|
||||
}
|
||||
else if (strncmp(optarg,"VPU",3)==0) {
|
||||
vars_to_check=VPU;
|
||||
volume_name = strdup (optarg+3);
|
||||
if (!strcmp(volume_name,""))
|
||||
volume_name = strdup ("SYS");
|
||||
}
|
||||
else if (strncmp(optarg,"VPP",3)==0) {
|
||||
vars_to_check=VPP;
|
||||
volume_name = strdup (optarg+3);
|
||||
|
@ -1569,11 +1621,11 @@ int process_arguments(int argc, char **argv) {
|
|||
break;
|
||||
case 'w': /* warning threshold */
|
||||
warning_value=strtoul(optarg,NULL,10);
|
||||
check_warning_value=TRUE;
|
||||
check_warning_value = true;
|
||||
break;
|
||||
case 'c': /* critical threshold */
|
||||
critical_value=strtoul(optarg,NULL,10);
|
||||
check_critical_value=TRUE;
|
||||
check_critical_value = true;
|
||||
break;
|
||||
case 't': /* timeout */
|
||||
socket_timeout=atoi(optarg);
|
||||
|
@ -1626,6 +1678,7 @@ void print_help(void)
|
|||
printf (" %s\n", _("OFILES = number of open files"));
|
||||
printf (" %s\n", _(" VMF<vol> = MB of free space on Volume <vol>"));
|
||||
printf (" %s\n", _(" VMU<vol> = MB used space on Volume <vol>"));
|
||||
printf (" %s\n", _(" VPU<vol> = percent used space on Volume <vol>"));
|
||||
printf (" %s\n", _(" VMP<vol> = MB of purgeable space on Volume <vol>"));
|
||||
printf (" %s\n", _(" VPF<vol> = percent free space on volume <vol>"));
|
||||
printf (" %s\n", _(" VKF<vol> = KB of free space on volume <vol>"));
|
||||
|
|
|
@ -56,15 +56,15 @@ char *server_address = NULL;
|
|||
int server_port = PORT;
|
||||
double warning_value = 0L;
|
||||
double critical_value = 0L;
|
||||
int check_warning_value = FALSE;
|
||||
int check_critical_value = FALSE;
|
||||
bool check_warning_value = false;
|
||||
bool check_critical_value = false;
|
||||
enum checkvar vars_to_check = NONE;
|
||||
int cmd_timeout = 1;
|
||||
|
||||
int netstat_port = 0;
|
||||
char *disk_name = NULL;
|
||||
char *process_name = NULL;
|
||||
char send_buffer[MAX_INPUT_BUFFER];
|
||||
char send_buffer[MAX_INPUT_BUFFER];
|
||||
|
||||
int process_arguments (int, char **);
|
||||
void print_usage (void);
|
||||
|
@ -77,7 +77,7 @@ main (int argc, char **argv)
|
|||
char recv_buffer[MAX_INPUT_BUFFER];
|
||||
char temp_buffer[MAX_INPUT_BUFFER];
|
||||
char *temp_ptr = NULL;
|
||||
int found_disk = FALSE;
|
||||
bool found_disk = false;
|
||||
unsigned long percent_used_disk_space = 100;
|
||||
double load;
|
||||
double load_1min;
|
||||
|
@ -155,9 +155,9 @@ main (int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
|
||||
if (check_critical_value == TRUE && (load >= critical_value))
|
||||
if (check_critical_value && (load >= critical_value))
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_value == TRUE && (load >= warning_value))
|
||||
else if (check_warning_value && (load >= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
die (result,
|
||||
|
@ -178,7 +178,7 @@ main (int argc, char **argv)
|
|||
temp_ptr = (char *) strtok (NULL, " ")) {
|
||||
|
||||
if (!strcmp (temp_ptr, disk_name)) {
|
||||
found_disk = TRUE;
|
||||
found_disk = true;
|
||||
temp_ptr = (char *) strtok (NULL, "%");
|
||||
if (temp_ptr == NULL)
|
||||
die (STATE_CRITICAL, _("Invalid response from server\n"));
|
||||
|
@ -191,14 +191,14 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* error if we couldn't find the info for the disk */
|
||||
if (found_disk == FALSE)
|
||||
if (!found_disk)
|
||||
die (STATE_CRITICAL,
|
||||
"CRITICAL - Disk '%s' non-existent or not mounted",
|
||||
disk_name);
|
||||
|
||||
if (check_critical_value == TRUE && (percent_used_disk_space >= critical_value))
|
||||
if (check_critical_value && (percent_used_disk_space >= critical_value))
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_value == TRUE && (percent_used_disk_space >= warning_value))
|
||||
else if (check_warning_value && (percent_used_disk_space >= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
die (result, "Disk %s - %lu%% used on %s", state_text(result), percent_used_disk_space, disk_name);
|
||||
|
@ -212,9 +212,9 @@ main (int argc, char **argv)
|
|||
else
|
||||
port_connections = strtod (recv_buffer, NULL);
|
||||
|
||||
if (check_critical_value == TRUE && (port_connections >= critical_value))
|
||||
if (check_critical_value && (port_connections >= critical_value))
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_value == TRUE && (port_connections >= warning_value))
|
||||
else if (check_warning_value && (port_connections >= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
die (result,
|
||||
|
@ -241,9 +241,9 @@ main (int argc, char **argv)
|
|||
else
|
||||
processes = strtod (temp_ptr, NULL);
|
||||
|
||||
if (check_critical_value == TRUE && (processes >= critical_value))
|
||||
if (check_critical_value && (processes >= critical_value))
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_value == TRUE && (processes >= warning_value))
|
||||
else if (check_warning_value && (processes >= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
die (result,
|
||||
|
@ -262,9 +262,9 @@ main (int argc, char **argv)
|
|||
uptime_raw_hours = strtod (recv_buffer, NULL);
|
||||
uptime_raw_minutes = (unsigned long) (uptime_raw_hours * 60.0);
|
||||
|
||||
if (check_critical_value == TRUE && (uptime_raw_minutes <= critical_value))
|
||||
if (check_critical_value && (uptime_raw_minutes <= critical_value))
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_value == TRUE && (uptime_raw_minutes <= warning_value))
|
||||
else if (check_warning_value && (uptime_raw_minutes <= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
uptime_days = uptime_raw_minutes / 1440;
|
||||
|
@ -388,11 +388,11 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'w': /* warning threshold */
|
||||
warning_value = strtoul (optarg, NULL, 10);
|
||||
check_warning_value = TRUE;
|
||||
check_warning_value = true;
|
||||
break;
|
||||
case 'c': /* critical threshold */
|
||||
critical_value = strtoul (optarg, NULL, 10);
|
||||
check_critical_value = TRUE;
|
||||
check_critical_value = true;
|
||||
break;
|
||||
case 't': /* timeout */
|
||||
socket_timeout = atoi (optarg);
|
||||
|
|
|
@ -69,7 +69,7 @@ int process_arguments (int, char **);
|
|||
int validate_arguments (void);
|
||||
void print_usage (void);
|
||||
void print_help (void);
|
||||
int is_pg_logname (char *);
|
||||
bool is_pg_logname (char *);
|
||||
int do_query (PGconn *, char *);
|
||||
|
||||
char *pghost = NULL; /* host name of the backend server */
|
||||
|
@ -252,7 +252,7 @@ main (int argc, char **argv)
|
|||
printf (_(" %s - database %s (%f sec.)|%s\n"),
|
||||
state_text(status), dbName, elapsed_time,
|
||||
fperfdata("time", elapsed_time, "s",
|
||||
!!(twarn > 0.0), twarn, !!(tcrit > 0.0), tcrit, TRUE, 0, FALSE,0));
|
||||
!!(twarn > 0.0), twarn, !!(tcrit > 0.0), tcrit, true, 0, false,0));
|
||||
|
||||
if (pgquery)
|
||||
query_status = do_query (conn, pgquery);
|
||||
|
@ -393,7 +393,7 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
<para>&PROTO_validate_arguments;</para>
|
||||
|
||||
<para>Given a database name, this function returns TRUE if the string
|
||||
<para>Given a database name, this function returns true if the string
|
||||
is a valid PostgreSQL database name, and returns false if it is
|
||||
not.</para>
|
||||
|
||||
|
@ -424,7 +424,7 @@ function prototype
|
|||
|
||||
<para>&PROTO_is_pg_logname;</para>
|
||||
|
||||
<para>Given a username, this function returns TRUE if the string is a
|
||||
<para>Given a username, this function returns true if the string is a
|
||||
valid PostgreSQL username, and returns false if it is not. Valid PostgreSQL
|
||||
usernames are less than &NAMEDATALEN; characters long and consist of
|
||||
letters, numbers, dashes, and underscores, plus possibly some other
|
||||
|
@ -439,12 +439,10 @@ should be added.</para>
|
|||
|
||||
|
||||
|
||||
int
|
||||
is_pg_logname (char *username)
|
||||
{
|
||||
bool is_pg_logname (char *username) {
|
||||
if (strlen (username) > NAMEDATALEN - 1)
|
||||
return (FALSE);
|
||||
return (TRUE);
|
||||
return (false);
|
||||
return (true);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
@ -55,7 +55,7 @@ int error_scan (char buf[MAX_INPUT_BUFFER], const char *addr);
|
|||
void print_usage (void);
|
||||
void print_help (void);
|
||||
|
||||
int display_html = FALSE;
|
||||
bool display_html = false;
|
||||
int wpl = UNKNOWN_PACKET_LOSS;
|
||||
int cpl = UNKNOWN_PACKET_LOSS;
|
||||
float wrta = UNKNOWN_TRIP_TIME;
|
||||
|
@ -153,7 +153,7 @@ main (int argc, char **argv)
|
|||
if (n_addresses > 1 && this_result != STATE_UNKNOWN)
|
||||
die (STATE_OK, "%s is alive\n", addresses[i]);
|
||||
|
||||
if (display_html == TRUE)
|
||||
if (display_html == true)
|
||||
printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, addresses[i]);
|
||||
if (pl == 100)
|
||||
printf (_("PING %s - %sPacket loss = %d%%"), state_text (this_result), warn_text,
|
||||
|
@ -161,22 +161,22 @@ main (int argc, char **argv)
|
|||
else
|
||||
printf (_("PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"),
|
||||
state_text (this_result), warn_text, pl, rta);
|
||||
if (display_html == TRUE)
|
||||
if (display_html == true)
|
||||
printf ("</A>");
|
||||
|
||||
/* Print performance data */
|
||||
if (pl != 100) {
|
||||
printf("|%s", fperfdata ("rta", (double) rta, "ms",
|
||||
wrta>0?TRUE:FALSE, wrta,
|
||||
crta>0?TRUE:FALSE, crta,
|
||||
TRUE, 0, FALSE, 0));
|
||||
wrta>0?true:false, wrta,
|
||||
crta>0?true:false, crta,
|
||||
true, 0, false, 0));
|
||||
} else {
|
||||
printf("| rta=U;%f;%f;;", wrta, crta);
|
||||
}
|
||||
printf(" %s\n", perfdata ("pl", (long) pl, "%",
|
||||
wpl>0?TRUE:FALSE, wpl,
|
||||
cpl>0?TRUE:FALSE, cpl,
|
||||
TRUE, 0, FALSE, 0));
|
||||
wpl>0?true:false, wpl,
|
||||
cpl>0?true:false, cpl,
|
||||
true, 0, false, 0));
|
||||
|
||||
if (verbose >= 2)
|
||||
printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl);
|
||||
|
@ -278,10 +278,10 @@ process_arguments (int argc, char **argv)
|
|||
usage2 (_("<max_packets> (%s) must be a non-negative number\n"), optarg);
|
||||
break;
|
||||
case 'n': /* no HTML */
|
||||
display_html = FALSE;
|
||||
display_html = false;
|
||||
break;
|
||||
case 'L': /* show HTML */
|
||||
display_html = TRUE;
|
||||
display_html = true;
|
||||
break;
|
||||
case 'c':
|
||||
get_threshold (optarg, &crta, &cpl);
|
||||
|
@ -297,7 +297,7 @@ process_arguments (int argc, char **argv)
|
|||
return validate_arguments ();
|
||||
|
||||
if (addresses[0] == NULL) {
|
||||
if (is_host (argv[c]) == FALSE) {
|
||||
if (!is_host (argv[c])) {
|
||||
usage2 (_("Invalid hostname/address"), argv[c]);
|
||||
} else {
|
||||
addresses[0] = argv[c++];
|
||||
|
@ -308,7 +308,7 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
if (wpl == UNKNOWN_PACKET_LOSS) {
|
||||
if (is_intpercent (argv[c]) == FALSE) {
|
||||
if (!is_intpercent (argv[c])) {
|
||||
printf (_("<wpl> (%s) must be an integer percentage\n"), argv[c]);
|
||||
return ERROR;
|
||||
} else {
|
||||
|
@ -319,7 +319,7 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
if (cpl == UNKNOWN_PACKET_LOSS) {
|
||||
if (is_intpercent (argv[c]) == FALSE) {
|
||||
if (!is_intpercent (argv[c])) {
|
||||
printf (_("<cpl> (%s) must be an integer percentage\n"), argv[c]);
|
||||
return ERROR;
|
||||
} else {
|
||||
|
@ -420,7 +420,7 @@ validate_arguments ()
|
|||
timeout_interval = (int)max_seconds;
|
||||
|
||||
for (i=0; i<n_addresses; i++) {
|
||||
if (is_host(addresses[i]) == FALSE)
|
||||
if (!is_host(addresses[i]))
|
||||
usage2 (_("Invalid hostname/address"), addresses[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
* defaults to number of processes. Search filters can be applied to limit
|
||||
* the processes to check.
|
||||
*
|
||||
* The parent process, check_procs itself and any child process of
|
||||
* check_procs (ps) are excluded from any checks to prevent false positives.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
|
@ -153,7 +156,7 @@ main (int argc, char **argv)
|
|||
int expected_cols = PS_COLS - 1;
|
||||
int warn = 0; /* number of processes in warn state */
|
||||
int crit = 0; /* number of processes in crit state */
|
||||
int i = 0, j = 0;
|
||||
int i = 0;
|
||||
int result = STATE_UNKNOWN;
|
||||
int ret = 0;
|
||||
output chld_out, chld_err;
|
||||
|
@ -207,7 +210,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* flush first line: j starts at 1 */
|
||||
for (j = 1; j < chld_out.lines; j++) {
|
||||
for (size_t j = 1; j < chld_out.lines; j++) {
|
||||
input_line = chld_out.line[j];
|
||||
|
||||
if (verbose >= 3)
|
||||
|
@ -255,6 +258,13 @@ main (int argc, char **argv)
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Ignore our own children */
|
||||
if (procppid == mypid) {
|
||||
if (verbose >= 3)
|
||||
printf("not considering - is our child\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ignore excluded processes by name */
|
||||
if(options & EXCLUDE_PROGS) {
|
||||
int found = 0;
|
||||
|
@ -728,18 +738,23 @@ convert_to_seconds(char *etime) {
|
|||
void
|
||||
print_help (void)
|
||||
{
|
||||
print_revision (progname, NP_VERSION);
|
||||
print_revision (progname, NP_VERSION);
|
||||
|
||||
printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
|
||||
printf (COPYRIGHT, copyright, email);
|
||||
printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
|
||||
printf (COPYRIGHT, copyright, email);
|
||||
|
||||
printf ("%s\n", _("Checks all processes and generates WARNING or CRITICAL states if the specified"));
|
||||
printf ("%s\n", _("Checks all processes and generates WARNING or CRITICAL states if the specified"));
|
||||
printf ("%s\n", _("metric is outside the required threshold ranges. The metric defaults to number"));
|
||||
printf ("%s\n", _("of processes. Search filters can be applied to limit the processes to check."));
|
||||
|
||||
printf ("\n\n");
|
||||
|
||||
print_usage ();
|
||||
printf ("%s\n", _("The parent process, check_procs itself and any child process of check_procs (ps)"));
|
||||
printf ("%s\n", _("are excluded from any checks to prevent false positives."));
|
||||
|
||||
printf ("\n\n");
|
||||
|
||||
print_usage ();
|
||||
|
||||
printf (UT_HELP_VRSN);
|
||||
printf (UT_EXTRA_OPTS);
|
||||
|
@ -755,11 +770,11 @@ print_help (void)
|
|||
printf (" %s\n", _("CPU - percentage CPU"));
|
||||
/* only linux etime is support currently */
|
||||
#if defined( __linux__ )
|
||||
printf (" %s\n", _("ELAPSED - time elapsed in seconds"));
|
||||
printf (" %s\n", _("ELAPSED - time elapsed in seconds"));
|
||||
#endif /* defined(__linux__) */
|
||||
printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
||||
printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
||||
|
||||
printf (" %s\n", "-v, --verbose");
|
||||
printf (" %s\n", "-v, --verbose");
|
||||
printf (" %s\n", _("Extra information. Up to 3 verbosity levels"));
|
||||
|
||||
printf (" %s\n", "-T, --traditional");
|
||||
|
@ -777,7 +792,7 @@ print_help (void)
|
|||
printf (" %s\n", _("Only scan for processes with VSZ higher than indicated."));
|
||||
printf (" %s\n", "-r, --rss=RSS");
|
||||
printf (" %s\n", _("Only scan for processes with RSS higher than indicated."));
|
||||
printf (" %s\n", "-P, --pcpu=PCPU");
|
||||
printf (" %s\n", "-P, --pcpu=PCPU");
|
||||
printf (" %s\n", _("Only scan for processes with PCPU higher than indicated."));
|
||||
printf (" %s\n", "-u, --user=USER");
|
||||
printf (" %s\n", _("Only scan for processes with user name or ID indicated."));
|
||||
|
@ -792,19 +807,19 @@ print_help (void)
|
|||
printf (" %s\n", "-k, --no-kthreads");
|
||||
printf (" %s\n", _("Only scan for non kernel threads (works on Linux only)."));
|
||||
|
||||
printf(_("\n\
|
||||
printf(_("\n\
|
||||
RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n\
|
||||
specified 'max:min', a warning status will be generated if the\n\
|
||||
count is inside the specified range\n\n"));
|
||||
|
||||
printf(_("\
|
||||
printf(_("\
|
||||
This plugin checks the number of currently running processes and\n\
|
||||
generates WARNING or CRITICAL states if the process count is outside\n\
|
||||
the specified threshold ranges. The process count can be filtered by\n\
|
||||
process owner, parent process PID, current state (e.g., 'Z'), or may\n\
|
||||
be the total number of running processes\n\n"));
|
||||
|
||||
printf ("%s\n", _("Examples:"));
|
||||
printf ("%s\n", _("Examples:"));
|
||||
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"));
|
||||
|
@ -821,14 +836,14 @@ be the total number of running processes\n\n"));
|
|||
printf (" %s\n", "check_procs -w 10 -c 20 --metric=CPU");
|
||||
printf (" %s\n", _("Alert if CPU of any processes over 10\% or 20\%"));
|
||||
|
||||
printf (UT_SUPPORT);
|
||||
printf (UT_SUPPORT);
|
||||
}
|
||||
|
||||
void
|
||||
print_usage (void)
|
||||
{
|
||||
printf ("%s\n", _("Usage:"));
|
||||
printf ("%s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n", progname);
|
||||
printf ("%s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n", progname);
|
||||
printf (" [-u user] [-r rss] [-z vsz] [-P %%cpu] [-a argument-array]\n");
|
||||
printf (" [-C command] [-X process_to_exclude] [-k] [-t timeout] [-v]\n");
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ char *expect = NULL;
|
|||
char *config_file = NULL;
|
||||
unsigned short port = PW_AUTH_UDP_PORT;
|
||||
int retries = 1;
|
||||
int verbose = FALSE;
|
||||
bool verbose = false;
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
|
@ -272,10 +272,10 @@ process_arguments (int argc, char **argv)
|
|||
print_revision (progname, NP_VERSION);
|
||||
exit (STATE_UNKNOWN);
|
||||
case 'v': /* verbose mode */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 'H': /* hostname */
|
||||
if (is_host (optarg) == FALSE) {
|
||||
if (!is_host (optarg)) {
|
||||
usage2 (_("Invalid hostname/address"), optarg);
|
||||
}
|
||||
server = optarg;
|
||||
|
|
|
@ -54,10 +54,10 @@ char *host_name;
|
|||
char *server_url = NULL;
|
||||
char *server_expect;
|
||||
int warning_time = 0;
|
||||
int check_warning_time = FALSE;
|
||||
bool check_warning_time = false;
|
||||
int critical_time = 0;
|
||||
int check_critical_time = FALSE;
|
||||
int verbose = FALSE;
|
||||
bool check_critical_time = false;
|
||||
bool verbose = false;
|
||||
|
||||
|
||||
|
||||
|
@ -238,9 +238,9 @@ main (int argc, char **argv)
|
|||
/* Return results */
|
||||
if (result == STATE_OK) {
|
||||
|
||||
if (check_critical_time == TRUE
|
||||
if (check_critical_time
|
||||
&& (end_time - start_time) > critical_time) result = STATE_CRITICAL;
|
||||
else if (check_warning_time == TRUE
|
||||
else if (check_warning_time
|
||||
&& (end_time - start_time) > warning_time) result =
|
||||
STATE_WARNING;
|
||||
|
||||
|
@ -331,7 +331,7 @@ process_arguments (int argc, char **argv)
|
|||
case 'w': /* warning time threshold */
|
||||
if (is_intnonneg (optarg)) {
|
||||
warning_time = atoi (optarg);
|
||||
check_warning_time = TRUE;
|
||||
check_warning_time = true;
|
||||
}
|
||||
else {
|
||||
usage4 (_("Warning time must be a positive integer"));
|
||||
|
@ -340,14 +340,14 @@ process_arguments (int argc, char **argv)
|
|||
case 'c': /* critical time threshold */
|
||||
if (is_intnonneg (optarg)) {
|
||||
critical_time = atoi (optarg);
|
||||
check_critical_time = TRUE;
|
||||
check_critical_time = true;
|
||||
}
|
||||
else {
|
||||
usage4 (_("Critical time must be a positive integer"));
|
||||
}
|
||||
break;
|
||||
case 'v': /* verbose */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 't': /* timeout */
|
||||
if (is_intnonneg (optarg)) {
|
||||
|
|
|
@ -40,7 +40,7 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_SSL
|
||||
int check_cert = FALSE;
|
||||
bool check_cert = false;
|
||||
int days_till_exp_warn, days_till_exp_crit;
|
||||
# define my_recv(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
|
||||
# define my_send(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
|
||||
|
@ -100,17 +100,17 @@ char *authtype = NULL;
|
|||
char *authuser = NULL;
|
||||
char *authpass = NULL;
|
||||
double warning_time = 0;
|
||||
int check_warning_time = FALSE;
|
||||
bool check_warning_time = false;
|
||||
double critical_time = 0;
|
||||
int check_critical_time = FALSE;
|
||||
bool check_critical_time = false;
|
||||
int verbose = 0;
|
||||
int use_ssl = FALSE;
|
||||
int use_starttls = FALSE;
|
||||
int use_sni = FALSE;
|
||||
short use_proxy_prefix = FALSE;
|
||||
short use_ehlo = FALSE;
|
||||
short use_lhlo = FALSE;
|
||||
short ssl_established = 0;
|
||||
bool use_ssl = false;
|
||||
bool use_starttls = false;
|
||||
bool use_sni = false;
|
||||
bool use_proxy_prefix = false;
|
||||
bool use_ehlo = false;
|
||||
bool use_lhlo = false;
|
||||
bool ssl_established = false;
|
||||
char *localhostname = NULL;
|
||||
int sd;
|
||||
char buffer[MAX_INPUT_BUFFER];
|
||||
|
@ -118,13 +118,13 @@ enum {
|
|||
TCP_PROTOCOL = 1,
|
||||
UDP_PROTOCOL = 2,
|
||||
};
|
||||
int ignore_send_quit_failure = FALSE;
|
||||
bool ignore_send_quit_failure = false;
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
short supports_tls=FALSE;
|
||||
bool supports_tls = false;
|
||||
int n = 0;
|
||||
double elapsed_time;
|
||||
long microsec;
|
||||
|
@ -230,7 +230,7 @@ main (int argc, char **argv)
|
|||
} else if(use_ehlo || use_lhlo){
|
||||
if(strstr(buffer, "250 STARTTLS") != NULL ||
|
||||
strstr(buffer, "250-STARTTLS") != NULL){
|
||||
supports_tls=TRUE;
|
||||
supports_tls=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,7 +466,7 @@ main (int argc, char **argv)
|
|||
fperfdata ("time", elapsed_time, "s",
|
||||
(int)check_warning_time, warning_time,
|
||||
(int)check_critical_time, critical_time,
|
||||
TRUE, 0, FALSE, 0));
|
||||
true, 0, false, 0));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -480,6 +480,8 @@ process_arguments (int argc, char **argv)
|
|||
int c;
|
||||
char* temp;
|
||||
|
||||
bool implicit_tls = false;
|
||||
|
||||
enum {
|
||||
SNI_OPTION
|
||||
};
|
||||
|
@ -560,7 +562,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'A':
|
||||
authtype = optarg;
|
||||
use_ehlo = TRUE;
|
||||
use_ehlo = true;
|
||||
break;
|
||||
case 'U':
|
||||
authuser = optarg;
|
||||
|
@ -600,7 +602,7 @@ process_arguments (int argc, char **argv)
|
|||
usage4 (_("Critical time must be a positive"));
|
||||
else {
|
||||
critical_time = strtod (optarg, NULL);
|
||||
check_critical_time = TRUE;
|
||||
check_critical_time = true;
|
||||
}
|
||||
break;
|
||||
case 'w': /* warning time threshold */
|
||||
|
@ -608,14 +610,14 @@ process_arguments (int argc, char **argv)
|
|||
usage4 (_("Warning time must be a positive"));
|
||||
else {
|
||||
warning_time = strtod (optarg, NULL);
|
||||
check_warning_time = TRUE;
|
||||
check_warning_time = true;
|
||||
}
|
||||
break;
|
||||
case 'v': /* verbose */
|
||||
verbose++;
|
||||
break;
|
||||
case 'q':
|
||||
ignore_send_quit_failure++; /* ignore problem sending QUIT */
|
||||
ignore_send_quit_failure = true; /* ignore problem sending QUIT */
|
||||
break;
|
||||
case 't': /* timeout */
|
||||
if (is_intnonneg (optarg)) {
|
||||
|
@ -645,33 +647,35 @@ process_arguments (int argc, char **argv)
|
|||
usage2 ("Invalid certificate expiration period", optarg);
|
||||
days_till_exp_warn = atoi (optarg);
|
||||
}
|
||||
check_cert = TRUE;
|
||||
ignore_send_quit_failure = TRUE;
|
||||
check_cert = true;
|
||||
ignore_send_quit_failure = true;
|
||||
#else
|
||||
usage (_("SSL support not available - install OpenSSL and recompile"));
|
||||
#endif
|
||||
implicit_tls = true;
|
||||
// fallthrough
|
||||
case 's':
|
||||
/* ssl */
|
||||
use_ssl = TRUE;
|
||||
use_ssl = true;
|
||||
server_port = SMTPS_PORT;
|
||||
break;
|
||||
case 'S':
|
||||
/* starttls */
|
||||
use_starttls = TRUE;
|
||||
use_ehlo = TRUE;
|
||||
use_starttls = true;
|
||||
use_ehlo = true;
|
||||
break;
|
||||
case SNI_OPTION:
|
||||
#ifdef HAVE_SSL
|
||||
use_sni = TRUE;
|
||||
use_sni = true;
|
||||
#else
|
||||
usage (_("SSL support not available - install OpenSSL and recompile"));
|
||||
#endif
|
||||
break;
|
||||
case 'r':
|
||||
use_proxy_prefix = TRUE;
|
||||
use_proxy_prefix = true;
|
||||
break;
|
||||
case 'L':
|
||||
use_lhlo = TRUE;
|
||||
use_lhlo = true;
|
||||
break;
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
|
@ -717,7 +721,12 @@ process_arguments (int argc, char **argv)
|
|||
from_arg = strdup(" ");
|
||||
|
||||
if (use_starttls && use_ssl) {
|
||||
usage4 (_("Set either -s/--ssl/--tls or -S/--starttls"));
|
||||
if (implicit_tls) {
|
||||
use_ssl = false;
|
||||
server_port = SMTP_PORT;
|
||||
} else {
|
||||
usage4 (_("Set either -s/--ssl/--tls or -S/--starttls"));
|
||||
}
|
||||
}
|
||||
|
||||
if (server_port_option != 0) {
|
||||
|
|
|
@ -131,11 +131,11 @@ size_t nlabels = 0;
|
|||
size_t labels_size = OID_COUNT_STEP;
|
||||
size_t nunits = 0;
|
||||
size_t unitv_size = OID_COUNT_STEP;
|
||||
int numoids = 0;
|
||||
size_t numoids = 0;
|
||||
int numauthpriv = 0;
|
||||
int numcontext = 0;
|
||||
int verbose = 0;
|
||||
int usesnmpgetnext = FALSE;
|
||||
bool usesnmpgetnext = false;
|
||||
char *warning_thresholds = NULL;
|
||||
char *critical_thresholds = NULL;
|
||||
thresholds **thlds;
|
||||
|
@ -148,7 +148,7 @@ size_t eval_size = OID_COUNT_STEP;
|
|||
char *delimiter;
|
||||
char *output_delim;
|
||||
char *miblist = NULL;
|
||||
int needmibs = FALSE;
|
||||
bool needmibs = false;
|
||||
int calculate_rate = 0;
|
||||
double offset = 0.0;
|
||||
int rate_multiplier = 1;
|
||||
|
@ -187,7 +187,8 @@ static char *fix_snmp_range(char *th)
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i, len, line, total_oids;
|
||||
int len, total_oids;
|
||||
size_t line;
|
||||
unsigned int bk_count = 0, dq_count = 0;
|
||||
int iresult = STATE_UNKNOWN;
|
||||
int result = STATE_UNKNOWN;
|
||||
|
@ -253,14 +254,16 @@ main (int argc, char **argv)
|
|||
if(calculate_rate) {
|
||||
if (!strcmp(label, "SNMP"))
|
||||
label = strdup("SNMP RATE");
|
||||
i=0;
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
previous_state = np_state_read();
|
||||
if(previous_state!=NULL) {
|
||||
/* Split colon separated values */
|
||||
previous_string = strdup((char *) previous_state->data);
|
||||
while((ap = strsep(&previous_string, ":")) != NULL) {
|
||||
if(verbose>2)
|
||||
printf("State for %d=%s\n", i, ap);
|
||||
printf("State for %zd=%s\n", i, ap);
|
||||
while (i >= previous_size) {
|
||||
previous_size += OID_COUNT_STEP;
|
||||
previous_value = realloc(previous_value, previous_size * sizeof(*previous_value));
|
||||
|
@ -273,7 +276,7 @@ main (int argc, char **argv)
|
|||
/* Populate the thresholds */
|
||||
th_warn=warning_thresholds;
|
||||
th_crit=critical_thresholds;
|
||||
for (i=0; i<numoids; i++) {
|
||||
for (size_t i = 0; i < numoids; i++) {
|
||||
char *w = th_warn ? strndup(th_warn, strcspn(th_warn, ",")) : NULL;
|
||||
char *c = th_crit ? strndup(th_crit, strcspn(th_crit, ",")) : NULL;
|
||||
/* translate "2:1" to "@1:2" for backwards compatibility */
|
||||
|
@ -302,7 +305,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* Create the command array to execute */
|
||||
if(usesnmpgetnext == TRUE) {
|
||||
if(usesnmpgetnext) {
|
||||
snmpcmd = strdup (PATH_TO_SNMPGETNEXT);
|
||||
}else{
|
||||
snmpcmd = strdup (PATH_TO_SNMPGET);
|
||||
|
@ -333,11 +336,11 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
|
||||
for (i = 0; i < numcontext; i++) {
|
||||
for (int i = 0; i < numcontext; i++) {
|
||||
command_line[index++] = contextargs[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < numauthpriv; i++) {
|
||||
for (int i = 0; i < numauthpriv; i++) {
|
||||
command_line[index++] = authpriv[i];
|
||||
}
|
||||
|
||||
|
@ -348,7 +351,7 @@ main (int argc, char **argv)
|
|||
server_address,
|
||||
port);
|
||||
|
||||
for (i = 0; i < numoids; i++) {
|
||||
for (size_t i = 0; i < numoids; i++) {
|
||||
command_line[index++] = oids[i];
|
||||
xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
|
||||
}
|
||||
|
@ -382,7 +385,7 @@ main (int argc, char **argv)
|
|||
if (external_error) {
|
||||
if (chld_err.lines > 0) {
|
||||
printf (_("External command error: %s\n"), chld_err.line[0]);
|
||||
for (i = 1; i < chld_err.lines; i++) {
|
||||
for (size_t i = 1; i < chld_err.lines; i++) {
|
||||
printf ("%s\n", chld_err.line[i]);
|
||||
}
|
||||
} else {
|
||||
|
@ -392,12 +395,14 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
if (verbose) {
|
||||
for (i = 0; i < chld_out.lines; i++) {
|
||||
for (size_t i = 0; i < chld_out.lines; i++) {
|
||||
printf ("%s\n", chld_out.line[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (line=0, i=0; line < chld_out.lines && i < numoids ; line++, i++) {
|
||||
line = 0;
|
||||
total_oids = 0;
|
||||
for (size_t i = 0; line < chld_out.lines && i < numoids ; line++, i++, total_oids++) {
|
||||
if(calculate_rate)
|
||||
conv = "%.10g";
|
||||
else
|
||||
|
@ -410,7 +415,7 @@ main (int argc, char **argv)
|
|||
break;
|
||||
|
||||
if (verbose > 2) {
|
||||
printf("Processing oid %i (line %i)\n oidname: %s\n response: %s\n", i+1, line+1, oidname, response);
|
||||
printf("Processing oid %zi (line %zi)\n oidname: %s\n response: %s\n", i+1, line+1, oidname, response);
|
||||
}
|
||||
|
||||
/* Clean up type array - Sol10 does not necessarily zero it out */
|
||||
|
@ -634,7 +639,6 @@ main (int argc, char **argv)
|
|||
strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
|
||||
}
|
||||
}
|
||||
total_oids=i;
|
||||
|
||||
/* Save state data, as all data collected now */
|
||||
if(calculate_rate) {
|
||||
|
@ -644,7 +648,7 @@ main (int argc, char **argv)
|
|||
die(STATE_UNKNOWN, _("Cannot malloc"));
|
||||
|
||||
current_length=0;
|
||||
for(i=0; i<total_oids; i++) {
|
||||
for(int i = 0; i < total_oids; i++) {
|
||||
xasprintf(&temp_string,"%.0f",response_value[i]);
|
||||
if(temp_string==NULL)
|
||||
die(STATE_UNKNOWN,_("Cannot asprintf()"));
|
||||
|
@ -687,7 +691,7 @@ process_arguments (int argc, char **argv)
|
|||
{
|
||||
char *ptr;
|
||||
int c = 1;
|
||||
int j = 0, jj = 0, ii = 0;
|
||||
size_t j = 0, jj = 0;
|
||||
|
||||
int option = 0;
|
||||
static struct option longopts[] = {
|
||||
|
@ -777,7 +781,7 @@ process_arguments (int argc, char **argv)
|
|||
miblist = optarg;
|
||||
break;
|
||||
case 'n': /* usesnmpgetnext */
|
||||
usesnmpgetnext = TRUE;
|
||||
usesnmpgetnext = true;
|
||||
break;
|
||||
case 'P': /* SNMP protocol version */
|
||||
proto = optarg;
|
||||
|
@ -831,7 +835,7 @@ process_arguments (int argc, char **argv)
|
|||
* so we have a mib variable, rather than just an SNMP OID,
|
||||
* so we have to actually read the mib files
|
||||
*/
|
||||
needmibs = TRUE;
|
||||
needmibs = true;
|
||||
}
|
||||
for (ptr = strtok(optarg, ", "); ptr != NULL; ptr = strtok(NULL, ", "), j++) {
|
||||
while (j >= oids_size) {
|
||||
|
@ -843,7 +847,6 @@ process_arguments (int argc, char **argv)
|
|||
numoids = j;
|
||||
if (c == 'E' || c == 'e') {
|
||||
jj++;
|
||||
ii++;
|
||||
while (j+1 >= eval_size) {
|
||||
eval_size += OID_COUNT_STEP;
|
||||
eval_method = realloc(eval_method, eval_size * sizeof(*eval_method));
|
||||
|
@ -870,7 +873,6 @@ process_arguments (int argc, char **argv)
|
|||
memset(eval_method + eval_size - OID_COUNT_STEP, 0, 8);
|
||||
}
|
||||
eval_method[jj++] = CRIT_STRING;
|
||||
ii++;
|
||||
break;
|
||||
case 'R': /* regex */
|
||||
cflags = REG_ICASE;
|
||||
|
@ -891,7 +893,6 @@ process_arguments (int argc, char **argv)
|
|||
memset(eval_method + eval_size - OID_COUNT_STEP, 0, 8);
|
||||
}
|
||||
eval_method[jj++] = CRIT_REGEX;
|
||||
ii++;
|
||||
break;
|
||||
|
||||
/* Format */
|
||||
|
@ -1034,7 +1035,7 @@ validate_arguments ()
|
|||
{
|
||||
/* check whether to load locally installed MIBS (CPU/disk intensive) */
|
||||
if (miblist == NULL) {
|
||||
if ( needmibs == TRUE ) {
|
||||
if (needmibs) {
|
||||
miblist = strdup (DEFAULT_MIBLIST);
|
||||
}else{
|
||||
miblist = ""; /* don't read any mib files for numeric oids */
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
* Monitoring check_ssh plugin
|
||||
*
|
||||
*
|
||||
* License: GPL
|
||||
* Copyright (c) 2000-2007 Monitoring Plugins Development Team
|
||||
*
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
*
|
||||
* This file contains the check_ssh plugin
|
||||
*
|
||||
*
|
||||
* Try to connect to an SSH server at specified server and port
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
const char *progname = "check_ssh";
|
||||
const char *copyright = "2000-2007";
|
||||
const char *email = "devel@monitoring-plugins.org";
|
||||
|
||||
#include "common.h"
|
||||
#include "netutils.h"
|
||||
#include "./common.h"
|
||||
#include "./netutils.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef MSG_DONTWAIT
|
||||
|
@ -47,7 +47,7 @@ int port = -1;
|
|||
char *server_name = NULL;
|
||||
char *remote_version = NULL;
|
||||
char *remote_protocol = NULL;
|
||||
int verbose = FALSE;
|
||||
bool verbose = false;
|
||||
|
||||
int process_arguments (int, char **);
|
||||
int validate_arguments (void);
|
||||
|
@ -57,7 +57,6 @@ void print_usage (void);
|
|||
int ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol);
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
|
@ -106,7 +105,7 @@ process_arguments (int argc, char **argv)
|
|||
{"timeout", required_argument, 0, 't'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"remote-version", required_argument, 0, 'r'},
|
||||
{"remote-protcol", required_argument, 0, 'P'},
|
||||
{"remote-protocol", required_argument, 0, 'P'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -133,7 +132,7 @@ process_arguments (int argc, char **argv)
|
|||
print_help ();
|
||||
exit (STATE_UNKNOWN);
|
||||
case 'v': /* verbose */
|
||||
verbose = TRUE;
|
||||
verbose = true;
|
||||
break;
|
||||
case 't': /* timeout period */
|
||||
if (!is_integer (optarg))
|
||||
|
@ -158,7 +157,7 @@ process_arguments (int argc, char **argv)
|
|||
remote_protocol = optarg;
|
||||
break;
|
||||
case 'H': /* host */
|
||||
if (is_host (optarg) == FALSE)
|
||||
if (!is_host (optarg))
|
||||
usage2 (_("Invalid hostname/address"), optarg);
|
||||
server_name = optarg;
|
||||
break;
|
||||
|
@ -215,7 +214,9 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol
|
|||
{
|
||||
int sd;
|
||||
int result;
|
||||
char *output = NULL;
|
||||
int len = 0;
|
||||
ssize_t recv_ret = 0;
|
||||
char *version_control_string = NULL;
|
||||
char *buffer = NULL;
|
||||
char *ssh_proto = NULL;
|
||||
char *ssh_server = NULL;
|
||||
|
@ -230,52 +231,126 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol
|
|||
if (result != STATE_OK)
|
||||
return result;
|
||||
|
||||
output = (char *) malloc (BUFF_SZ + 1);
|
||||
memset (output, 0, BUFF_SZ + 1);
|
||||
recv (sd, output, BUFF_SZ, 0);
|
||||
if (strncmp (output, "SSH", 3)) {
|
||||
printf (_("Server answer: %s"), output);
|
||||
char *output = (char *) calloc (BUFF_SZ + 1, sizeof(char));
|
||||
|
||||
unsigned int iteration = 0;
|
||||
ssize_t byte_offset = 0;
|
||||
|
||||
while ((version_control_string == NULL) && (recv_ret = recv(sd, output+byte_offset, BUFF_SZ - byte_offset, 0) > 0)) {
|
||||
|
||||
if (strchr(output, '\n')) { /* we've got at least one full line, start parsing*/
|
||||
byte_offset = 0;
|
||||
|
||||
char *index = NULL;
|
||||
while ((index = strchr(output+byte_offset, '\n')) != NULL) {
|
||||
/*Partition the buffer so that this line is a separate string,
|
||||
* by replacing the newline with NUL*/
|
||||
output[(index - output)] = '\0';
|
||||
len = strlen(output + byte_offset);
|
||||
|
||||
if ((len >= 4) && (strncmp (output+byte_offset, "SSH-", 4) == 0)) {
|
||||
/*if the string starts with SSH-, this _should_ be a valid version control string*/
|
||||
version_control_string = output+byte_offset;
|
||||
break;
|
||||
}
|
||||
|
||||
/*the start of the next line (if one exists) will be after the current one (+ NUL)*/
|
||||
byte_offset += (len + 1);
|
||||
}
|
||||
|
||||
if(version_control_string == NULL) {
|
||||
/* move unconsumed data to beginning of buffer, null rest */
|
||||
memmove((void *)output, (void *)output+byte_offset+1, BUFF_SZ - len+1);
|
||||
memset(output+byte_offset+1, 0, BUFF_SZ-byte_offset+1);
|
||||
|
||||
/*start reading from end of current line chunk on next recv*/
|
||||
byte_offset = strlen(output);
|
||||
}
|
||||
} else {
|
||||
byte_offset += recv_ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (recv_ret < 0) {
|
||||
printf("SSH CRITICAL - %s", strerror(errno));
|
||||
exit(STATE_CRITICAL);
|
||||
}
|
||||
|
||||
if (version_control_string == NULL) {
|
||||
printf("SSH CRITICAL - No version control string received");
|
||||
exit(STATE_CRITICAL);
|
||||
}
|
||||
/*
|
||||
* "When the connection has been established, both sides MUST send an
|
||||
* identification string. This identification string MUST be
|
||||
*
|
||||
* SSH-protoversion-softwareversion SP comments CR LF"
|
||||
* - RFC 4253:4.2
|
||||
*/
|
||||
strip (version_control_string);
|
||||
if (verbose)
|
||||
printf ("%s\n", version_control_string);
|
||||
ssh_proto = version_control_string + 4;
|
||||
|
||||
/*
|
||||
* We assume the protoversion is of the form Major.Minor, although
|
||||
* this is not _strictly_ required. See
|
||||
*
|
||||
* "Both the 'protoversion' and 'softwareversion' strings MUST consist of
|
||||
* printable US-ASCII characters, with the exception of whitespace
|
||||
* characters and the minus sign (-)"
|
||||
* - RFC 4253:4.2
|
||||
* and,
|
||||
*
|
||||
* "As stated earlier, the 'protoversion' specified for this protocol is
|
||||
* "2.0". Earlier versions of this protocol have not been formally
|
||||
* documented, but it is widely known that they use 'protoversion' of
|
||||
* "1.x" (e.g., "1.5" or "1.3")."
|
||||
* - RFC 4253:5
|
||||
*/
|
||||
ssh_server = ssh_proto + strspn (ssh_proto, "0123456789.") + 1; /* (+1 for the '-' separating protoversion from softwareversion) */
|
||||
|
||||
/* If there's a space in the version string, whatever's after the space is a comment
|
||||
* (which is NOT part of the server name/version)*/
|
||||
char *tmp = strchr(ssh_server, ' ');
|
||||
if (tmp) {
|
||||
ssh_server[tmp - ssh_server] = '\0';
|
||||
}
|
||||
if (strlen(ssh_proto) == 0 || strlen(ssh_server) == 0) {
|
||||
printf(_("SSH CRITICAL - Invalid protocol version control string %s\n"), version_control_string);
|
||||
exit (STATE_CRITICAL);
|
||||
}
|
||||
ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;
|
||||
|
||||
xasprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, rev_no);
|
||||
send (sd, buffer, strlen (buffer), MSG_DONTWAIT);
|
||||
if (verbose)
|
||||
printf ("%s\n", buffer);
|
||||
|
||||
if (remote_version && strcmp(remote_version, ssh_server)) {
|
||||
printf
|
||||
(_("SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"),
|
||||
ssh_server, ssh_proto, remote_version);
|
||||
close(sd);
|
||||
exit (STATE_CRITICAL);
|
||||
}
|
||||
else {
|
||||
strip (output);
|
||||
if (verbose)
|
||||
printf ("%s\n", output);
|
||||
ssh_proto = output + 4;
|
||||
ssh_server = ssh_proto + strspn (ssh_proto, "-0123456789. ");
|
||||
ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;
|
||||
|
||||
xasprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, rev_no);
|
||||
send (sd, buffer, strlen (buffer), MSG_DONTWAIT);
|
||||
if (verbose)
|
||||
printf ("%s\n", buffer);
|
||||
|
||||
if (remote_version && strcmp(remote_version, ssh_server)) {
|
||||
printf
|
||||
(_("SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"),
|
||||
ssh_server, ssh_proto, remote_version);
|
||||
close(sd);
|
||||
exit (STATE_CRITICAL);
|
||||
}
|
||||
|
||||
if (remote_protocol && strcmp(remote_protocol, ssh_proto)) {
|
||||
printf
|
||||
(_("SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"),
|
||||
ssh_server, ssh_proto, remote_protocol);
|
||||
close(sd);
|
||||
exit (STATE_CRITICAL);
|
||||
}
|
||||
|
||||
elapsed_time = (double)deltime(tv) / 1.0e6;
|
||||
|
||||
if (remote_protocol && strcmp(remote_protocol, ssh_proto)) {
|
||||
printf
|
||||
(_("SSH OK - %s (protocol %s) | %s\n"),
|
||||
ssh_server, ssh_proto, fperfdata("time", elapsed_time, "s",
|
||||
FALSE, 0, FALSE, 0, TRUE, 0, TRUE, (int)socket_timeout));
|
||||
(_("SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s' | %s\n"),
|
||||
ssh_server, ssh_proto, remote_protocol, fperfdata("time", elapsed_time, "s",
|
||||
false, 0, false, 0, true, 0, true, (int)socket_timeout));
|
||||
close(sd);
|
||||
exit (STATE_OK);
|
||||
exit (STATE_CRITICAL);
|
||||
}
|
||||
elapsed_time = (double)deltime(tv) / 1.0e6;
|
||||
|
||||
printf
|
||||
(_("SSH OK - %s (protocol %s) | %s\n"),
|
||||
ssh_server, ssh_proto, fperfdata("time", elapsed_time, "s",
|
||||
false, 0, false, 0, true, 0, true, (int)socket_timeout));
|
||||
close(sd);
|
||||
exit (STATE_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -293,7 +368,7 @@ print_help (void)
|
|||
|
||||
printf ("%s\n", _("Try to connect to an SSH server at specified server and port"));
|
||||
|
||||
printf ("\n\n");
|
||||
printf ("\n\n");
|
||||
|
||||
print_usage ();
|
||||
|
||||
|
@ -307,10 +382,10 @@ print_help (void)
|
|||
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
||||
|
||||
printf (" %s\n", "-r, --remote-version=STRING");
|
||||
printf (" %s\n", _("Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
|
||||
printf (" %s\n", _("Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
|
||||
|
||||
printf (" %s\n", "-P, --remote-protocol=STRING");
|
||||
printf (" %s\n", _("Alert if protocol doesn't match expected protocol version (ex: 2.0)"));
|
||||
printf (" %s\n", _("Alert if protocol doesn't match expected protocol version (ex: 2.0)"));
|
||||
|
||||
printf (UT_VERBOSE);
|
||||
|
||||
|
@ -322,7 +397,7 @@ print_help (void)
|
|||
void
|
||||
print_usage (void)
|
||||
{
|
||||
printf ("%s\n", _("Usage:"));
|
||||
printf ("%s\n", _("Usage:"));
|
||||
printf ("%s [-4|-6] [-t <timeout>] [-r <remote version>] [-p <port>] <host>\n", progname);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* License: GPL
|
||||
* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
|
||||
* Copyright (c) 2000-2007 Monitoring Plugins Development Team
|
||||
* Copyright (c) 2000-2024 Monitoring Plugins Development Team
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
|
@ -28,7 +28,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
const char *progname = "check_swap";
|
||||
const char *copyright = "2000-2007";
|
||||
const char *copyright = "2000-2024";
|
||||
const char *email = "devel@monitoring-plugins.org";
|
||||
|
||||
#include "common.h"
|
||||
|
@ -52,9 +52,9 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
#endif
|
||||
|
||||
typedef struct {
|
||||
int is_percentage;
|
||||
bool is_percentage;
|
||||
uint64_t value;
|
||||
} threshold_t;
|
||||
} threshold;
|
||||
|
||||
int check_swap (float free_swap_mb, float total_swap_mb);
|
||||
int process_arguments (int argc, char **argv);
|
||||
|
@ -62,10 +62,10 @@ int validate_arguments (void);
|
|||
void print_usage (void);
|
||||
void print_help (void);
|
||||
|
||||
threshold_t warn;
|
||||
threshold_t crit;
|
||||
threshold warn;
|
||||
threshold crit;
|
||||
int verbose;
|
||||
int allswaps;
|
||||
bool allswaps = false;
|
||||
int no_swap_state = STATE_CRITICAL;
|
||||
|
||||
int
|
||||
|
@ -383,10 +383,10 @@ main (int argc, char **argv)
|
|||
if (crit.is_percentage) crit_print = crit.value * (total_swap_mb *1024 *1024/100);
|
||||
|
||||
puts (perfdata_uint64 ("swap", free_swap_mb *1024 *1024, "B",
|
||||
TRUE, warn_print,
|
||||
TRUE, crit_print,
|
||||
TRUE, 0,
|
||||
TRUE, (long) total_swap_mb * 1024 * 1024));
|
||||
true, warn_print,
|
||||
true, crit_print,
|
||||
true, 0,
|
||||
true, (long) total_swap_mb * 1024 * 1024));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -399,28 +399,30 @@ check_swap(float free_swap_mb, float total_swap_mb)
|
|||
if (!total_swap_mb) return no_swap_state;
|
||||
|
||||
uint64_t free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */
|
||||
|
||||
if (!crit.is_percentage && crit.value >= free_swap) return STATE_CRITICAL;
|
||||
if (!warn.is_percentage && warn.value >= free_swap) return STATE_WARNING;
|
||||
|
||||
|
||||
uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100;
|
||||
|
||||
if (crit.is_percentage &&
|
||||
crit.value != 0 &&
|
||||
usage_percentage >= (100 - crit.value))
|
||||
{
|
||||
return STATE_CRITICAL;
|
||||
}
|
||||
if (warn.value || crit.value) { /* Thresholds defined */
|
||||
if (!crit.is_percentage && crit.value >= free_swap) return STATE_CRITICAL;
|
||||
if (!warn.is_percentage && warn.value >= free_swap) return STATE_WARNING;
|
||||
|
||||
if (warn.is_percentage &&
|
||||
warn.value != 0 &&
|
||||
usage_percentage >= (100 - warn.value))
|
||||
{
|
||||
return STATE_WARNING;
|
||||
}
|
||||
if (crit.is_percentage &&
|
||||
crit.value != 0 &&
|
||||
usage_percentage >= (100 - crit.value))
|
||||
{
|
||||
return STATE_CRITICAL;
|
||||
}
|
||||
|
||||
return STATE_OK;
|
||||
if (warn.is_percentage &&
|
||||
warn.value != 0 &&
|
||||
usage_percentage >= (100 - warn.value))
|
||||
{
|
||||
return STATE_WARNING;
|
||||
}
|
||||
|
||||
return STATE_OK;
|
||||
} else { /* Without thresholds */
|
||||
return STATE_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -443,9 +445,6 @@ process_arguments (int argc, char **argv)
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
if (argc < 2)
|
||||
return ERROR;
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "+?Vvhac:w:n:", longopts, &option);
|
||||
|
||||
|
@ -465,7 +464,7 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
if (optarg[length - 1] == '%') {
|
||||
/* It's percentage */
|
||||
warn.is_percentage = 1;
|
||||
warn.is_percentage = true;
|
||||
optarg[length - 1] = '\0';
|
||||
if (is_uint64(optarg, &warn.value)) {
|
||||
if (warn.value > 100) {
|
||||
|
@ -475,7 +474,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
} else {
|
||||
/* It's Bytes */
|
||||
warn.is_percentage = 0;
|
||||
warn.is_percentage = false;
|
||||
if (is_uint64(optarg, &warn.value)) {
|
||||
break;
|
||||
} else {
|
||||
|
@ -495,7 +494,7 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
if (optarg[length - 1] == '%') {
|
||||
/* It's percentage */
|
||||
crit.is_percentage = 1;
|
||||
crit.is_percentage = true;
|
||||
optarg[length - 1] = '\0';
|
||||
if (is_uint64(optarg, &crit.value)) {
|
||||
if (crit.value> 100) {
|
||||
|
@ -505,7 +504,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
} else {
|
||||
/* It's Bytes */
|
||||
crit.is_percentage = 0;
|
||||
crit.is_percentage = false;
|
||||
if (is_uint64(optarg, &crit.value)) {
|
||||
break;
|
||||
} else {
|
||||
|
@ -514,7 +513,7 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
}
|
||||
case 'a': /* all swap */
|
||||
allswaps = TRUE;
|
||||
allswaps = true;
|
||||
break;
|
||||
case 'n':
|
||||
if ((no_swap_state = mp_translate_state(optarg)) == ERROR) {
|
||||
|
@ -547,10 +546,7 @@ process_arguments (int argc, char **argv)
|
|||
int
|
||||
validate_arguments (void)
|
||||
{
|
||||
if (warn.value == 0 && crit.value == 0) {
|
||||
return ERROR;
|
||||
}
|
||||
else if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
|
||||
if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
|
||||
/* This is NOT triggered if warn and crit are different units, e.g warn is percentage
|
||||
* and crit is absolute. We cannot determine the condition at this point since we
|
||||
* dont know the value of total swap yet
|
||||
|
@ -595,6 +591,7 @@ print_help (void)
|
|||
printf ("\n");
|
||||
printf ("%s\n", _("Notes:"));
|
||||
printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked."));
|
||||
printf (" %s\n", _("Without thresholds, the plugin shows free swap space and performance data, but always returns OK."));
|
||||
printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."));
|
||||
|
||||
printf (UT_SUPPORT);
|
||||
|
@ -605,6 +602,6 @@ void
|
|||
print_usage (void)
|
||||
{
|
||||
printf ("%s\n", _("Usage:"));
|
||||
printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
|
||||
printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n");
|
||||
printf (" %s [-av] [-w <percent_free>%%] [-c <percent_free>%%]\n",progname);
|
||||
printf (" [-w <bytes_free>] [-c <bytes_free>] [-n <state>]\n");
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
#include <sys/select.h>
|
||||
|
||||
#ifdef HAVE_SSL
|
||||
static int check_cert = FALSE;
|
||||
static bool check_cert = false;
|
||||
static int days_till_exp_warn, days_till_exp_crit;
|
||||
# define my_recv(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
|
||||
# define my_send(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
|
||||
|
@ -65,12 +65,12 @@ static int READ_TIMEOUT = 2;
|
|||
|
||||
static int server_port = 0;
|
||||
static char *server_address = NULL;
|
||||
static int host_specified = FALSE;
|
||||
static bool host_specified = false;
|
||||
static char *server_send = NULL;
|
||||
static char *server_quit = NULL;
|
||||
static char **server_expect;
|
||||
static size_t server_expect_count = 0;
|
||||
static size_t maxbytes = 0;
|
||||
static ssize_t maxbytes = 0;
|
||||
static char **warn_codes = NULL;
|
||||
static size_t warn_codes_count = 0;
|
||||
static char **crit_codes = NULL;
|
||||
|
@ -88,7 +88,7 @@ static int match_flags = NP_MATCH_EXACT;
|
|||
|
||||
#ifdef HAVE_SSL
|
||||
static char *sni = NULL;
|
||||
static int sni_specified = FALSE;
|
||||
static bool sni_specified = false;
|
||||
#endif
|
||||
|
||||
#define FLAG_SSL 0x01
|
||||
|
@ -102,11 +102,9 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
int result = STATE_UNKNOWN;
|
||||
int i;
|
||||
char *status = NULL;
|
||||
struct timeval tv;
|
||||
struct timeval timeout;
|
||||
size_t len;
|
||||
int match = -1;
|
||||
fd_set rfds;
|
||||
|
||||
|
@ -121,10 +119,10 @@ main (int argc, char **argv)
|
|||
if(progname != NULL) progname++;
|
||||
else progname = argv[0];
|
||||
|
||||
len = strlen(progname);
|
||||
if(len > 6 && !memcmp(progname, "check_", 6)) {
|
||||
size_t prog_name_len = strlen(progname);
|
||||
if(prog_name_len > 6 && !memcmp(progname, "check_", 6)) {
|
||||
SERVICE = strdup(progname + 6);
|
||||
for(i = 0; i < len - 6; i++)
|
||||
for(size_t i = 0; i < prog_name_len - 6; i++)
|
||||
SERVICE[i] = toupper(SERVICE[i]);
|
||||
}
|
||||
|
||||
|
@ -247,7 +245,7 @@ main (int argc, char **argv)
|
|||
#ifdef HAVE_SSL
|
||||
if (flags & FLAG_SSL){
|
||||
result = np_net_ssl_init_with_hostname(sd, (sni_specified ? sni : NULL));
|
||||
if (result == STATE_OK && check_cert == TRUE) {
|
||||
if (result == STATE_OK && check_cert) {
|
||||
result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
|
||||
}
|
||||
}
|
||||
|
@ -275,19 +273,21 @@ main (int argc, char **argv)
|
|||
printf("Quit string: %s\n", server_quit);
|
||||
}
|
||||
printf("server_expect_count: %d\n", (int)server_expect_count);
|
||||
for(i = 0; i < server_expect_count; i++)
|
||||
printf("\t%d: %s\n", i, server_expect[i]);
|
||||
for(size_t i = 0; i < server_expect_count; i++)
|
||||
printf("\t%zd: %s\n", i, server_expect[i]);
|
||||
}
|
||||
|
||||
/* if(len) later on, we know we have a non-NULL response */
|
||||
len = 0;
|
||||
ssize_t len = 0;
|
||||
|
||||
if (server_expect_count) {
|
||||
ssize_t received = 0;
|
||||
|
||||
/* watch for the expect string */
|
||||
while ((i = my_recv(buffer, sizeof(buffer))) > 0) {
|
||||
status = realloc(status, len + i + 1);
|
||||
memcpy(&status[len], buffer, i);
|
||||
len += i;
|
||||
while ((received = my_recv(buffer, sizeof(buffer))) > 0) {
|
||||
status = realloc(status, len + received + 1);
|
||||
memcpy(&status[len], buffer, received);
|
||||
len += received;
|
||||
status[len] = '\0';
|
||||
|
||||
/* stop reading if user-forced */
|
||||
|
@ -307,6 +307,7 @@ main (int argc, char **argv)
|
|||
if(select(sd + 1, &rfds, NULL, NULL, &timeout) <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (match == NP_MATCH_RETRY)
|
||||
match = NP_MATCH_FAILURE;
|
||||
|
||||
|
@ -378,18 +379,18 @@ main (int argc, char **argv)
|
|||
if(match == NP_MATCH_FAILURE)
|
||||
printf ("|%s",
|
||||
fperfdata ("time", elapsed_time, "s",
|
||||
(flags & FLAG_TIME_WARN ? TRUE : FALSE), 0,
|
||||
(flags & FLAG_TIME_CRIT ? TRUE : FALSE), 0,
|
||||
TRUE, 0,
|
||||
TRUE, socket_timeout)
|
||||
(flags & FLAG_TIME_WARN ? true : false), 0,
|
||||
(flags & FLAG_TIME_CRIT ? true : false), 0,
|
||||
true, 0,
|
||||
true, socket_timeout)
|
||||
);
|
||||
else
|
||||
printf("|%s",
|
||||
fperfdata ("time", elapsed_time, "s",
|
||||
(flags & FLAG_TIME_WARN ? TRUE : FALSE), warning_time,
|
||||
(flags & FLAG_TIME_CRIT ? TRUE : FALSE), critical_time,
|
||||
TRUE, 0,
|
||||
TRUE, socket_timeout)
|
||||
(flags & FLAG_TIME_WARN ? true : false), warning_time,
|
||||
(flags & FLAG_TIME_CRIT ? true : false), critical_time,
|
||||
true, 0,
|
||||
true, socket_timeout)
|
||||
);
|
||||
|
||||
putchar('\n');
|
||||
|
@ -399,11 +400,9 @@ main (int argc, char **argv)
|
|||
|
||||
|
||||
/* process command-line arguments */
|
||||
static int
|
||||
process_arguments (int argc, char **argv)
|
||||
{
|
||||
static int process_arguments (int argc, char **argv) {
|
||||
int c;
|
||||
int escape = 0;
|
||||
bool escape = false;
|
||||
char *temp;
|
||||
|
||||
enum {
|
||||
|
@ -492,7 +491,7 @@ process_arguments (int argc, char **argv)
|
|||
#endif
|
||||
break;
|
||||
case 'H': /* hostname */
|
||||
host_specified = TRUE;
|
||||
host_specified = true;
|
||||
server_address = optarg;
|
||||
break;
|
||||
case 'c': /* critical */
|
||||
|
@ -527,7 +526,7 @@ process_arguments (int argc, char **argv)
|
|||
server_port = atoi (optarg);
|
||||
break;
|
||||
case 'E':
|
||||
escape = 1;
|
||||
escape = true;
|
||||
break;
|
||||
case 's':
|
||||
if (escape)
|
||||
|
@ -601,7 +600,7 @@ process_arguments (int argc, char **argv)
|
|||
usage2 (_("Invalid certificate expiration period"), optarg);
|
||||
days_till_exp_warn = atoi (optarg);
|
||||
}
|
||||
check_cert = TRUE;
|
||||
check_cert = true;
|
||||
flags |= FLAG_SSL;
|
||||
break;
|
||||
# endif /* USE_OPENSSL */
|
||||
|
@ -617,7 +616,7 @@ process_arguments (int argc, char **argv)
|
|||
case SNI_OPTION:
|
||||
#ifdef HAVE_SSL
|
||||
flags |= FLAG_SSL;
|
||||
sni_specified = TRUE;
|
||||
sni_specified = true;
|
||||
sni = optarg;
|
||||
#else
|
||||
die (STATE_UNKNOWN, _("Invalid option - SSL is not available"));
|
||||
|
@ -630,15 +629,15 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
c = optind;
|
||||
if(host_specified == FALSE && c < argc)
|
||||
if(!host_specified && c < argc)
|
||||
server_address = strdup (argv[c++]);
|
||||
|
||||
if (server_address == NULL)
|
||||
usage4 (_("You must provide a server address"));
|
||||
else if (server_address[0] != '/' && is_host (server_address) == FALSE)
|
||||
else if (server_address[0] != '/' && !is_host(server_address))
|
||||
die (STATE_CRITICAL, "%s %s - %s: %s\n", SERVICE, state_text(STATE_CRITICAL), _("Invalid hostname, address or socket"), server_address);
|
||||
|
||||
return TRUE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,16 +45,16 @@ enum {
|
|||
uint32_t raw_server_time;
|
||||
unsigned long server_time, diff_time;
|
||||
int warning_time = 0;
|
||||
int check_warning_time = FALSE;
|
||||
bool check_warning_time = false;
|
||||
int critical_time = 0;
|
||||
int check_critical_time = FALSE;
|
||||
bool check_critical_time = false;
|
||||
unsigned long warning_diff = 0;
|
||||
int check_warning_diff = FALSE;
|
||||
bool check_warning_diff = false;
|
||||
unsigned long critical_diff = 0;
|
||||
int check_critical_diff = FALSE;
|
||||
bool check_critical_diff = false;
|
||||
int server_port = TIME_PORT;
|
||||
char *server_address = NULL;
|
||||
int use_udp = FALSE;
|
||||
bool use_udp = false;
|
||||
|
||||
int process_arguments (int, char **);
|
||||
void print_help (void);
|
||||
|
@ -92,9 +92,9 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
if (result != STATE_OK) {
|
||||
if (check_critical_time == TRUE)
|
||||
if (check_critical_time)
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_time == TRUE)
|
||||
else if (check_warning_time)
|
||||
result = STATE_WARNING;
|
||||
else
|
||||
result = STATE_UNKNOWN;
|
||||
|
@ -105,9 +105,9 @@ main (int argc, char **argv)
|
|||
|
||||
if (use_udp) {
|
||||
if (send (sd, "", 0, 0) < 0) {
|
||||
if (check_critical_time == TRUE)
|
||||
if (check_critical_time)
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_time == TRUE)
|
||||
else if (check_warning_time)
|
||||
result = STATE_WARNING;
|
||||
else
|
||||
result = STATE_UNKNOWN;
|
||||
|
@ -129,9 +129,9 @@ main (int argc, char **argv)
|
|||
|
||||
/* return a WARNING status if we couldn't read any data */
|
||||
if (result <= 0) {
|
||||
if (check_critical_time == TRUE)
|
||||
if (check_critical_time)
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_time == TRUE)
|
||||
else if (check_warning_time)
|
||||
result = STATE_WARNING;
|
||||
else
|
||||
result = STATE_UNKNOWN;
|
||||
|
@ -143,9 +143,9 @@ main (int argc, char **argv)
|
|||
result = STATE_OK;
|
||||
|
||||
conntime = (end_time - start_time);
|
||||
if (check_critical_time == TRUE && conntime > critical_time)
|
||||
if (check_critical_time&& conntime > critical_time)
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_time == TRUE && conntime > warning_time)
|
||||
else if (check_warning_time && conntime > warning_time)
|
||||
result = STATE_WARNING;
|
||||
|
||||
if (result != STATE_OK)
|
||||
|
@ -154,7 +154,7 @@ main (int argc, char **argv)
|
|||
perfdata ("time", (long)conntime, "s",
|
||||
check_warning_time, (long)warning_time,
|
||||
check_critical_time, (long)critical_time,
|
||||
TRUE, 0, FALSE, 0));
|
||||
true, 0, false, 0));
|
||||
|
||||
server_time = ntohl (raw_server_time) - UNIX_EPOCH;
|
||||
if (server_time > (unsigned long)end_time)
|
||||
|
@ -162,9 +162,9 @@ main (int argc, char **argv)
|
|||
else
|
||||
diff_time = (unsigned long)end_time - server_time;
|
||||
|
||||
if (check_critical_diff == TRUE && diff_time > critical_diff)
|
||||
if (check_critical_diff&& diff_time > critical_diff)
|
||||
result = STATE_CRITICAL;
|
||||
else if (check_warning_diff == TRUE && diff_time > warning_diff)
|
||||
else if (check_warning_diff&& diff_time > warning_diff)
|
||||
result = STATE_WARNING;
|
||||
|
||||
printf (_("TIME %s - %lu second time difference|%s %s\n"),
|
||||
|
@ -172,11 +172,11 @@ main (int argc, char **argv)
|
|||
perfdata ("time", (long)conntime, "s",
|
||||
check_warning_time, (long)warning_time,
|
||||
check_critical_time, (long)critical_time,
|
||||
TRUE, 0, FALSE, 0),
|
||||
true, 0, false, 0),
|
||||
perfdata ("offset", diff_time, "s",
|
||||
check_warning_diff, warning_diff,
|
||||
check_critical_diff, critical_diff,
|
||||
TRUE, 0, FALSE, 0));
|
||||
true, 0, false, 0));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ process_arguments (int argc, char **argv)
|
|||
strcpy (argv[c], "-C");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
c = getopt_long (argc, argv, "hVH:w:c:W:C:p:t:u", longopts,
|
||||
&option);
|
||||
|
||||
|
@ -236,19 +236,19 @@ process_arguments (int argc, char **argv)
|
|||
print_revision (progname, NP_VERSION);
|
||||
exit (STATE_UNKNOWN);
|
||||
case 'H': /* hostname */
|
||||
if (is_host (optarg) == FALSE)
|
||||
if (!is_host (optarg))
|
||||
usage2 (_("Invalid hostname/address"), optarg);
|
||||
server_address = optarg;
|
||||
break;
|
||||
case 'w': /* warning-variance */
|
||||
if (is_intnonneg (optarg)) {
|
||||
warning_diff = strtoul (optarg, NULL, 10);
|
||||
check_warning_diff = TRUE;
|
||||
check_warning_diff = true;
|
||||
}
|
||||
else if (strspn (optarg, "0123456789:,") > 0) {
|
||||
if (sscanf (optarg, "%lu%*[:,]%d", &warning_diff, &warning_time) == 2) {
|
||||
check_warning_diff = TRUE;
|
||||
check_warning_time = TRUE;
|
||||
check_warning_diff = true;
|
||||
check_warning_time = true;
|
||||
}
|
||||
else {
|
||||
usage4 (_("Warning thresholds must be a positive integer"));
|
||||
|
@ -261,13 +261,13 @@ process_arguments (int argc, char **argv)
|
|||
case 'c': /* critical-variance */
|
||||
if (is_intnonneg (optarg)) {
|
||||
critical_diff = strtoul (optarg, NULL, 10);
|
||||
check_critical_diff = TRUE;
|
||||
check_critical_diff = true;
|
||||
}
|
||||
else if (strspn (optarg, "0123456789:,") > 0) {
|
||||
if (sscanf (optarg, "%lu%*[:,]%d", &critical_diff, &critical_time) ==
|
||||
2) {
|
||||
check_critical_diff = TRUE;
|
||||
check_critical_time = TRUE;
|
||||
check_critical_diff = true;
|
||||
check_critical_time = true;
|
||||
}
|
||||
else {
|
||||
usage4 (_("Critical thresholds must be a positive integer"));
|
||||
|
@ -282,14 +282,14 @@ process_arguments (int argc, char **argv)
|
|||
usage4 (_("Warning threshold must be a positive integer"));
|
||||
else
|
||||
warning_time = atoi (optarg);
|
||||
check_warning_time = TRUE;
|
||||
check_warning_time = true;
|
||||
break;
|
||||
case 'C': /* critical-connect */
|
||||
if (!is_intnonneg (optarg))
|
||||
usage4 (_("Critical threshold must be a positive integer"));
|
||||
else
|
||||
critical_time = atoi (optarg);
|
||||
check_critical_time = TRUE;
|
||||
check_critical_time = true;
|
||||
break;
|
||||
case 'p': /* port */
|
||||
if (!is_intnonneg (optarg))
|
||||
|
@ -304,14 +304,14 @@ process_arguments (int argc, char **argv)
|
|||
socket_timeout = atoi (optarg);
|
||||
break;
|
||||
case 'u': /* udp */
|
||||
use_udp = TRUE;
|
||||
use_udp = true;
|
||||
}
|
||||
}
|
||||
|
||||
c = optind;
|
||||
if (server_address == NULL) {
|
||||
if (argc > c) {
|
||||
if (is_host (argv[c]) == FALSE)
|
||||
if (!is_host (argv[c]))
|
||||
usage2 (_("Invalid hostname/address"), optarg);
|
||||
server_address = argv[c];
|
||||
}
|
||||
|
|
1091
plugins/check_ups.c
1091
plugins/check_ups.c
File diff suppressed because it is too large
Load diff
|
@ -179,7 +179,7 @@ main (int argc, char **argv)
|
|||
printf (_("USERS %s - %d users currently logged in |%s\n"),
|
||||
state_text(result), users,
|
||||
sperfdata_int("users", users, "", warning_range,
|
||||
critical_range, TRUE, 0, FALSE, 0));
|
||||
critical_range, true, 0, false, 0));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -202,7 +202,7 @@ process_arguments (int argc, char **argv)
|
|||
if (argc < 2)
|
||||
usage ("\n");
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
c = getopt_long (argc, argv, "+hVvc:w:", longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF || c == 1)
|
||||
|
@ -227,18 +227,23 @@ process_arguments (int argc, char **argv)
|
|||
}
|
||||
|
||||
c = optind;
|
||||
|
||||
if (warning_range == NULL && argc > c)
|
||||
warning_range = argv[c++];
|
||||
|
||||
if (critical_range == NULL && argc > c)
|
||||
critical_range = argv[c++];
|
||||
|
||||
/* this will abort in case of invalid ranges */
|
||||
set_thresholds (&thlds, warning_range, critical_range);
|
||||
|
||||
if (thlds->warning->end < 0)
|
||||
usage4 (_("Warning threshold must be a positive integer"));
|
||||
if (thlds->critical->end < 0)
|
||||
usage4 (_("Critical threshold must be a positive integer"));
|
||||
if (!thlds->warning) {
|
||||
usage4 (_("Warning threshold must be a valid range expression"));
|
||||
}
|
||||
|
||||
if (!thlds->critical) {
|
||||
usage4 (_("Critical threshold must be a valid range expression"));
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -261,10 +266,10 @@ print_help (void)
|
|||
printf (UT_HELP_VRSN);
|
||||
printf (UT_EXTRA_OPTS);
|
||||
|
||||
printf (" %s\n", "-w, --warning=INTEGER");
|
||||
printf (" %s\n", _("Set WARNING status if more than INTEGER users are logged in"));
|
||||
printf (" %s\n", "-c, --critical=INTEGER");
|
||||
printf (" %s\n", _("Set CRITICAL status if more than INTEGER users are logged in"));
|
||||
printf (" %s\n", "-w, --warning=RANGE_EXPRESSION");
|
||||
printf (" %s\n", _("Set WARNING status if number of logged in users violates RANGE_EXPRESSION"));
|
||||
printf (" %s\n", "-c, --critical=RANGE_EXPRESSION");
|
||||
printf (" %s\n", _("Set CRITICAL status if number of logged in users violates RANGE_EXPRESSION"));
|
||||
|
||||
printf (UT_SUPPORT);
|
||||
}
|
||||
|
|
|
@ -184,14 +184,6 @@ enum {
|
|||
ERROR = -1
|
||||
};
|
||||
|
||||
/* AIX seems to have this defined somewhere else */
|
||||
#ifndef FALSE
|
||||
enum {
|
||||
FALSE,
|
||||
TRUE
|
||||
};
|
||||
#endif
|
||||
|
||||
enum {
|
||||
STATE_OK,
|
||||
STATE_WARNING,
|
||||
|
|
|
@ -47,7 +47,7 @@ static const char **process_arguments (int, char **);
|
|||
void validate_arguments (char **);
|
||||
void print_help (void);
|
||||
void print_usage (void);
|
||||
int subst_text = FALSE;
|
||||
bool subst_text = false;
|
||||
|
||||
static int state[4] = {
|
||||
STATE_OK,
|
||||
|
@ -63,7 +63,6 @@ main (int argc, char **argv)
|
|||
char *sub;
|
||||
char **command_line;
|
||||
output chld_out, chld_err;
|
||||
int i;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
|
@ -86,7 +85,7 @@ main (int argc, char **argv)
|
|||
result = cmd_run_array (command_line, &chld_out, &chld_err, 0);
|
||||
}
|
||||
if (chld_err.lines > 0) {
|
||||
for (i = 0; i < chld_err.lines; i++) {
|
||||
for (size_t i = 0; i < chld_err.lines; i++) {
|
||||
fprintf (stderr, "%s\n", chld_err.line[i]);
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +94,7 @@ main (int argc, char **argv)
|
|||
if (chld_out.lines == 0)
|
||||
die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n"));
|
||||
|
||||
for (i = 0; i < chld_out.lines; i++) {
|
||||
for (size_t i = 0; i < chld_out.lines; i++) {
|
||||
if (subst_text && result >= 0 && result <= 4 && result != state[result]) {
|
||||
/* Loop over each match found */
|
||||
while ((sub = strstr (chld_out.line[i], state_text (result)))) {
|
||||
|
@ -122,7 +121,7 @@ static const char **
|
|||
process_arguments (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int permute = TRUE;
|
||||
bool permute = true;
|
||||
|
||||
int option = 0;
|
||||
static struct option longopts[] = {
|
||||
|
@ -168,26 +167,26 @@ process_arguments (int argc, char **argv)
|
|||
case 'o': /* replacement for OK */
|
||||
if ((state[STATE_OK] = mp_translate_state(optarg)) == ERROR)
|
||||
usage4 (_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
|
||||
permute = FALSE;
|
||||
permute = false;
|
||||
break;
|
||||
|
||||
case 'w': /* replacement for WARNING */
|
||||
if ((state[STATE_WARNING] = mp_translate_state(optarg)) == ERROR)
|
||||
usage4 (_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
|
||||
permute = FALSE;
|
||||
permute = false;
|
||||
break;
|
||||
case 'c': /* replacement for CRITICAL */
|
||||
if ((state[STATE_CRITICAL] = mp_translate_state(optarg)) == ERROR)
|
||||
usage4 (_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
|
||||
permute = FALSE;
|
||||
permute = false;
|
||||
break;
|
||||
case 'u': /* replacement for UNKNOWN */
|
||||
if ((state[STATE_UNKNOWN] = mp_translate_state(optarg)) == ERROR)
|
||||
usage4 (_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
|
||||
permute = FALSE;
|
||||
permute = false;
|
||||
break;
|
||||
case 's': /* Substitute status text */
|
||||
subst_text = TRUE;
|
||||
subst_text = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -221,8 +220,10 @@ print_help (void)
|
|||
|
||||
printf (COPYRIGHT, copyright, email);
|
||||
|
||||
printf ("%s\n", _("Negates the status of a plugin (returns OK for CRITICAL and vice-versa)."));
|
||||
printf ("%s\n", _("Additional switches can be used to control which state becomes what."));
|
||||
printf ("%s\n", _("Negates only the return code of a plugin (returns OK for CRITICAL and vice-versa) by default."));
|
||||
printf ("%s\n", _("Additional switches can be used to control:\n"));
|
||||
printf ("\t - which state becomes what\n");
|
||||
printf ("\t - changing the plugin output text to match the return code");
|
||||
|
||||
printf ("\n\n");
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue