New upstream version 2.4.0

This commit is contained in:
Jan Wagner 2024-07-23 20:21:44 +00:00
parent d5a5faa95b
commit 600e193ca4
102 changed files with 16219 additions and 31778 deletions

View file

@ -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.

View file

@ -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 \

View file

@ -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
View file

@ -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

View file

@ -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
View file

@ -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

File diff suppressed because it is too large Load diff

348
build-aux/compile Executable file
View 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

File diff suppressed because it is too large Load diff

2855
build-aux/config.sub vendored

File diff suppressed because it is too large Load diff

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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'. */

20536
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -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
)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
])
])

View file

@ -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

View file

@ -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;
}

View file

@ -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

View file

@ -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 *);

View 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 */

View file

@ -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);
}

View file

@ -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"

View file

@ -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@

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -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%"

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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]);
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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");

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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"));

View file

@ -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];

View file

@ -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

View file

@ -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;
}

View file

@ -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++;
}

View file

@ -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++;
}

View file

@ -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);

View file

@ -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");

View file

@ -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) {

View file

@ -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[]){

View file

@ -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);

View file

@ -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);
}

View file

@ -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>"));

View file

@ -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);

View file

@ -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);
}
/******************************************************************************

View file

@ -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]);
}

View file

@ -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");
}

View file

@ -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;

View file

@ -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)) {

View file

@ -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) {

View file

@ -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 */

View file

@ -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);
}

View file

@ -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");
}

View file

@ -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;
}

View file

@ -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];
}

File diff suppressed because it is too large Load diff

View file

@ -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);
}

View file

@ -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,

View file

@ -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");

View file

@ -34,7 +34,7 @@ unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT;
unsigned int socket_timeout_state = STATE_CRITICAL;
int econn_refuse_state = STATE_CRITICAL;
int was_refused = FALSE;
bool was_refused = false;
#if USE_IPV6
int address_family = AF_UNSPEC;
#else
@ -215,14 +215,14 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
result = connect (*sd, r->ai_addr, r->ai_addrlen);
if (result == 0) {
was_refused = FALSE;
was_refused = false;
break;
}
if (result < 0) {
switch (errno) {
case ECONNREFUSED:
was_refused = TRUE;
was_refused = true;
break;
}
}
@ -246,7 +246,7 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
}
result = connect(*sd, (struct sockaddr *)&su, sizeof(su));
if (result < 0 && errno == ECONNREFUSED)
was_refused = TRUE;
was_refused = true;
}
if (result == 0)
@ -326,13 +326,11 @@ send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int
}
int
is_host (const char *address)
{
bool is_host (const char *address) {
if (is_addr (address) || is_hostname (address))
return (TRUE);
return (true);
return (FALSE);
return (false);
}
void
@ -342,20 +340,18 @@ host_or_die(const char *str)
usage_va(_("Invalid hostname/address - %s"), str);
}
int
is_addr (const char *address)
{
bool is_addr (const char *address) {
#ifdef USE_IPV6
if (address_family == AF_INET && is_inet_addr (address))
return TRUE;
return true;
else if (address_family == AF_INET6 && is_inet6_addr (address))
return TRUE;
return true;
#else
if (is_inet_addr (address))
return (TRUE);
return (true);
#endif
return (FALSE);
return (false);
}
int
@ -370,10 +366,10 @@ dns_lookup (const char *in, struct sockaddr_storage *ss, int family)
retval = getaddrinfo (in, NULL, &hints, &res);
if (retval != 0)
return FALSE;
return false;
if (ss != NULL)
memcpy (ss, res->ai_addr, res->ai_addrlen);
freeaddrinfo (res);
return TRUE;
return true;
}

View file

@ -73,8 +73,8 @@ int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer,
/* "is_*" wrapper macros and functions */
int is_host (const char *);
int is_addr (const char *);
bool is_host (const char *);
bool is_addr (const char *);
int dns_lookup (const char *, struct sockaddr_storage *, int);
void host_or_die(const char *str);
#define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family)
@ -89,7 +89,7 @@ void host_or_die(const char *str);
extern unsigned int socket_timeout;
extern unsigned int socket_timeout_state;
extern int econn_refuse_state;
extern int was_refused;
extern bool was_refused;
extern int address_family;
void socket_timeout_alarm_handler (int) __attribute__((noreturn));

View file

@ -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,
@ -164,8 +164,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 \
@ -178,7 +177,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 \
@ -196,7 +194,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 \
@ -286,8 +283,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__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/build-aux/depcomp \
$(top_srcdir)/build-aux/mkinstalldirs
@ -318,6 +313,8 @@ CFLAGS = @CFLAGS@
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = @DEFS@
@ -337,6 +334,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@
@ -1708,6 +1706,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@
@ -1863,7 +1863,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

View file

@ -105,7 +105,7 @@ spopen (const char *cmdstring)
#endif
env[0] = strdup("LC_ALL=C");
env[1] = '\0';
env[1] = NULL;
/* if no command was passed, return with no error */
if (cmdstring == NULL)

View file

@ -115,7 +115,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
if(!np_pids) NP_RUNCMD_INIT;
env[0] = strdup("LC_ALL=C");
env[1] = '\0';
env[1] = NULL;
/* make copy of command string so strtok() doesn't silently modify it */
/* (the calling program may want to access it later) */
@ -240,13 +240,12 @@ np_runcmd_close(int fd)
void
runcmd_timeout_alarm_handler (int signo)
{
size_t i;
if (signo == SIGALRM)
puts(_("CRITICAL - Plugin timed out while executing system call"));
long maxfd = mp_open_max();
if(np_pids) for(i = 0; i < maxfd; i++) {
if(np_pids) for(long int i = 0; i < maxfd; i++) {
if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
}

View file

@ -205,9 +205,9 @@ SKIP: {
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" );
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" );
is( $res->return_code, 0, "Redirection based on location is okay");
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" );
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
}

View file

@ -23,11 +23,11 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth
if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
plan skip_all => "Need 2 mountpoints to test";
} else {
plan tests => 88;
plan tests => 94;
}
$result = NPTest->testCmd(
"./check_disk -w 1% -c 1% -p $mountpoint_valid -w 1% -c 1% -p $mountpoint2_valid"
$result = NPTest->testCmd(
"./check_disk -w 1% -c 1% -p $mountpoint_valid -w 1% -c 1% -p $mountpoint2_valid"
);
cmp_ok( $result->return_code, "==", 0, "Checking two mountpoints (must have at least 1% free in space and inodes)");
my $c = 0;
@ -44,7 +44,7 @@ my @perf_data = sort(split(/ /, $result->perf_output));
# Calculate avg_free free on mountpoint1 and mountpoint2
# because if you check in the middle, you should get different errors
$_ = $result->output;
my ($free_on_mp1, $free_on_mp2) = (m/\((\d+)%.*\((\d+)%/);
my ($free_on_mp1, $free_on_mp2) = (m/\((\d+\.\d+)%.*\((\d+\.\d+)%/);
die "Cannot parse output: $_" unless ($free_on_mp1 && $free_on_mp2);
my $avg_free = ceil(($free_on_mp1+$free_on_mp2)/2);
my ($more_free, $less_free);
@ -103,8 +103,8 @@ is ($crit_percth_data, int((1-10/100)*$total_percth_data), "Wrong critical in pe
# Check when order of mount points are reversed, that perf data remains same
$result = NPTest->testCmd(
"./check_disk -w 1% -c 1% -p $mountpoint2_valid -w 1% -c 1% -p $mountpoint_valid"
$result = NPTest->testCmd(
"./check_disk -w 1% -c 1% -p $mountpoint2_valid -w 1% -c 1% -p $mountpoint_valid"
);
@_ = sort(split(/ /, $result->perf_output));
is_deeply( \@perf_data, \@_, "perf data for both filesystems same when reversed");
@ -119,8 +119,12 @@ like ( $result->only_output, qr/$more_free/, "Have disk name in text");
$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" );
cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free");
$_ = $result->output;
my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+)MiB .* (\d+)MiB /g);
die "Cannot parse output: $_" unless ($free_mb_on_mp1 && $free_mb_on_mp2);
my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2;
@ -134,8 +138,8 @@ cmp_ok( $result->return_code, '==', 0, "Old syntax okay" );
$result = NPTest->testCmd( "./check_disk -w 1% -c 1% -p $more_free" );
cmp_ok( $result->return_code, "==", 0, "At least 1% free" );
$result = NPTest->testCmd(
"./check_disk -w 1% -c 1% -p $more_free -w 100% -c 100% -p $less_free"
$result = NPTest->testCmd(
"./check_disk -w 1% -c 1% -p $more_free -w 100% -c 100% -p $less_free"
);
cmp_ok( $result->return_code, "==", 2, "Get critical on less_free mountpoint $less_free" );
like( $result->output, $failureOutput, "Right output" );
@ -151,14 +155,14 @@ $result = NPTest->testCmd(
);
cmp_ok( $result->return_code, '==', 0, "Get ok on more_free mountpoint, when checking avg_free");
$result = NPTest->testCmd(
"./check_disk -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
$result = NPTest->testCmd(
"./check_disk -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
);
cmp_ok( $result->return_code, "==", 1, "Combining above two tests, get warning");
my $all_disks = $result->output;
$result = NPTest->testCmd(
"./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
"./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
);
isnt( $result->output, $all_disks, "-e gives different output");
@ -240,7 +244,7 @@ TODO: {
cmp_ok( $result->return_code, '==', 3, "Invalid command line options" );
}
$result = NPTest->testCmd(
$result = NPTest->testCmd(
"./check_disk -p $mountpoint_valid -w 10% -c 15%"
);
cmp_ok( $result->return_code, "==", 3, "Invalid options: -p must come after thresholds" );
@ -311,8 +315,8 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -C -w 0% -c 0% -p $mountpoi
like( $result->output, '/;.*;\|/', "-C selects partitions if -p is not given");
# grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all + 1) ."-g group -p $mountpoint_valid -p $mountpoint2_valid" );
cmp_ok( $result->return_code, '==', 2, "grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit");
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all + 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
cmp_ok( $result->return_code, '==', 2, "grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit\nInstead received: " . $result->output);
# grouping: exit warning if the sum of free megs on mp1+mp2 is between -w and -c
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all - 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
@ -322,7 +326,7 @@ cmp_ok( $result->return_code, '==', 1, "grouping: exit warning if the sum of fre
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free megs on mp1+mp2 is more than warn/crit");
# grouping: exit unknown if group name is given after -p
# grouping: exit unknown if group name is given after -p
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" );
cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname");
@ -355,17 +359,17 @@ like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mo
# ignore-missing: exit okay, when fs is not accessible
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p /bob");
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for not existing filesystem /bob");
like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /bob;.*$/', 'Output OK');
like( $result->output, '/^DISK OK - No disks were found for provided parameters - ignored paths: /bob;.*$/', 'Output OK');
# ignore-missing: exit okay, when regex does not match
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r /bob");
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
like( $result->output, '/^DISK OK - No disks were found for provided parameters;.*$/', 'Output OK');
like( $result->output, '/^DISK OK - No disks were found for provided parameters.*$/', 'Output OK');
# ignore-missing: exit okay, when fs with exact match (-E) is not found
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -E -p /etc");
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay when exact match does not find fs");
like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /etc;.*$/', 'Output OK');
like( $result->output, '/^DISK OK - No disks were found for provided parameters - ignored paths: /etc;.*$/', 'Output OK');
# ignore-missing: exit okay, when checking one existing fs and one non-existing fs (regex)
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r '/bob' -r '^/\$'");
@ -375,4 +379,19 @@ like( $result->output, '/^DISK OK - free space: \/ .*$/', 'Output OK');
# ignore-missing: exit okay, when checking one existing fs and one non-existing fs (path)
$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p '/bob' -p '/'");
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
like( $result->output, '/^DISK OK - free space: / .*; - ignored paths: /bob;.*$/', 'Output OK');
like( $result->output, '/^DISK OK - free space: / .*; - ignored paths: /bob;.*$/', 'Output OK');
# ignore-missing: exit okay, when checking one non-existing fs (path) and one ignored
$result = NPTest->testCmd( "./check_disk -n -w 0% -c 0% -r /dummy -i /dummy2");
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
like( $result->output, '/^DISK OK - No disks were found for provided parameters\|$/', 'Output OK');
# ignore-missing: exit okay, when regex match does not find anything
$result = NPTest->testCmd( "./check_disk -n -e -l -w 10% -c 5% -W 10% -K 5% -r /dummy");
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
like( $result->output, '/^DISK OK\|$/', 'Output OK');
# ignore-missing: exit okay, when regex match does not find anything
$result = NPTest->testCmd( "./check_disk -n -l -w 10% -c 5% -W 10% -K 5% -r /dummy");
cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
like( $result->output, '/^DISK OK - No disks were found for provided parameters\|$/', 'Output OK');

View file

@ -166,10 +166,10 @@ SKIP: {
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" );
is( $res->return_code, 0, "Redirection based on location is okay");
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" );
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
}

View file

@ -8,34 +8,116 @@ use strict;
use Test::More;
use NPTest;
my $res;
# Required parameters
my $ssh_host = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost");
my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1" );
my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost" );
my $ssh_host = getTestParameter("NP_SSH_HOST",
"A host providing SSH service",
"localhost");
my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE",
"The hostname of system not responsive to network requests",
"10.0.0.1" );
my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID",
"An invalid (not known to DNS) hostname",
"nosuchhost" );
plan skip_all => "SSH_HOST must be defined" unless $ssh_host;
plan tests => 6;
plan tests => 14 + 6;
SKIP: {
skip "SSH_HOST must be defined", 6 unless $ssh_host;
my $result = NPTest->testCmd(
"./check_ssh -H $ssh_host"
);
cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
my $result = NPTest->testCmd(
"./check_ssh -H $ssh_host"
);
cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
$result = NPTest->testCmd(
"./check_ssh -H $host_nonresponsive -t 2"
);
cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
$result = NPTest->testCmd(
"./check_ssh -H $host_nonresponsive -t 2"
);
cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
$result = NPTest->testCmd(
"./check_ssh -H $hostname_invalid -t 2"
);
cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");
$result = NPTest->testCmd(
"./check_ssh -H $hostname_invalid -t 2"
);
cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");
}
SKIP: {
skip "No netcat available", 14 unless (system("which nc > /dev/null") == 0);
# netcat on linux (on debian) will just keep the socket open if not advised otherwise
# therefore we add -q to close it after two seconds after receiving the EOF from input
my $nc_flags = "-l 5003 -N";
#A valid protocol version control string has the form
# SSH-protoversion-softwareversion SP comments CR LF
#
# where `comments` is optional, protoversion is the SSH protocol version and
# softwareversion is an arbitrary string representing the server software version
open(NC, "echo 'SSH-2.0-nagiosplug.ssh.0.1' | nc ${nc_flags}|");
sleep 0.1;
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
cmp_ok( $res->return_code, '==', 0, "Got SSH protocol version control string");
like( $res->output, '/^SSH OK - nagiosplug.ssh.0.1 \(protocol 2.0\)/', "Output OK");
close NC;
open(NC, "echo 'SSH-2.0-3.2.9.1' | nc ${nc_flags}|");
sleep 0.1;
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
cmp_ok( $res->return_code, "==", 0, "Got SSH protocol version control string with non-alpha softwareversion string");
like( $res->output, '/^SSH OK - 3.2.9.1 \(protocol 2.0\)/', "Output OK for non-alpha softwareversion string");
close NC;
open(NC, "echo 'SSH-2.0-nagiosplug.ssh.0.1 this is a comment' | nc ${nc_flags} |");
sleep 0.1;
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003 -r nagiosplug.ssh.0.1" );
cmp_ok( $res->return_code, '==', 0, "Got SSH protocol version control string, and parsed comment appropriately");
like( $res->output, '/^SSH OK - nagiosplug.ssh.0.1 \(protocol 2.0\)/', "Output OK");
close NC;
open(NC, "echo 'SSH-' | nc ${nc_flags}|");
sleep 0.1;
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
cmp_ok( $res->return_code, '==', 2, "Got invalid SSH protocol version control string");
like( $res->output, '/^SSH CRITICAL/', "Output OK");
close NC;
open(NC, "echo '' | nc ${nc_flags}|");
sleep 0.1;
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
cmp_ok( $res->return_code, '==', 2, "No version control string received");
like( $res->output, '/^SSH CRITICAL - No version control string received/', "Output OK");
close NC;
open(NC, "echo 'Not a version control string' | nc ${nc_flags}|");
sleep 0.1;
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
cmp_ok( $res->return_code, '==', 2, "No version control string received");
like( $res->output, '/^SSH CRITICAL - No version control string received/', "Output OK");
close NC;
#RFC 4253 permits servers to send any number of data lines prior to sending the protocol version control string
open(NC, "{ echo 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; sleep 0.5;
echo 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'; sleep 0.5;
echo 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'; sleep 0.2;
echo 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD'; sleep 0.3;
printf 'EEEEEEEEEEEEEEEEEE'; sleep 0.2;
printf 'EEEEEEEEEEEEEEEEEE\n'; sleep 0.2;
echo 'Some\nPrepended\nData\nLines\n'; sleep 0.2;
echo 'SSH-2.0-nagiosplug.ssh.0.2';} | nc ${nc_flags}|");
sleep 0.1;
$res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
cmp_ok( $res->return_code, '==', 0, "Got delayed SSH protocol version control string");
like( $res->output, '/^SSH OK - nagiosplug.ssh.0.2 \(protocol 2.0\)/', "Output OK");
close NC;
}

View file

@ -5,7 +5,7 @@
#
use strict;
use Test::More tests => 8;
use Test::More tests => 14;
use NPTest;
my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
@ -14,6 +14,10 @@ my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)
my $result;
$result = NPTest->testCmd( "./check_swap" ); # Always OK
cmp_ok( $result->return_code, "==", 0, "Always OK" );
like( $result->output, $successOutput, "Right output" );
$result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" ); # 1 MB free
cmp_ok( $result->return_code, "==", 0, "At least 1MB free" );
like( $result->output, $successOutput, "Right output" );
@ -29,3 +33,11 @@ like( $result->output, $failureOutput, "Right output" );
$result = NPTest->testCmd( "./check_swap -w 100% -c 1%" ); # 100% (always warn)
cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
like( $result->output, $warnOutput, "Right output" );
$result = NPTest->testCmd( "./check_swap -w 100%" ); # 100% (single threshold, always warn)
cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
like( $result->output, $warnOutput, "Right output" );
$result = NPTest->testCmd( "./check_swap -c 100%" ); # 100% (single threshold, always critical)
cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' );
like( $result->output, $failureOutput, "Right output" );

View file

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

View file

@ -23,13 +23,15 @@
*****************************************************************************/
#include "common.h"
#include "utils.h"
#include "./utils.h"
#include "utils_base.h"
#include <stdarg.h>
#include <limits.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <arpa/inet.h>
extern void print_usage (void);
@ -147,98 +149,107 @@ print_revision (const char *command_name, const char *revision)
command_name, revision, PACKAGE, VERSION);
}
int
is_numeric (char *number)
{
bool is_numeric (char *number) {
char tmp[1];
float x;
if (!number)
return FALSE;
return false;
else if (sscanf (number, "%f%c", &x, tmp) == 1)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_positive (char *number)
{
bool is_positive (char *number) {
if (is_numeric (number) && atof (number) > 0.0)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_negative (char *number)
{
bool is_negative (char *number) {
if (is_numeric (number) && atof (number) < 0.0)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_nonnegative (char *number)
{
bool is_nonnegative (char *number) {
if (is_numeric (number) && atof (number) >= 0.0)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_percentage (char *number)
{
bool is_percentage (char *number) {
int x;
if (is_numeric (number) && (x = atof (number)) >= 0 && x <= 100)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_integer (char *number)
{
bool is_percentage_expression (const char str[]) {
if (!str) {
return false;
}
size_t len = strlen(str);
if (str[len-1] != '%') {
return false;
}
char *foo = calloc(sizeof(char), len + 1);
if (!foo) {
die (STATE_UNKNOWN, _("calloc failed \n"));
}
strcpy(foo, str);
foo[len-1] = '\0';
bool result = is_numeric(foo);
free(foo);
return result;
}
bool is_integer (char *number) {
long int n;
if (!number || (strspn (number, "-0123456789 ") != strlen (number)))
return FALSE;
return false;
n = strtol (number, NULL, 10);
if (errno != ERANGE && n >= INT_MIN && n <= INT_MAX)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_intpos (char *number)
{
bool is_intpos (char *number) {
if (is_integer (number) && atoi (number) > 0)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_intneg (char *number)
{
bool is_intneg (char *number) {
if (is_integer (number) && atoi (number) < 0)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_intnonneg (char *number)
{
bool is_intnonneg (char *number) {
if (is_integer (number) && atoi (number) >= 0)
return TRUE;
return true;
else
return FALSE;
return false;
}
/*
@ -246,19 +257,27 @@ is_intnonneg (char *number)
* On success the number will be written to the _target_ address, if _target_ is not set
* to NULL.
*/
int is_int64(char *number, int64_t *target) {
bool is_int64(char *number, int64_t *target) {
errno = 0;
uint64_t tmp = strtoll(number, NULL, 10);
char *endptr = { 0 };
int64_t tmp = strtoll(number, &endptr, 10);
if (errno != 0) {
return false;
}
if (*endptr == '\0') {
return 0;
}
if (tmp < INT64_MIN || tmp > INT64_MAX) {
return 0;
return false;
}
if (target != NULL) {
*target = tmp;
}
return 1;
return true;
}
/*
@ -266,40 +285,45 @@ int is_int64(char *number, int64_t *target) {
* On success the number will be written to the _target_ address, if _target_ is not set
* to NULL.
*/
int is_uint64(char *number, uint64_t *target) {
bool is_uint64(char *number, uint64_t *target) {
errno = 0;
uint64_t tmp = strtoll(number, NULL, 10);
char *endptr = { 0 };
unsigned long long tmp = strtoull(number, &endptr, 10);
if (errno != 0) {
return 0;
return false;
}
if (tmp < 0 || tmp > UINT64_MAX) {
return 0;
if (*endptr != '\0') {
return false;
}
if (tmp > UINT64_MAX) {
return false;
}
if (target != NULL) {
*target = tmp;
*target = (uint64_t)tmp;
}
return 1;
return true;
}
int
is_intpercent (char *number)
{
bool is_intpercent (char *number) {
int i;
if (is_integer (number) && (i = atoi (number)) >= 0 && i <= 100)
return TRUE;
return true;
else
return FALSE;
return false;
}
int
is_option (char *str)
{
bool is_option (char *str) {
if (!str)
return FALSE;
return false;
else if (strspn (str, "-") == 1 || strspn (str, "-") == 2)
return TRUE;
return true;
else
return FALSE;
return false;
}
#ifdef NEED_GETTIMEOFDAY

View file

@ -16,6 +16,8 @@ suite of plugins. */
/* now some functions etc are being defined in ../lib/utils_base.c */
#include "utils_base.h"
#include <stdbool.h>
#ifdef NP_EXTRA_OPTS
/* Include extra-opts functions if compiled in */
@ -34,21 +36,22 @@ extern time_t start_time, end_time;
/* Test input types */
int is_integer (char *);
int is_intpos (char *);
int is_intneg (char *);
int is_intnonneg (char *);
int is_intpercent (char *);
int is_uint64(char *number, uint64_t *target);
int is_int64(char *number, int64_t *target);
bool is_integer (char *);
bool is_intpos (char *);
bool is_intneg (char *);
bool is_intnonneg (char *);
bool is_intpercent (char *);
bool is_uint64(char *number, uint64_t *target);
bool is_int64(char *number, int64_t *target);
int is_numeric (char *);
int is_positive (char *);
int is_negative (char *);
int is_nonnegative (char *);
int is_percentage (char *);
bool is_numeric (char *);
bool is_positive (char *);
bool is_negative (char *);
bool is_nonnegative (char *);
bool is_percentage (char *);
bool is_percentage_expression (const char[]);
int is_option (char *);
bool is_option (char *);
/* Generalized timer that will do milliseconds if available */
#ifndef HAVE_STRUCT_TIMEVAL

View file

@ -1,11 +0,0 @@
2003-07-02 gettextize <bug-gnu-gettext@gnu.org>
* Makefile.in.in: New file, from gettext-0.11.4.
* boldquot.sed: New file, from gettext-0.11.4.
* en@boldquot.header: New file, from gettext-0.11.4.
* en@quot.header: New file, from gettext-0.11.4.
* insert-header.sin: New file, from gettext-0.11.4.
* quot.sed: New file, from gettext-0.11.4.
* remove-potcdate.sin: New file, from gettext-0.11.4.
* Rules-quot: New file, from gettext-0.11.4.

View file

@ -1,2 +0,0 @@
fr de

View file

@ -1,395 +0,0 @@
# -*- buffer-read-only: t -*- vi: set ro:
# DO NOT EDIT! GENERATED AUTOMATICALLY!
# Makefile for PO directory in any package using GNU gettext.
# Copyright (C) 1995-1997, 2000-2006 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
#
# This file can be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU General Public
# License but which still want to provide support for the GNU gettext
# functionality.
# Please note that the actual code of GNU gettext is covered by the GNU
# General Public License and is *not* in the public domain.
#
# Origin: gettext-0.15
PACKAGE = @PACKAGE@
VERSION = @VERSION@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
SHELL = /bin/sh
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
localedir = @localedir@
gettextsrcdir = $(datadir)/gettext/po
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
mkinstalldirs = $(SHELL) @install_sh@ -d
mkdir_p = @MKDIR_P@
GMSGFMT_ = @GMSGFMT@
GMSGFMT_no = @GMSGFMT@
GMSGFMT_yes = @GMSGFMT_015@
GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
MSGFMT_ = @MSGFMT@
MSGFMT_no = @MSGFMT@
MSGFMT_yes = @MSGFMT_015@
MSGFMT = $(MSGFMT_$(USE_MSGCTXT))
XGETTEXT_ = @XGETTEXT@
XGETTEXT_no = @XGETTEXT@
XGETTEXT_yes = @XGETTEXT_015@
XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
MSGMERGE = msgmerge
MSGMERGE_UPDATE = @MSGMERGE@ --update
MSGINIT = msginit
MSGCONV = msgconv
MSGFILTER = msgfilter
POFILES = @POFILES@
GMOFILES = @GMOFILES@
UPDATEPOFILES = @UPDATEPOFILES@
DUMMYPOFILES = @DUMMYPOFILES@
DISTFILES.common = Makefile.in.in remove-potcdate.sin \
$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
$(POFILES) $(GMOFILES) \
$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
POTFILES = \
CATALOGS = @CATALOGS@
# Makevars gets inserted here. (Don't remove this line!)
.SUFFIXES:
.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
.po.mo:
@echo "$(MSGFMT) -c -o $@ $<"; \
$(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
.po.gmo:
@lang=`echo $* | sed -e 's,.*/,,'`; \
test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
.sin.sed:
sed -e '/^#/d' $< > t-$@
mv t-$@ $@
all: all-@USE_NLS@
all-yes: stamp-po
all-no:
# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
# we don't want to bother translators with empty POT files). We assume that
# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
# In this case, stamp-po is a nop (i.e. a phony target).
# stamp-po is a timestamp denoting the last time at which the CATALOGS have
# been loosely updated. Its purpose is that when a developer or translator
# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
# invocations of "make" will do nothing. This timestamp would not be necessary
# if updating the $(CATALOGS) would always touch them; however, the rule for
# $(POFILES) has been designed to not touch files that don't need to be
# changed.
stamp-po: $(srcdir)/$(DOMAIN).pot
test ! -f $(srcdir)/$(DOMAIN).pot || \
test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
@test ! -f $(srcdir)/$(DOMAIN).pot || { \
echo "touch stamp-po" && \
echo timestamp > stamp-poT && \
mv stamp-poT stamp-po; \
}
# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
# otherwise packages like GCC can not be built if only parts of the source
# have been downloaded.
# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
else \
msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
fi; \
$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
--add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
--files-from=$(srcdir)/POTFILES.in \
--copyright-holder='$(COPYRIGHT_HOLDER)' \
--msgid-bugs-address="$$msgid_bugs_address"
test ! -f $(DOMAIN).po || { \
if test -f $(srcdir)/$(DOMAIN).pot; then \
sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
else \
rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
fi; \
else \
mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
fi; \
}
# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
# every "make" invocation, only create it when it is missing.
# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
$(srcdir)/$(DOMAIN).pot:
$(MAKE) $(DOMAIN).pot-update
# This target rebuilds a PO file if $(DOMAIN).pot has changed.
# Note that a PO file is not touched if it doesn't need to be changed.
$(POFILES): $(srcdir)/$(DOMAIN).pot
@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
if test -f "$(srcdir)/$${lang}.po"; then \
test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
else \
$(MAKE) $${lang}.po-create; \
fi
install: install-exec install-data
install-exec:
install-data: install-data-@USE_NLS@
if test "$(PACKAGE)" = "gettext-tools"; then \
$(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
for file in $(DISTFILES.common) Makevars.template; do \
$(INSTALL_DATA) $(srcdir)/$$file \
$(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
for file in Makevars; do \
rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
else \
: ; \
fi
install-data-no: all
install-data-yes: all
$(mkdir_p) $(DESTDIR)$(datadir)
@catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
dir=$(localedir)/$$lang/LC_MESSAGES; \
$(mkdir_p) $(DESTDIR)$$dir; \
if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
$(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
if test -n "$$lc"; then \
if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
(cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
for file in *; do \
if test -f $$file; then \
ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
fi; \
done); \
rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
else \
if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
:; \
else \
rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
fi; \
fi; \
rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
fi; \
done; \
done
install-strip: install
installdirs: installdirs-exec installdirs-data
installdirs-exec:
installdirs-data: installdirs-data-@USE_NLS@
if test "$(PACKAGE)" = "gettext-tools"; then \
$(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
else \
: ; \
fi
installdirs-data-no:
installdirs-data-yes:
$(mkdir_p) $(DESTDIR)$(datadir)
@catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
dir=$(localedir)/$$lang/LC_MESSAGES; \
$(mkdir_p) $(DESTDIR)$$dir; \
for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
if test -n "$$lc"; then \
if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
(cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
for file in *; do \
if test -f $$file; then \
ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
fi; \
done); \
rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
else \
if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
:; \
else \
rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
fi; \
fi; \
fi; \
done; \
done
# Define this as empty until I found a useful application.
installcheck:
uninstall: uninstall-exec uninstall-data
uninstall-exec:
uninstall-data: uninstall-data-@USE_NLS@
if test "$(PACKAGE)" = "gettext-tools"; then \
for file in $(DISTFILES.common) Makevars.template; do \
rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
else \
: ; \
fi
uninstall-data-no:
uninstall-data-yes:
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
done; \
done
check: all
info dvi ps pdf html tags TAGS ctags CTAGS ID:
mostlyclean:
rm -f remove-potcdate.sed
rm -f stamp-poT
rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
rm -fr *.o
clean: mostlyclean
distclean: clean
rm -f Makefile Makefile.in POTFILES *.mo
maintainer-clean: distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
rm -f stamp-po $(GMOFILES)
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
dist distdir:
$(MAKE) update-po
@$(MAKE) dist2
# This is a separate target because 'update-po' must be executed before.
dist2: stamp-po $(DISTFILES)
dists="$(DISTFILES)"; \
if test "$(PACKAGE)" = "gettext-tools"; then \
dists="$$dists Makevars.template"; \
fi; \
if test -f $(srcdir)/$(DOMAIN).pot; then \
dists="$$dists $(DOMAIN).pot stamp-po"; \
fi; \
if test -f $(srcdir)/ChangeLog; then \
dists="$$dists ChangeLog"; \
fi; \
for i in 0 1 2 3 4 5 6 7 8 9; do \
if test -f $(srcdir)/ChangeLog.$$i; then \
dists="$$dists ChangeLog.$$i"; \
fi; \
done; \
if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
for file in $$dists; do \
if test -f $$file; then \
cp -p $$file $(distdir) || exit 1; \
else \
cp -p $(srcdir)/$$file $(distdir) || exit 1; \
fi; \
done
update-po: Makefile
$(MAKE) $(DOMAIN).pot-update
test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
$(MAKE) update-gmo
# General rule for creating PO files.
.nop.po-create:
@lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
exit 1
# General rule for updating PO files.
.nop.po-update:
@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
tmpdir=`pwd`; \
echo "$$lang:"; \
test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
cd $(srcdir); \
if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
rm -f $$tmpdir/$$lang.new.po; \
else \
if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
:; \
else \
echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
exit 1; \
fi; \
fi; \
else \
echo "msgmerge for $$lang.po failed!" 1>&2; \
rm -f $$tmpdir/$$lang.new.po; \
fi
$(DUMMYPOFILES):
update-gmo: Makefile $(GMOFILES)
@:
Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
cd $(top_builddir) \
&& $(SHELL) ./config.status $(subdir)/$@.in po-directories
force:
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -1,29 +0,0 @@
# Makefile variables for PO directory in any package using GNU gettext.
# Usually the message domain is the same as the package name.
DOMAIN = $(PACKAGE)
# These two variables depend on the location of this directory.
subdir = po
top_builddir = ..
# These options get passed to xgettext.
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=asprintf:2:c-format --flag=vasprintf:2:c-format --no-location
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
# package. (Note that the msgstr strings, extracted from the package's
# sources, belong to the copyright holder of the package.) Translators are
# expected to transfer the copyright for their translations to this person
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
COPYRIGHT_HOLDER = Monitoring Plugins Development Team
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
EXTRA_LOCALE_CATEGORIES =
# Email address were to send bug report for the .po translation files
PACKAGE_BUGREPORT = devel@monitoring-plugins.org

View file

@ -1,44 +0,0 @@
plugins/check_by_ssh.c
plugins/check_cluster.c
plugins/check_dig.c
plugins/check_disk.c
plugins/check_dns.c
plugins/check_dummy.c
plugins/check_fping.c
plugins/check_game.c
plugins/check_hpjd.c
plugins/check_http.c
plugins/check_ldap.c
plugins/check_load.c
plugins/check_mrtg.c
plugins/check_mrtgtraf.c
plugins/check_mysql.c
plugins/check_nagios.c
plugins/check_nt.c
plugins/check_ntp.c
plugins/check_ntp_peer.c
plugins/check_ntp_time.c
plugins/check_nwstat.c
plugins/check_overcr.c
plugins/check_pgsql.c
plugins/check_ping.c
plugins/check_procs.c
plugins/check_radius.c
plugins/check_real.c
plugins/check_smtp.c
plugins/check_snmp.c
plugins/check_ssh.c
plugins/check_swap.c
plugins/check_tcp.c
plugins/check_time.c
plugins/check_ups.c
plugins/check_users.c
plugins/check_ide_smart.c
plugins/negate.c
plugins/netutils.c
plugins/popen.c
plugins/urlize.c
plugins/utils.c
plugins/utils.h
plugins-root/check_dhcp.c
plugins-root/check_icmp.c

BIN
po/de.gmo

Binary file not shown.

5447
po/de.po

File diff suppressed because it is too large Load diff

BIN
po/fr.gmo

Binary file not shown.

5445
po/fr.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,19 +0,0 @@
# Sed script that remove the POT-Creation-Date line in the header entry
# from a POT file.
#
# The distinction between the first and the following occurrences of the
# pattern is achieved by looking at the hold space.
/^"POT-Creation-Date: .*"$/{
x
# Test if the hold space is empty.
s/P/P/
ta
# Yes it was empty. First occurrence. Remove the line.
g
d
bb
:a
# The hold space was nonempty. Following occurrences. Do nothing.
x
:b
}

View file

@ -1 +0,0 @@
timestamp

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