From git at monitoring-plugins.org Tue Nov 5 09:20:11 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Tue, 5 Nov 2024 09:20:11 +0100 (CET) Subject: [monitoring-plugins] check_disk: Initialize most variables Message-ID: <20241105082011.CF2842000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: c0bcad7feb18bd1e3a1f98f2f41c437925a8dbf0 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Mon Nov 4 23:12:18 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=c0bcad7 check_disk: Initialize most variables --- plugins/check_disk.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/check_disk.c b/plugins/check_disk.c index d1d1b92..037a6f7 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -156,20 +156,20 @@ static struct name_list *seen = NULL; int main(int argc, char **argv) { int result = STATE_UNKNOWN; int disk_result = STATE_UNKNOWN; - char *output; - char *ignored; - char *details; - char *perf; - char *perf_ilabel; + char *output = NULL; + char *ignored = NULL; + char *details = NULL; + char *perf = NULL; + char *perf_ilabel = NULL; char *preamble = " - free space:"; char *ignored_preamble = " - ignored paths:"; - char *flag_header; - int temp_result; + char *flag_header = NULL; + int temp_result = STATE_UNKNOWN; - struct mount_entry *me; - struct fs_usage fsp; - struct parameter_list *temp_list; - struct parameter_list *path; + struct mount_entry *me = NULL; + struct fs_usage fsp = {0}; + struct parameter_list *temp_list = NULL; + struct parameter_list *path = NULL; #ifdef __CYGWIN__ char mountdir[32]; From git at monitoring-plugins.org Tue Nov 5 09:20:11 2024 From: git at monitoring-plugins.org (GitHub) Date: Tue, 5 Nov 2024 09:20:11 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2039 from ... Message-ID: <20241105082011.DBE062000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 94150ae347beb25ac369d5773834ceef7f3736d3 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Tue Nov 5 09:12:28 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=94150ae Merge pull request #2039 from RincewindsHat/fix/check_disk_initialize_variables check_disk: Initialize most variables --- From git at monitoring-plugins.org Wed Nov 6 09:30:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Wed, 6 Nov 2024 09:30:12 +0100 (CET) Subject: [monitoring-plugins] Sync with the latest Gnulib code (d4ec02b3cc) Message-ID: <20241106083012.3040C2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 5be04ec2ceb1df77afbca4fcbf9e92a712612d6f Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Thu Oct 31 16:27:12 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=5be04ec Sync with the latest Gnulib code (d4ec02b3cc) --- gl/Makefile.am | 321 +++++-- gl/_Noreturn.h | 2 +- gl/af_alg.c | 2 +- gl/af_alg.h | 2 +- gl/alloca.in.h | 2 +- gl/arg-nonnull.h | 2 +- gl/arpa_inet.in.h | 7 +- gl/asnprintf.c | 2 +- gl/asprintf.c | 2 +- gl/assert.in.h | 2 +- gl/attribute.h | 19 +- gl/base64.c | 50 +- gl/base64.h | 54 +- gl/basename-lgpl.c | 2 +- gl/basename-lgpl.h | 7 +- gl/basename.c | 2 +- gl/btowc.c | 10 +- gl/byteswap.in.h | 2 +- gl/c++defs.h | 8 +- gl/calloc.c | 2 +- gl/cdefs.h | 46 +- gl/cloexec.c | 2 +- gl/cloexec.h | 12 +- gl/close.c | 2 +- gl/dirname-lgpl.c | 2 +- gl/dirname.c | 2 +- gl/dirname.h | 8 +- gl/dup2.c | 2 +- gl/dynarray.h | 2 +- gl/errno.in.h | 2 +- gl/error.c | 7 +- gl/error.h | 66 -- gl/error.in.h | 216 +++++ gl/exitfail.c | 2 +- gl/exitfail.h | 12 +- gl/fcntl.c | 2 +- gl/fcntl.in.h | 7 +- gl/fd-hook.c | 2 +- gl/fd-hook.h | 2 +- gl/fflush.c | 2 +- gl/filename.h | 2 +- gl/float+.h | 2 +- gl/float.c | 2 +- gl/float.in.h | 2 +- gl/floor.c | 2 +- gl/floorf.c | 2 +- gl/fopen.c | 12 +- gl/fpurge.c | 2 +- gl/freading.c | 2 +- gl/freading.h | 7 +- gl/free.c | 2 +- gl/fseek.c | 2 +- gl/fseeko.c | 2 +- gl/fstat.c | 2 +- gl/fsusage.c | 2 +- gl/fsusage.h | 16 +- gl/ftell.c | 2 +- gl/ftello.c | 2 +- gl/gai_strerror.c | 2 +- gl/getaddrinfo.c | 2 +- gl/getdelim.c | 6 +- gl/getdtablesize.c | 2 +- gl/gethostname.c | 2 +- gl/getline.c | 2 +- gl/getloadavg.c | 2 +- gl/getopt-cdefs.in.h | 8 +- gl/getopt-core.h | 2 +- gl/getopt-ext.h | 2 +- gl/getopt-pfx-core.h | 4 +- gl/getopt-pfx-ext.h | 2 +- gl/getopt.c | 35 +- gl/getopt.in.h | 2 +- gl/getopt1.c | 4 +- gl/getopt_int.h | 2 +- gl/getprogname.c | 24 +- gl/getprogname.h | 20 +- gl/gettext.h | 2 +- gl/gl_openssl.h | 10 +- gl/glthread/lock.c | 2 +- gl/glthread/lock.h | 10 +- gl/glthread/threadlib.c | 2 +- gl/hard-locale.c | 16 +- gl/hard-locale.h | 18 +- gl/ialloc.c | 2 +- gl/ialloc.h | 68 +- gl/idpriv-droptemp.c | 2 +- gl/idpriv.h | 2 +- gl/idx.h | 12 +- gl/inet_ntop.c | 2 +- gl/intprops-internal.h | 11 +- gl/intprops.h | 2 +- gl/inttypes.in.h | 41 +- gl/iswblank.c | 26 + gl/iswctype-impl.h | 22 + gl/iswctype.c | 36 + gl/iswdigit.c | 26 + gl/iswpunct.c | 33 + gl/iswxdigit.c | 33 + gl/itold.c | 2 +- gl/langinfo.in.h | 9 +- gl/lc-charset-dispatch.c | 2 +- gl/lc-charset-dispatch.h | 2 +- gl/libc-config.h | 24 +- gl/limits.in.h | 32 +- gl/localcharset.c | 4 +- gl/localcharset.h | 6 +- gl/locale.in.h | 37 +- gl/localeconv.c | 47 +- gl/lseek.c | 2 +- gl/m4/00gnulib.m4 | 13 +- gl/m4/__inline.m4 | 7 +- gl/m4/absolute-header.m4 | 7 +- gl/m4/af_alg.m4 | 5 +- gl/m4/alloca.m4 | 5 +- gl/m4/arpa_inet_h.m4 | 5 +- gl/m4/assert_h.m4 | 27 +- gl/m4/base64.m4 | 5 +- gl/m4/btowc.m4 | 85 +- gl/m4/builtin-expect.m4 | 8 +- gl/m4/byteswap.m4 | 5 +- gl/m4/c-bool.m4 | 8 +- gl/m4/calloc.m4 | 28 +- gl/m4/close.m4 | 7 +- gl/m4/codeset.m4 | 5 +- gl/m4/double-slash-root.m4 | 5 +- gl/m4/dup2.m4 | 7 +- gl/m4/eealloc.m4 | 5 +- gl/m4/environ.m4 | 5 +- gl/m4/errno_h.m4 | 5 +- gl/m4/error.m4 | 22 +- gl/m4/error_h.m4 | 125 +++ gl/m4/exponentd.m4 | 7 +- gl/m4/extensions.m4 | 24 +- gl/m4/extern-inline.m4 | 12 +- gl/m4/fclose.m4 | 99 ++ gl/m4/fcntl-o.m4 | 11 +- gl/m4/fcntl.m4 | 7 +- gl/m4/fcntl_h.m4 | 6 +- gl/m4/fflush.m4 | 18 +- gl/m4/float_h.m4 | 13 +- gl/m4/floorf.m4 | 29 +- gl/m4/fopen.m4 | 24 +- gl/m4/fpurge.m4 | 15 +- gl/m4/freading.m4 | 10 +- gl/m4/free.m4 | 11 +- gl/m4/fseek.m4 | 5 +- gl/m4/fseeko.m4 | 5 +- gl/m4/fstat.m4 | 9 +- gl/m4/fstypename.m4 | 14 +- gl/m4/fsusage.m4 | 14 +- gl/m4/ftell.m4 | 5 +- gl/m4/ftello.m4 | 30 +- gl/m4/getaddrinfo.m4 | 9 +- gl/m4/getdelim.m4 | 14 +- gl/m4/getdtablesize.m4 | 5 +- gl/m4/gethostname.m4 | 9 +- gl/m4/getline.m4 | 23 +- gl/m4/getloadavg.m4 | 37 +- gl/m4/getopt.m4 | 9 +- gl/m4/getprogname.m4 | 33 +- gl/m4/gl-openssl.m4 | 8 +- gl/m4/gnulib-cache.m4 | 2 +- gl/m4/gnulib-common.m4 | 426 +++++++-- gl/m4/gnulib-comp.m4 | 100 +- gl/m4/gnulib-tool.m4 | 5 +- gl/m4/hostent.m4 | 9 +- gl/m4/idpriv.m4 | 5 +- gl/m4/include_next.m4 | 13 +- gl/m4/inet_ntop.m4 | 9 +- gl/m4/intmax_t.m4 | 5 +- gl/m4/inttypes.m4 | 9 +- gl/m4/inttypes_h.m4 | 5 +- gl/m4/iswblank.m4 | 39 + gl/m4/iswctype.m4 | 14 + gl/m4/iswdigit.m4 | 121 +++ gl/m4/iswpunct.m4 | 49 + gl/m4/iswxdigit.m4 | 111 +++ gl/m4/langinfo_h.m4 | 5 +- gl/m4/largefile.m4 | 229 +++-- gl/m4/limits-h.m4 | 31 +- gl/m4/localcharset.m4 | 5 +- gl/m4/locale-fr.m4 | 142 ++- gl/m4/locale-ja.m4 | 17 +- gl/m4/locale-zh.m4 | 15 +- gl/m4/locale_h.m4 | 11 +- gl/m4/localeconv.m4 | 42 +- gl/m4/lock.m4 | 5 +- gl/m4/lseek.m4 | 45 +- gl/m4/malloc.m4 | 14 +- gl/m4/malloca.m4 | 5 +- gl/m4/math_h.m4 | 60 +- gl/m4/mbrtowc.m4 | 123 +-- gl/m4/mbsinit.m4 | 7 +- gl/m4/mbstate_t.m4 | 5 +- gl/m4/mbtowc.m4 | 10 +- gl/m4/memchr.m4 | 17 +- gl/m4/minmax.m4 | 5 +- gl/m4/mktime.m4 | 15 +- gl/m4/mmap-anon.m4 | 5 +- gl/m4/mode_t.m4 | 5 +- gl/m4/mountlist.m4 | 18 +- gl/m4/msvc-inval.m4 | 5 +- gl/m4/msvc-nothrow.m4 | 5 +- gl/m4/multiarch.m4 | 5 +- gl/m4/musl.m4 | 21 + gl/m4/netdb_h.m4 | 5 +- gl/m4/netinet_in_h.m4 | 5 +- gl/m4/nl_langinfo.m4 | 12 +- gl/m4/nocrash.m4 | 5 +- gl/m4/off_t.m4 | 5 +- gl/m4/open-cloexec.m4 | 8 +- gl/m4/open-slash.m4 | 5 +- gl/m4/open.m4 | 7 +- gl/m4/pathmax.m4 | 5 +- gl/m4/pid_t.m4 | 5 +- gl/m4/printf.m4 | 931 ++++++++++++++----- gl/m4/pthread_rwlock_rdlock.m4 | 43 +- gl/m4/realloc.m4 | 12 +- gl/m4/reallocarray.m4 | 10 +- gl/m4/regex.m4 | 23 +- gl/m4/servent.m4 | 9 +- gl/m4/setenv.m4 | 20 +- gl/m4/setlocale_null.m4 | 46 +- gl/m4/sha256.m4 | 5 +- gl/m4/size_max.m4 | 5 +- gl/m4/snprintf.m4 | 5 +- gl/m4/socketlib.m4 | 19 +- gl/m4/sockets.m4 | 5 +- gl/m4/socklen.m4 | 5 +- gl/m4/sockpfaf.m4 | 5 +- gl/m4/ssize_t.m4 | 31 +- gl/m4/stat-time.m4 | 14 +- gl/m4/stat.m4 | 23 +- gl/m4/std-gnu11.m4 | 5 +- gl/m4/stdalign.m4 | 202 ++-- gl/m4/stddef_h.m4 | 20 +- gl/m4/stdint.m4 | 18 +- gl/m4/stdint_h.m4 | 5 +- gl/m4/stdio_h.m4 | 39 +- gl/m4/stdlib_h.m4 | 72 +- gl/m4/strcase.m4 | 5 +- gl/m4/strcasestr.m4 | 5 +- gl/m4/strerror.m4 | 33 +- gl/m4/string_h.m4 | 18 +- gl/m4/strings_h.m4 | 11 +- gl/m4/strsep.m4 | 5 +- gl/m4/strstr.m4 | 5 +- gl/m4/sys_socket_h.m4 | 5 +- gl/m4/sys_stat_h.m4 | 5 +- gl/m4/sys_types_h.m4 | 5 +- gl/m4/sys_uio_h.m4 | 5 +- gl/m4/threadlib.m4 | 63 +- gl/m4/time_h.m4 | 48 +- gl/m4/time_r.m4 | 12 +- gl/m4/timegm.m4 | 11 +- gl/m4/ungetc.m4 | 25 +- gl/m4/unistd_h.m4 | 11 +- gl/m4/unlocked-io.m4 | 13 +- gl/m4/vararrays.m4 | 14 +- gl/m4/vasnprintf.m4 | 207 ++++- gl/m4/vasprintf.m4 | 5 +- gl/m4/visibility.m4 | 13 +- gl/m4/vsnprintf.m4 | 5 +- gl/m4/warn-on-use.m4 | 9 +- gl/m4/wchar_h.m4 | 25 +- gl/m4/wchar_t.m4 | 5 +- gl/m4/wcrtomb.m4 | 23 +- gl/m4/wctype.m4 | 52 ++ gl/m4/wctype_h.m4 | 9 +- gl/m4/wint_t.m4 | 5 +- gl/m4/xalloc.m4 | 5 +- gl/m4/xsize.m4 | 5 +- gl/m4/zzgnulib.m4 | 5 +- gl/malloc.c | 2 +- gl/malloc/dynarray-skeleton.c | 2 +- gl/malloc/dynarray.h | 2 +- gl/malloc/dynarray_at_failure.c | 2 +- gl/malloc/dynarray_emplace_enlarge.c | 6 +- gl/malloc/dynarray_finalize.c | 2 +- gl/malloc/dynarray_resize.c | 6 +- gl/malloc/dynarray_resize_clear.c | 2 +- gl/malloca.c | 41 +- gl/malloca.h | 35 +- gl/math.c | 4 +- gl/math.in.h | 404 +++++++- gl/mbrtowc-impl-utf8.h | 2 +- gl/mbrtowc-impl.h | 2 +- gl/mbrtowc.c | 8 +- gl/mbsinit.c | 4 +- gl/mbszero.c | 23 + gl/mbtowc-impl.h | 4 +- gl/mbtowc-lock.c | 19 +- gl/mbtowc-lock.h | 6 +- gl/mbtowc.c | 2 +- gl/memchr.c | 2 +- gl/memchr.valgrind | 2 +- gl/minmax.h | 7 +- gl/mktime-internal.h | 2 +- gl/mktime.c | 13 +- gl/mountlist.c | 21 +- gl/mountlist.h | 21 +- gl/msvc-inval.c | 2 +- gl/msvc-inval.h | 7 +- gl/msvc-nothrow.c | 2 +- gl/msvc-nothrow.h | 15 +- gl/netdb.in.h | 7 +- gl/netinet_in.in.h | 2 +- gl/nl_langinfo-lock.c | 19 +- gl/nl_langinfo.c | 23 +- gl/open.c | 8 +- gl/pathmax.h | 7 +- gl/printf-args.c | 125 ++- gl/printf-args.h | 61 +- gl/printf-parse.c | 502 +++++----- gl/printf-parse.h | 10 +- gl/realloc.c | 2 +- gl/reallocarray.c | 2 +- gl/regcomp.c | 4 +- gl/regex.c | 6 +- gl/regex.h | 2 +- gl/regex_internal.c | 2 +- gl/regex_internal.h | 8 +- gl/regexec.c | 4 +- gl/setenv.c | 8 +- gl/setlocale-lock.c | 19 +- gl/setlocale_null-unlocked.c | 149 +++ gl/setlocale_null.c | 176 +--- gl/setlocale_null.h | 30 +- gl/sha256-stream.c | 2 +- gl/sha256.c | 2 +- gl/sha256.h | 23 +- gl/size_max.h | 7 +- gl/snprintf.c | 2 +- gl/sockets.c | 2 +- gl/sockets.h | 16 +- gl/stat-time.c | 2 +- gl/stat-time.h | 60 +- gl/stat-w32.c | 2 +- gl/stat-w32.h | 2 +- gl/stat.c | 2 +- gl/stdalign.in.h | 137 --- gl/stdckdint.in.h | 2 +- gl/stddef.in.h | 78 +- gl/stdint.in.h | 4 +- gl/stdio-impl.h | 2 +- gl/stdio-read.c | 2 +- gl/stdio-write.c | 2 +- gl/stdio.in.h | 172 +++- gl/stdlib.in.h | 374 +++++++- gl/str-two-way.h | 2 +- gl/strcasecmp.c | 8 +- gl/strcasestr.c | 10 +- gl/streq.h | 12 +- gl/strerror-override.c | 2 +- gl/strerror-override.h | 73 +- gl/strerror.c | 2 +- gl/string.in.h | 200 +++- gl/strings.in.h | 7 +- gl/stripslash.c | 2 +- gl/strncasecmp.c | 8 +- gl/strsep.c | 2 +- gl/strstr.c | 2 +- gl/sys-limits.h | 2 +- gl/sys_socket.c | 4 +- gl/sys_socket.in.h | 15 +- gl/sys_stat.in.h | 50 +- gl/sys_types.in.h | 9 +- gl/sys_uio.in.h | 2 +- gl/time.in.h | 142 ++- gl/time_r.c | 7 +- gl/timegm.c | 2 +- gl/unistd.c | 4 +- gl/unistd.in.h | 140 ++- gl/unlocked-io.h | 9 +- gl/unsetenv.c | 2 +- gl/vasnprintf.c | 1682 +++++++++++++++++++++++++++++----- gl/vasnprintf.h | 7 +- gl/vasprintf.c | 2 +- gl/verify.h | 65 +- gl/vsnprintf.c | 2 +- gl/w32sock.h | 2 +- gl/warn-on-use.h | 6 +- gl/wchar.in.h | 376 +++++++- gl/wcrtomb.c | 4 +- gl/wctype-h.c | 4 +- gl/wctype-impl.h | 96 ++ gl/wctype.c | 25 + gl/wctype.in.h | 93 +- gl/windows-initguard.h | 2 +- gl/windows-mutex.c | 2 +- gl/windows-mutex.h | 2 +- gl/windows-once.c | 2 +- gl/windows-once.h | 2 +- gl/windows-recmutex.c | 2 +- gl/windows-recmutex.h | 2 +- gl/windows-rwlock.c | 2 +- gl/windows-rwlock.h | 2 +- gl/xalloc-die.c | 4 +- gl/xalloc-oversized.h | 13 +- gl/xalloc.h | 14 +- gl/xmalloc.c | 16 +- gl/xsize.c | 2 +- gl/xsize.h | 20 +- 403 files changed, 9657 insertions(+), 2895 deletions(-) Diff: https://www.monitoring-plugins.org/repositories/monitoring-plugins/diff/?id=5be04ec From git at monitoring-plugins.org Wed Nov 6 09:30:12 2024 From: git at monitoring-plugins.org (GitHub) Date: Wed, 6 Nov 2024 09:30:12 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2037 from ... Message-ID: <20241106083012.3EEC92000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 9b4df9e50837cc837e113053ba12ee6967d5e6c2 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Wed Nov 6 09:24:23 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=9b4df9e Merge pull request #2037 from RincewindsHat/update/gnulib-1.0 Sync with the latest Gnulib code (d4ec02b3cc) (gnulib v1.0) --- From git at monitoring-plugins.org Thu Nov 7 10:00:12 2024 From: git at monitoring-plugins.org (William) Date: Thu, 7 Nov 2024 10:00:12 +0100 (CET) Subject: [monitoring-plugins] Add dontfrag/random for fping Message-ID: <20241107090012.BED3A2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 88d991773b6d8ac416ad2931ea8debc949555c7a Author: William Date: Wed Nov 6 14:00:23 2024 +1000 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=88d9917 Add dontfrag/random for fping Support the dont fragment and randomise packet data options for check_fping --- plugins/check_fping.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 49235e2..67fa236 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -60,6 +60,8 @@ static int packet_count = PACKET_COUNT; static int target_timeout = 0; static int packet_interval = 0; static bool verbose = false; +static bool dontfrag = false; +static bool randomize_packet_data = false; static int cpl; static int wpl; static double crta; @@ -103,6 +105,11 @@ int main(int argc, char **argv) { xasprintf(&option_string, "%s-S %s ", option_string, sourceip); if (sourceif) xasprintf(&option_string, "%s-I %s ", option_string, sourceif); + if (dontfrag) + xasprintf(&option_string, "%s-M ", option_string); + if (randomize_packet_data) + xasprintf(&option_string, "%s-R ", option_string); + #ifdef PATH_TO_FPING6 if (address_family != AF_INET && is_inet6_addr(server)) @@ -279,6 +286,8 @@ int process_arguments(int argc, char **argv) { {"help", no_argument, 0, 'h'}, {"use-ipv4", no_argument, 0, '4'}, {"use-ipv6", no_argument, 0, '6'}, + {"dontfrag", no_argument, 0, 'M'}, + {"random", no_argument, 0, 'R'}, {0, 0, 0, 0}}; rv[PL] = NULL; @@ -390,6 +399,12 @@ int process_arguments(int argc, char **argv) { else usage(_("Interval must be a positive integer")); break; + case 'R': + randomize_packet_data = true; + break; + case 'M': + dontfrag = true; + break; } } @@ -470,6 +485,10 @@ void print_help(void) { printf(" %s\n", _("name or IP Address of sourceip")); printf(" %s\n", "-I, --sourceif=IF"); printf(" %s\n", _("source interface name")); + printf(" %s\n", "-M, --dontfrag"); + printf(" %s\n", _("set the Don't Fragment flag")); + printf(" %s\n", "-R, --random"); + printf(" %s\n", _("random packet data (to foil link data compression)")); printf(UT_VERBOSE); printf("\n"); printf(" %s\n", _("THRESHOLD is ,%% where is the round trip average travel time (ms)")); From git at monitoring-plugins.org Thu Nov 7 10:00:12 2024 From: git at monitoring-plugins.org (GitHub) Date: Thu, 7 Nov 2024 10:00:12 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2041 from ... Message-ID: <20241107090012.CD8742000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: cace8759c98a1d861c4318afa1d207d869d02646 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Thu Nov 7 09:52:13 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=cace875 Merge pull request #2041 from Firstyear/20241006-fping-dont-frag Add dontfrag / random to fping check --- From git at monitoring-plugins.org Thu Nov 7 11:00:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Thu, 7 Nov 2024 11:00:12 +0100 (CET) Subject: [monitoring-plugins] tap: clang-format Message-ID: <20241107100012.95C2B2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 00cbf8bcca9d047eead535ebd5bc986365b04426 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Thu Oct 31 15:24:53 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=00cbf8b tap: clang-format --- tap/tap.c | 140 +++++++++++++-------------------- tap/tap.h | 60 +++++++------- tap/tests/diag/test.c | 4 +- tap/tests/fail/test.c | 4 +- tap/tests/ok/ok-hash/test.c | 8 +- tap/tests/ok/ok-numeric/test.c | 4 +- tap/tests/ok/ok/test.c | 4 +- tap/tests/pass/test.c | 4 +- tap/tests/plan/no-tests/test.c | 4 +- tap/tests/plan/no_plan/test.c | 4 +- tap/tests/plan/not-enough-tests/test.c | 4 +- tap/tests/plan/sane/test.c | 4 +- tap/tests/plan/skip_all/test.c | 4 +- tap/tests/plan/too-many-plans/test.c | 4 +- tap/tests/plan/too-many-tests/test.c | 4 +- tap/tests/skip/test.c | 12 ++- tap/tests/todo/test.c | 6 +- 17 files changed, 103 insertions(+), 171 deletions(-) diff --git a/tap/tap.c b/tap/tap.c index 97c20e9..00ceab2 100644 --- a/tap/tap.c +++ b/tap/tap.c @@ -35,8 +35,8 @@ static int no_plan = 0; static int skip_all = 0; static int have_plan = 0; static unsigned int test_count = 0; /* Number of tests that have been run */ -static unsigned int e_tests = 0; /* Expected number of tests to run */ -static unsigned int failures = 0; /* Number of tests that failed */ +static unsigned int e_tests = 0; /* Expected number of tests to run */ +static unsigned int failures = 0; /* Number of tests that failed */ static char *todo_msg = NULL; static char *todo_msg_fixed = "libtap malloc issue"; static int todo = 0; @@ -45,13 +45,13 @@ static int test_died = 0; /* Encapsulate the pthread code in a conditional. In the absence of libpthread the code does nothing */ #ifdef HAVE_LIBPTHREAD -#include +# include static pthread_mutex_t M = PTHREAD_MUTEX_INITIALIZER; -# define LOCK pthread_mutex_lock(&M); -# define UNLOCK pthread_mutex_unlock(&M); +# define LOCK pthread_mutex_lock(&M); +# define UNLOCK pthread_mutex_unlock(&M); #else -# define LOCK -# define UNLOCK +# define LOCK +# define UNLOCK #endif static void _expected_tests(unsigned int); @@ -65,10 +65,7 @@ static void _cleanup(void); * test_name -- the name of the test, may be NULL * test_comment -- a comment to print afterwards, may be NULL */ -unsigned int -_gen_result(int ok, const char *func, char *file, unsigned int line, - char *test_name, ...) -{ +unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line, char *test_name, ...) { va_list ap; char *local_test_name = NULL; char *c; @@ -80,7 +77,7 @@ _gen_result(int ok, const char *func, char *file, unsigned int line, /* Start by taking the test name and performing any printf() expansions on it */ - if(test_name != NULL) { + if (test_name != NULL) { va_start(ap, test_name); vasprintf(&local_test_name, test_name, ap); va_end(ap); @@ -88,43 +85,43 @@ _gen_result(int ok, const char *func, char *file, unsigned int line, /* Make sure the test name contains more than digits and spaces. Emit an error message and exit if it does */ - if(local_test_name) { + if (local_test_name) { name_is_digits = 1; - for(c = local_test_name; *c != '\0'; c++) { - if(!isdigit(*c) && !isspace(*c)) { + for (c = local_test_name; *c != '\0'; c++) { + if (!isdigit(*c) && !isspace(*c)) { name_is_digits = 0; break; } } - if(name_is_digits) { + if (name_is_digits) { diag(" You named your test '%s'. You shouldn't use numbers for your test names.", local_test_name); diag(" Very confusing."); } } } - if(!ok) { + if (!ok) { printf("not "); failures++; } printf("ok %d", test_count); - if(test_name != NULL) { + if (test_name != NULL) { printf(" - "); /* Print the test name, escaping any '#' characters it might contain */ - if(local_test_name != NULL) { + if (local_test_name != NULL) { flockfile(stdout); - for(c = local_test_name; *c != '\0'; c++) { - if(*c == '#') + for (c = local_test_name; *c != '\0'; c++) { + if (*c == '#') fputc('\\', stdout); fputc((int)*c, stdout); } funlockfile(stdout); - } else { /* vasprintf() failed, use a fixed message */ + } else { /* vasprintf() failed, use a fixed message */ printf("%s", todo_msg_fixed); } } @@ -136,17 +133,16 @@ _gen_result(int ok, const char *func, char *file, unsigned int line, This is not counted as a failure, so decrement the counter if the test failed. */ - if(todo) { + if (todo) { printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed); - if(!ok) + if (!ok) failures--; } printf("\n"); - if(!ok) - diag(" Failed %stest (%s:%s() at line %d)", - todo ? "(TODO) " : "", file, func, line); + if (!ok) + diag(" Failed %stest (%s:%s() at line %d)", todo ? "(TODO) " : "", file, func, line); free(local_test_name); @@ -161,18 +157,16 @@ _gen_result(int ok, const char *func, char *file, unsigned int line, * Initialise the TAP library. Will only do so once, however many times it's * called. */ -void -_tap_init(void) -{ +void _tap_init(void) { static int run_once = 0; LOCK; - if(!run_once) { + if (!run_once) { atexit(_cleanup); /* stdout needs to be unbuffered so that the output appears - in the same place relative to stderr output as it does + in the same place relative to stderr output as it does with Test::Harness */ setbuf(stdout, 0); run_once = 1; @@ -184,15 +178,13 @@ _tap_init(void) /* * Note that there's no plan. */ -int -plan_no_plan(void) -{ +int plan_no_plan(void) { LOCK; _tap_init(); - if(have_plan != 0) { + if (have_plan != 0) { fprintf(stderr, "You tried to plan twice!\n"); test_died = 1; UNLOCK; @@ -210,9 +202,7 @@ plan_no_plan(void) /* * Note that the plan is to skip all tests */ -int -plan_skip_all(char *reason) -{ +int plan_skip_all(char *reason) { LOCK; @@ -222,7 +212,7 @@ plan_skip_all(char *reason) printf("1..0"); - if(reason != NULL) + if (reason != NULL) printf(" # Skip %s", reason); printf("\n"); @@ -235,22 +225,20 @@ plan_skip_all(char *reason) /* * Note the number of tests that will be run. */ -int -plan_tests(unsigned int tests) -{ +int plan_tests(unsigned int tests) { LOCK; _tap_init(); - if(have_plan != 0) { + if (have_plan != 0) { fprintf(stderr, "You tried to plan twice!\n"); test_died = 1; UNLOCK; exit(255); } - if(tests == 0) { + if (tests == 0) { fprintf(stderr, "You said to run 0 tests! You've got to run something.\n"); test_died = 1; UNLOCK; @@ -266,9 +254,7 @@ plan_tests(unsigned int tests) return 0; } -unsigned int -diag(char *fmt, ...) -{ +unsigned int diag(char *fmt, ...) { va_list ap; LOCK; @@ -286,9 +272,7 @@ diag(char *fmt, ...) return 0; } -void -_expected_tests(unsigned int tests) -{ +void _expected_tests(unsigned int tests) { LOCK; @@ -298,9 +282,7 @@ _expected_tests(unsigned int tests) UNLOCK; } -int -skip(unsigned int n, char *fmt, ...) -{ +int skip(unsigned int n, char *fmt, ...) { va_list ap; char *skip_msg; @@ -310,11 +292,9 @@ skip(unsigned int n, char *fmt, ...) asprintf(&skip_msg, fmt, ap); va_end(ap); - while(n-- > 0) { + while (n-- > 0) { test_count++; - printf("ok %d # skip %s\n", test_count, - skip_msg != NULL ? - skip_msg : "libtap():malloc() failed"); + printf("ok %d # skip %s\n", test_count, skip_msg != NULL ? skip_msg : "libtap():malloc() failed"); } free(skip_msg); @@ -324,9 +304,7 @@ skip(unsigned int n, char *fmt, ...) return 1; } -void -todo_start(char *fmt, ...) -{ +void todo_start(char *fmt, ...) { va_list ap; LOCK; @@ -340,9 +318,7 @@ todo_start(char *fmt, ...) UNLOCK; } -void -todo_end(void) -{ +void todo_end(void) { LOCK; @@ -352,28 +328,26 @@ todo_end(void) UNLOCK; } -int -exit_status(void) -{ +int exit_status(void) { int r; LOCK; /* If there's no plan, just return the number of failures */ - if(no_plan || !have_plan) { + if (no_plan || !have_plan) { UNLOCK; return failures; } /* Ran too many tests? Return the number of tests that were run that shouldn't have been */ - if(e_tests < test_count) { + if (e_tests < test_count) { r = test_count - e_tests; UNLOCK; return r; } - /* Return the number of tests that failed + the number of tests + /* Return the number of tests that failed + the number of tests that weren't run */ r = failures + e_tests - test_count; UNLOCK; @@ -385,51 +359,45 @@ exit_status(void) * Cleanup at the end of the run, produce any final output that might be * required. */ -void -_cleanup(void) -{ +void _cleanup(void) { LOCK; /* If plan_no_plan() wasn't called, and we don't have a plan, and we're not skipping everything, then something happened before we could produce any output */ - if(!no_plan && !have_plan && !skip_all) { + if (!no_plan && !have_plan && !skip_all) { diag("Looks like your test died before it could output anything."); UNLOCK; return; } - if(test_died) { + if (test_died) { diag("Looks like your test died just after %d.", test_count); UNLOCK; return; } - /* No plan provided, but now we know how many tests were run, and can print the header at the end */ - if(!skip_all && (no_plan || !have_plan)) { + if (!skip_all && (no_plan || !have_plan)) { printf("1..%d\n", test_count); } - if((have_plan && !no_plan) && e_tests < test_count) { - diag("Looks like you planned %d tests but ran %d extra.", - e_tests, test_count - e_tests); + if ((have_plan && !no_plan) && e_tests < test_count) { + diag("Looks like you planned %d tests but ran %d extra.", e_tests, test_count - e_tests); UNLOCK; return; } - if((have_plan || !no_plan) && e_tests > test_count) { - diag("Looks like you planned %d tests but only ran %d.", - e_tests, test_count); + if ((have_plan || !no_plan) && e_tests > test_count) { + diag("Looks like you planned %d tests but only ran %d.", e_tests, test_count); UNLOCK; return; } - if(failures) - diag("Looks like you failed %d tests of %d.", - failures, test_count); + if (failures) + diag("Looks like you failed %d tests of %d.", failures, test_count); UNLOCK; } diff --git a/tap/tap.h b/tap/tap.h index 8ee525c..5abbd76 100644 --- a/tap/tap.h +++ b/tap/tap.h @@ -28,52 +28,46 @@ and requires the caller to add the final comma if they've omitted the optional arguments */ #ifdef __GNUC__ -# define ok(e, test, ...) ((e) ? \ - _gen_result(1, __func__, __FILE__, __LINE__, \ - test, ## __VA_ARGS__) : \ - _gen_result(0, __func__, __FILE__, __LINE__, \ - test, ## __VA_ARGS__)) +# define ok(e, test, ...) \ + ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__) \ + : _gen_result(0, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__)) -# define ok1(e) ((e) ? \ - _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \ - _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) +# define ok1(e) ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) -# define pass(test, ...) ok(1, test, ## __VA_ARGS__); -# define fail(test, ...) ok(0, test, ## __VA_ARGS__); +# define pass(test, ...) ok(1, test, ##__VA_ARGS__); +# define fail(test, ...) ok(0, test, ##__VA_ARGS__); -# define skip_start(test, n, fmt, ...) \ - do { \ - if((test)) { \ - skip(n, fmt, ## __VA_ARGS__); \ - continue; \ - } +# define skip_start(test, n, fmt, ...) \ + do { \ + if ((test)) { \ + skip(n, fmt, ##__VA_ARGS__); \ + continue; \ + } #else /* __GNUC__ */ /* The original tap.h used to test if __STDC_VERSION__ >= 199901L here. This * doesn't seem to work on HP-UX even though the code compile fine. I'm not * sure how to add an exception here for HP-UX so I just removed the check * for now */ -# define ok(e, ...) ((e) ? \ - _gen_result(1, __func__, __FILE__, __LINE__, \ - __VA_ARGS__) : \ - _gen_result(0, __func__, __FILE__, __LINE__, \ - __VA_ARGS__)) +# define ok(e, ...) \ + ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, __VA_ARGS__) : _gen_result(0, __func__, __FILE__, __LINE__, __VA_ARGS__)) -# define ok1(e) ((e) ? \ - _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \ - _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) +# define ok1(e) ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) -# define pass(...) ok(1, __VA_ARGS__); -# define fail(...) ok(0, __VA_ARGS__); +# define pass(...) ok(1, __VA_ARGS__); +# define fail(...) ok(0, __VA_ARGS__); -# define skip_start(test, n, ...) \ - do { \ - if((test)) { \ - skip(n, __VA_ARGS__); \ - continue; \ - } +# define skip_start(test, n, ...) \ + do { \ + if ((test)) { \ + skip(n, __VA_ARGS__); \ + continue; \ + } #endif /* __GNUC__ */ -# define skip_end } while(0); +#define skip_end \ + } \ + while (0) \ + ; unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...); diff --git a/tap/tests/diag/test.c b/tap/tests/diag/test.c index 401db64..b0a5a4f 100644 --- a/tap/tests/diag/test.c +++ b/tap/tests/diag/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; plan_tests(2); diff --git a/tap/tests/fail/test.c b/tap/tests/fail/test.c index 621b6c2..18e1695 100644 --- a/tap/tests/fail/test.c +++ b/tap/tests/fail/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(2); diff --git a/tap/tests/ok/ok-hash/test.c b/tap/tests/ok/ok-hash/test.c index 16be137..82f65b0 100644 --- a/tap/tests/ok/ok-hash/test.c +++ b/tap/tests/ok/ok-hash/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(4); @@ -42,11 +40,11 @@ main(int argc, char *argv[]) rc = ok(1, "Test with one # hash"); diag("Returned: %d", rc); - rc = ok(1, "Test with # two # hashes"); + rc = ok(1, "Test with # two # hashes"); diag("Returned: %d", rc); rc = ok(1, "Test with ## back to back hashes"); diag("Returned: %d", rc); - + return exit_status(); } diff --git a/tap/tests/ok/ok-numeric/test.c b/tap/tests/ok/ok-numeric/test.c index 0e33a74..46113f4 100644 --- a/tap/tests/ok/ok-numeric/test.c +++ b/tap/tests/ok/ok-numeric/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(3); diff --git a/tap/tests/ok/ok/test.c b/tap/tests/ok/ok/test.c index ae04f2e..8ef0bcd 100644 --- a/tap/tests/ok/ok/test.c +++ b/tap/tests/ok/ok/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(5); diff --git a/tap/tests/pass/test.c b/tap/tests/pass/test.c index 39d8a7c..73df20c 100644 --- a/tap/tests/pass/test.c +++ b/tap/tests/pass/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(2); diff --git a/tap/tests/plan/no-tests/test.c b/tap/tests/plan/no-tests/test.c index 78c5d37..f70ec8d 100644 --- a/tap/tests/plan/no-tests/test.c +++ b/tap/tests/plan/no-tests/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(0); diff --git a/tap/tests/plan/no_plan/test.c b/tap/tests/plan/no_plan/test.c index 5cffbdc..4c25d5f 100644 --- a/tap/tests/plan/no_plan/test.c +++ b/tap/tests/plan/no_plan/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_no_plan(); diff --git a/tap/tests/plan/not-enough-tests/test.c b/tap/tests/plan/not-enough-tests/test.c index a9ec64f..eacc07e 100644 --- a/tap/tests/plan/not-enough-tests/test.c +++ b/tap/tests/plan/not-enough-tests/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(1); diff --git a/tap/tests/plan/sane/test.c b/tap/tests/plan/sane/test.c index 0843d3a..17bf8d1 100644 --- a/tap/tests/plan/sane/test.c +++ b/tap/tests/plan/sane/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(1); diff --git a/tap/tests/plan/skip_all/test.c b/tap/tests/plan/skip_all/test.c index 31722da..4e37e1a 100644 --- a/tap/tests/plan/skip_all/test.c +++ b/tap/tests/plan/skip_all/test.c @@ -26,9 +26,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_skip_all("No good reason"); diff --git a/tap/tests/plan/too-many-plans/test.c b/tap/tests/plan/too-many-plans/test.c index b189cb7..5f45bc4 100644 --- a/tap/tests/plan/too-many-plans/test.c +++ b/tap/tests/plan/too-many-plans/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(1); diff --git a/tap/tests/plan/too-many-tests/test.c b/tap/tests/plan/too-many-tests/test.c index 0f72410..0b2ee16 100644 --- a/tap/tests/plan/too-many-tests/test.c +++ b/tap/tests/plan/too-many-tests/test.c @@ -28,9 +28,7 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; rc = plan_tests(5); diff --git a/tap/tests/skip/test.c b/tap/tests/skip/test.c index d8f3eaf..789812e 100644 --- a/tap/tests/skip/test.c +++ b/tap/tests/skip/test.c @@ -28,29 +28,27 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; unsigned int side_effect = 0; rc = plan_tests(4); diag("Returned: %d", rc); - rc = ok(1 == 1, "1 equals 1"); /* Should always work */ + rc = ok(1 == 1, "1 equals 1"); /* Should always work */ diag("Returned: %d", rc); do { - if(1) { + if (1) { rc = skip(1, "Testing skipping"); continue; } - + side_effect++; ok(side_effect == 1, "side_effect checked out"); - } while(0); + } while (0); diag("Returned: %d", rc); diff --git a/tap/tests/todo/test.c b/tap/tests/todo/test.c index ac6339a..0cd2fb3 100644 --- a/tap/tests/todo/test.c +++ b/tap/tests/todo/test.c @@ -28,16 +28,14 @@ #include "tap.h" -int -main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { unsigned int rc = 0; unsigned int side_effect = 0; rc = plan_tests(5); diag("Returned: %d", rc); - rc = ok(1 == 1, "1 equals 1"); /* Should always work */ + rc = ok(1 == 1, "1 equals 1"); /* Should always work */ diag("Returned: %d", rc); todo_start("For testing purposes"); From git at monitoring-plugins.org Thu Nov 7 11:00:12 2024 From: git at monitoring-plugins.org (GitHub) Date: Thu, 7 Nov 2024 11:00:12 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2036 from ... Message-ID: <20241107100012.A47122000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: b47b5b6fa06ac7ac6f284c7278890f3820100dd8 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Thu Nov 7 10:58:44 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b47b5b6 Merge pull request #2036 from RincewindsHat/cleanup/tap tap: clang-format --- From git at monitoring-plugins.org Fri Nov 8 09:40:12 2024 From: git at monitoring-plugins.org (William) Date: Fri, 8 Nov 2024 09:40:12 +0100 (CET) Subject: [monitoring-plugins] Add missed changes for dontfrag Message-ID: <20241108084012.8E51F2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: d5ed947e312bcb8f0c4e46c4ea9f39918387efc3 Author: William Date: Fri Nov 8 14:07:29 2024 +1000 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=d5ed947 Add missed changes for dontfrag Due to a mistake with git the command line args were not properly updated. --- plugins/check_fping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 67fa236..c1d03ec 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -7,7 +7,7 @@ * * Description: * - * This file contains the check_disk plugin + * This file contains the check_fping plugin * * This plugin will use the fping command to ping the specified host for a * fast check @@ -304,7 +304,7 @@ int process_arguments(int argc, char **argv) { } while (1) { - c = getopt_long(argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:46", longopts, &option); + c = getopt_long(argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:M:R:46", longopts, &option); if (c == -1 || c == EOF || c == 1) break; From git at monitoring-plugins.org Fri Nov 8 09:40:12 2024 From: git at monitoring-plugins.org (GitHub) Date: Fri, 8 Nov 2024 09:40:12 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2042 from ... Message-ID: <20241108084012.9D6BF2000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 9cd8294e99586fcbc4344b8e287886bd9788f969 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Fri Nov 8 09:33:00 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=9cd8294 Merge pull request #2042 from Firstyear/20241108-fping-missed-changes Add missed changes for dontfrag --- From git at monitoring-plugins.org Fri Nov 8 14:00:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 14:00:12 +0100 (CET) Subject: [monitoring-plugins] Fix RPM build tests Message-ID: <20241108130012.7D1422000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: e5a825de740ce78d99a1f47118c76b756bf32554 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 13:46:35 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=e5a825d Fix RPM build tests --- .github/mock.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/mock.sh b/.github/mock.sh index 87543ce..ea4f7f3 100755 --- a/.github/mock.sh +++ b/.github/mock.sh @@ -52,13 +52,16 @@ if command -v git > /dev/null 2>&1; then fi mkdir -p "${SRCRPM_DIR}" "${RPM_DIR}" -#rpmbuild --undefine=_disable_source_fetch --define "_sourcedir ${SOURCE_DIR}" -ba ${SPEC_FILE} + +# Run mock below +# No idea what happens here to be honest +# mock seems to run more containers to build the package dnf -y --setopt="tsflags=nodocs" install rpmdevtools && \ spectool -g -C ${SOURCE_DIR} ${SPEC_FILE} && \ - { mock --dnf --clean --spec ${SPEC_FILE} --sources=${SOURCE_DIR} --result=${SRCRPM_DIR} --build || \ - { cat ${SRCRPM_DIR}/{root,build}.log; exit 1; } } - -mock --dnf --clean --sources=${SOURCE_DIR} --result=${RPM_DIR} --rebuild "${SRCRPM_DIR}"/${SRC_RPM} || \ - { cat ${RPM_DIR}/{root,build}.log; exit 1; } + mock --init && \ + { mock --no-clean --spec ${SPEC_FILE} --sources=${SOURCE_DIR} --result=${SRCRPM_DIR} --build || \ + { cat ${SRCRPM_DIR}/{root,build}.log; exit 1; } } && \ + { mock --no-clean --sources=${SOURCE_DIR} --result=${RPM_DIR} --rebuild "${SRCRPM_DIR}"/${SRC_RPM} || \ + { cat ${RPM_DIR}/{root,build}.log; exit 1; } } ls -la ${SOURCE_DIR} ${SRCRPM_DIR} ${RPM_DIR} From git at monitoring-plugins.org Fri Nov 8 14:00:12 2024 From: git at monitoring-plugins.org (GitHub) Date: Fri, 8 Nov 2024 14:00:12 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2044 from ... Message-ID: <20241108130012.897152000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 14aad851bc467baf89b5c181ac8ffcb4b42bb7bb Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Fri Nov 8 13:55:13 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=14aad85 Merge pull request #2044 from RincewindsHat/fix/fedora-rpm-build Fix RPM build tests --- From git at monitoring-plugins.org Fri Nov 8 23:00:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:00:12 +0100 (CET) Subject: [monitoring-plugins] check_apt: clang-format Message-ID: <20241108220012.5626D2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 962053e6ab58ade05a43eb222a0308770ce89634 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 10:48:58 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=962053e check_apt: clang-format --- plugins/check_apt.c | 504 ++++++++++++++++++++++++++-------------------------- 1 file changed, 251 insertions(+), 253 deletions(-) diff --git a/plugins/check_apt.c b/plugins/check_apt.c index 5e4021b..02af1a4 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -42,14 +42,14 @@ const char *email = "devel at monitoring-plugins.org"; typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type; /* Character for hidden input file option (for testing). */ -#define INPUT_FILE_OPT CHAR_MAX+1 +#define INPUT_FILE_OPT CHAR_MAX + 1 /* the default opts can be overridden via the cmdline */ #define UPGRADE_DEFAULT_OPTS "-o 'Debug::NoLocking=true' -s -qq" -#define UPDATE_DEFAULT_OPTS "-q" +#define UPDATE_DEFAULT_OPTS "-q" /* until i commit the configure.in patch which gets this, i'll define * it here as well */ #ifndef PATH_TO_APTGET -# define PATH_TO_APTGET "/usr/bin/apt-get" +# define PATH_TO_APTGET "/usr/bin/apt-get" #endif /* PATH_TO_APTGET */ /* String found at the beginning of the apt output lines we're interested in */ #define PKGINST_PREFIX "Inst " @@ -62,91 +62,84 @@ void print_help(void); void print_usage(void); /* construct the appropriate apt-get cmdline */ -char* construct_cmdline(upgrade_type u, const char *opts); +char *construct_cmdline(upgrade_type u, const char *opts); /* run an apt-get update */ int run_update(void); /* run an apt-get upgrade */ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist); /* add another clause to a regexp */ -char* add_to_regexp(char *expr, const char *next); +char *add_to_regexp(char *expr, const char *next); /* extract package name from Inst line */ -char* pkg_name(char *line); +char *pkg_name(char *line); /* string comparison function for qsort */ int cmpstringp(const void *p1, const void *p2); /* configuration variables */ -static int verbose = 0; /* -v */ -static bool list = false; /* list packages available for upgrade */ -static bool do_update = false; /* whether to call apt-get update */ -static bool only_critical = false; /* whether to warn about non-critical updates */ +static int verbose = 0; /* -v */ +static bool list = false; /* list packages available for upgrade */ +static bool do_update = false; /* whether to call apt-get update */ +static bool only_critical = false; /* whether to warn about non-critical updates */ static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */ -static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ -static char *update_opts = NULL; /* options to override defaults for update */ -static char *do_include = NULL; /* regexp to only include certain packages */ -static char *do_exclude = NULL; /* regexp to only exclude certain packages */ -static char *do_critical = NULL; /* regexp specifying critical packages */ -static char *input_filename = NULL; /* input filename for testing */ +static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ +static char *update_opts = NULL; /* options to override defaults for update */ +static char *do_include = NULL; /* regexp to only include certain packages */ +static char *do_exclude = NULL; /* regexp to only exclude certain packages */ +static char *do_critical = NULL; /* regexp specifying critical packages */ +static char *input_filename = NULL; /* input filename for testing */ /* number of packages available for upgrade to return WARNING status */ static int packages_warning = 1; /* other global variables */ -static int stderr_warning = 0; /* if a cmd issued output on stderr */ -static int exec_warning = 0; /* if a cmd exited non-zero */ +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; - char **packages_list=NULL, **secpackages_list=NULL; +int main(int argc, char **argv) { + int result = STATE_UNKNOWN, packages_available = 0, sec_count = 0; + char **packages_list = NULL, **secpackages_list = NULL; /* Parse extra opts if any */ - argv=np_extra_opts(&argc, argv, progname); + argv = np_extra_opts(&argc, argv, progname); if (process_arguments(argc, argv) == ERROR) usage_va(_("Could not parse arguments")); /* Set signal handling and alarm timeout */ - if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { + if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) { usage_va(_("Cannot catch SIGALRM")); } /* handle timeouts gracefully... */ - alarm (timeout_interval); + alarm(timeout_interval); /* if they want to run apt-get update first... */ - if(do_update) result = run_update(); + if (do_update) + result = run_update(); /* apt-get upgrade */ result = max_state(result, run_upgrade(&packages_available, &sec_count, &packages_list, &secpackages_list)); - if(sec_count > 0){ + if (sec_count > 0) { result = max_state(result, STATE_CRITICAL); - } else if(packages_available >= packages_warning && only_critical == false){ + } else if (packages_available >= packages_warning && only_critical == false) { result = max_state(result, STATE_WARNING); - } else if(result > STATE_UNKNOWN){ + } else if (result > STATE_UNKNOWN) { result = STATE_UNKNOWN; } printf(_("APT %s: %d packages available for %s (%d critical updates). %s%s%s%s|available_upgrades=%d;;;0 critical_updates=%d;;;0\n"), - state_text(result), - packages_available, - (upgrade==DIST_UPGRADE)?"dist-upgrade":"upgrade", - sec_count, - (stderr_warning)?" warnings detected":"", - (stderr_warning && exec_warning)?",":"", - (exec_warning)?" errors detected":"", - (stderr_warning||exec_warning)?".":"", - packages_available, - sec_count - ); - - if(list) { - qsort(secpackages_list, sec_count, sizeof(char*), cmpstringp); - qsort(packages_list, packages_available-sec_count, sizeof(char*), cmpstringp); - - for(int i = 0; i < sec_count; i++) + state_text(result), packages_available, (upgrade == DIST_UPGRADE) ? "dist-upgrade" : "upgrade", sec_count, + (stderr_warning) ? " warnings detected" : "", (stderr_warning && exec_warning) ? "," : "", + (exec_warning) ? " errors detected" : "", (stderr_warning || exec_warning) ? "." : "", packages_available, sec_count); + + if (list) { + qsort(secpackages_list, sec_count, sizeof(char *), cmpstringp); + qsort(packages_list, packages_available - sec_count, sizeof(char *), cmpstringp); + + for (int i = 0; i < sec_count; i++) printf("%s (security)\n", secpackages_list[i]); if (only_critical == false) { - for(int i = 0; i < packages_available - sec_count; i++) + for (int i = 0; i < packages_available - sec_count; i++) printf("%s\n", packages_list[i]); } } @@ -155,34 +148,33 @@ int main (int argc, char **argv) { } /* process command-line arguments */ -int process_arguments (int argc, char **argv) { +int process_arguments(int argc, char **argv) { int c; - static struct option longopts[] = { - {"version", no_argument, 0, 'V'}, - {"help", no_argument, 0, 'h'}, - {"verbose", no_argument, 0, 'v'}, - {"timeout", required_argument, 0, 't'}, - {"update", optional_argument, 0, 'u'}, - {"upgrade", optional_argument, 0, 'U'}, - {"no-upgrade", no_argument, 0, 'n'}, - {"dist-upgrade", optional_argument, 0, 'd'}, - {"list", no_argument, false, 'l'}, - {"include", required_argument, 0, 'i'}, - {"exclude", required_argument, 0, 'e'}, - {"critical", required_argument, 0, 'c'}, - {"only-critical", no_argument, 0, 'o'}, - {"input-file", required_argument, 0, INPUT_FILE_OPT}, - {"packages-warning", required_argument, 0, 'w'}, - {0, 0, 0, 0} - }; - - while(1) { + static struct option longopts[] = {{"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, + {"verbose", no_argument, 0, 'v'}, + {"timeout", required_argument, 0, 't'}, + {"update", optional_argument, 0, 'u'}, + {"upgrade", optional_argument, 0, 'U'}, + {"no-upgrade", no_argument, 0, 'n'}, + {"dist-upgrade", optional_argument, 0, 'd'}, + {"list", no_argument, false, 'l'}, + {"include", required_argument, 0, 'i'}, + {"exclude", required_argument, 0, 'e'}, + {"critical", required_argument, 0, 'c'}, + {"only-critical", no_argument, 0, 'o'}, + {"input-file", required_argument, 0, INPUT_FILE_OPT}, + {"packages-warning", required_argument, 0, 'w'}, + {0, 0, 0, 0}}; + + while (1) { c = getopt_long(argc, argv, "hVvt:u::U::d::nli:e:c:ow:", longopts, NULL); - if(c == -1 || c == EOF || c == 1) break; + if (c == -1 || c == EOF || c == 1) + break; - switch(c) { + switch (c) { case 'h': print_help(); exit(STATE_UNKNOWN); @@ -193,46 +185,49 @@ int process_arguments (int argc, char **argv) { verbose++; break; case 't': - timeout_interval=atoi(optarg); + timeout_interval = atoi(optarg); break; case 'd': - upgrade=DIST_UPGRADE; - if(optarg!=NULL){ - upgrade_opts=strdup(optarg); - if(upgrade_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); + upgrade = DIST_UPGRADE; + if (optarg != NULL) { + upgrade_opts = strdup(optarg); + if (upgrade_opts == NULL) + die(STATE_UNKNOWN, "strdup failed"); } break; case 'U': - upgrade=UPGRADE; - if(optarg!=NULL){ - upgrade_opts=strdup(optarg); - if(upgrade_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); + upgrade = UPGRADE; + if (optarg != NULL) { + upgrade_opts = strdup(optarg); + if (upgrade_opts == NULL) + die(STATE_UNKNOWN, "strdup failed"); } break; case 'n': - upgrade=NO_UPGRADE; + upgrade = NO_UPGRADE; break; case 'u': - do_update=true; - if(optarg!=NULL){ - update_opts=strdup(optarg); - if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); + do_update = true; + if (optarg != NULL) { + update_opts = strdup(optarg); + if (update_opts == NULL) + die(STATE_UNKNOWN, "strdup failed"); } break; case 'l': - list=true; + list = true; break; case 'i': - do_include=add_to_regexp(do_include, optarg); + do_include = add_to_regexp(do_include, optarg); break; case 'e': - do_exclude=add_to_regexp(do_exclude, optarg); + do_exclude = add_to_regexp(do_exclude, optarg); break; case 'c': - do_critical=add_to_regexp(do_critical, optarg); + do_critical = add_to_regexp(do_critical, optarg); break; case 'o': - only_critical=true; + only_critical = true; break; case INPUT_FILE_OPT: input_filename = optarg; @@ -249,46 +244,44 @@ int process_arguments (int argc, char **argv) { return OK; } - /* run an apt-get upgrade */ -int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist){ - int result=STATE_UNKNOWN, regres=0, pc=0, spc=0; +int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist) { + 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]; + char *cmdline = NULL, rerrbuf[64]; /* initialize ereg as it is possible it is printed while uninitialized */ memset(&ereg, '\0', sizeof(ereg.buffer)); - if(upgrade==NO_UPGRADE) return STATE_OK; + if (upgrade == NO_UPGRADE) + return STATE_OK; /* compile the regexps */ if (do_include != NULL) { - regres=regcomp(&ireg, do_include, REG_EXTENDED); - if (regres!=0) { + regres = regcomp(&ireg, do_include, REG_EXTENDED); + if (regres != 0) { regerror(regres, &ireg, rerrbuf, 64); die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); } } - if(do_exclude!=NULL){ - regres=regcomp(&ereg, do_exclude, REG_EXTENDED); - if(regres!=0) { + if (do_exclude != NULL) { + regres = regcomp(&ereg, do_exclude, REG_EXTENDED); + if (regres != 0) { regerror(regres, &ereg, rerrbuf, 64); - die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), - progname, rerrbuf); + die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); } } const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE; - regres=regcomp(&sreg, crit_ptr, REG_EXTENDED); - if(regres!=0) { + regres = regcomp(&sreg, crit_ptr, REG_EXTENDED); + if (regres != 0) { regerror(regres, &ereg, rerrbuf, 64); - die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), - progname, rerrbuf); + die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); } - cmdline=construct_cmdline(upgrade, upgrade_opts); + cmdline = construct_cmdline(upgrade, upgrade_opts); if (input_filename != NULL) { /* read input from a file for testing */ result = cmd_file_read(input_filename, &chld_out, 0); @@ -300,17 +293,18 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg /* apt-get upgrade only changes exit status if there is an * internal error when run in dry-run mode. therefore we will * treat such an error as UNKNOWN */ - if(result != 0){ - exec_warning=1; + if (result != 0) { + exec_warning = 1; result = STATE_UNKNOWN; - fprintf(stderr, _("'%s' exited with non-zero status.\n"), - cmdline); + fprintf(stderr, _("'%s' exited with non-zero status.\n"), cmdline); } - *pkglist=malloc(sizeof(char *) * chld_out.lines); - if(!pkglist) die(STATE_UNKNOWN, "malloc failed!\n"); - *secpkglist=malloc(sizeof(char *) * chld_out.lines); - if(!secpkglist) die(STATE_UNKNOWN, "malloc failed!\n"); + *pkglist = malloc(sizeof(char *) * chld_out.lines); + if (!pkglist) + die(STATE_UNKNOWN, "malloc failed!\n"); + *secpkglist = malloc(sizeof(char *) * chld_out.lines); + if (!secpkglist) + die(STATE_UNKNOWN, "malloc failed!\n"); /* parse the output, which should only consist of lines like * @@ -321,54 +315,56 @@ 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(size_t i = 0; i < chld_out.lines; i++) { - if(verbose){ + for (size_t i = 0; i < chld_out.lines; i++) { + if (verbose) { printf("%s\n", chld_out.line[i]); } /* if it is a package we care about */ if (strncmp(PKGINST_PREFIX, chld_out.line[i], strlen(PKGINST_PREFIX)) == 0 && - (do_include == NULL || regexec(&ireg, chld_out.line[i], 0, NULL, 0) == 0)) { + (do_include == NULL || regexec(&ireg, chld_out.line[i], 0, NULL, 0) == 0)) { /* if we're not excluding, or it's not in the * list of stuff to exclude */ - if(do_exclude==NULL || - regexec(&ereg, chld_out.line[i], 0, NULL, 0)!=0){ + if (do_exclude == NULL || regexec(&ereg, chld_out.line[i], 0, NULL, 0) != 0) { pc++; - if(regexec(&sreg, chld_out.line[i], 0, NULL, 0)==0){ + if (regexec(&sreg, chld_out.line[i], 0, NULL, 0) == 0) { spc++; - if(verbose) printf("*"); - (*secpkglist)[spc-1] = pkg_name(chld_out.line[i]); + if (verbose) + printf("*"); + (*secpkglist)[spc - 1] = pkg_name(chld_out.line[i]); } else { - (*pkglist)[pc-spc-1] = pkg_name(chld_out.line[i]); + (*pkglist)[pc - spc - 1] = pkg_name(chld_out.line[i]); } - if(verbose){ + if (verbose) { printf("*%s\n", chld_out.line[i]); } } } } - *pkgcount=pc; - *secpkgcount=spc; + *pkgcount = pc; + *secpkgcount = spc; /* If we get anything on stderr, at least set warning */ if (input_filename == NULL && chld_err.buflen) { - stderr_warning=1; + stderr_warning = 1; result = max_state(result, STATE_WARNING); - if(verbose){ - for(size_t i = 0; i < chld_err.lines; i++) { + if (verbose) { + for (size_t i = 0; i < chld_err.lines; i++) { fprintf(stderr, "%s\n", chld_err.line[i]); } } } - if (do_include != NULL) regfree(&ireg); + if (do_include != NULL) + regfree(&ireg); regfree(&sreg); - if(do_exclude!=NULL) regfree(&ereg); + if (do_exclude != NULL) + regfree(&ereg); free(cmdline); return result; } /* run an apt-get update (needs root) */ -int run_update(void){ - int result=STATE_UNKNOWN; +int run_update(void) { + int result = STATE_UNKNOWN; struct output chld_out, chld_err; char *cmdline; @@ -378,25 +374,24 @@ int run_update(void){ /* apt-get update changes exit status if it can't fetch packages. * since we were explicitly asked to do so, this is treated as * a critical error. */ - if(result != 0){ - exec_warning=1; + if (result != 0) { + exec_warning = 1; result = STATE_CRITICAL; - fprintf(stderr, _("'%s' exited with non-zero status.\n"), - cmdline); + fprintf(stderr, _("'%s' exited with non-zero status.\n"), cmdline); } - if(verbose){ - for(size_t i = 0; i < chld_out.lines; i++) { + if (verbose) { + for (size_t i = 0; i < chld_out.lines; i++) { printf("%s\n", chld_out.line[i]); } } /* If we get anything on stderr, at least set warning */ - if(chld_err.buflen){ - stderr_warning=1; + if (chld_err.buflen) { + stderr_warning = 1; result = max_state(result, STATE_WARNING); - if(verbose){ - for(size_t i = 0; i < chld_err.lines; i++) { + if (verbose) { + for (size_t i = 0; i < chld_err.lines; i++) { fprintf(stderr, "%s\n", chld_err.line[i]); } } @@ -405,158 +400,161 @@ int run_update(void){ return result; } -char* pkg_name(char *line){ - char *start=NULL, *space=NULL, *pkg=NULL; - int len=0; +char *pkg_name(char *line) { + char *start = NULL, *space = NULL, *pkg = NULL; + int len = 0; start = line + strlen(PKGINST_PREFIX); len = strlen(start); space = index(start, ' '); - if(space!=NULL){ + if (space != NULL) { len = space - start; } - pkg=malloc(sizeof(char)*(len+1)); - if(!pkg) die(STATE_UNKNOWN, "malloc failed!\n"); + pkg = malloc(sizeof(char) * (len + 1)); + if (!pkg) + die(STATE_UNKNOWN, "malloc failed!\n"); strncpy(pkg, start, len); - pkg[len]='\0'; + pkg[len] = '\0'; return pkg; } -int cmpstringp(const void *p1, const void *p2){ - return strcmp(* (char * const *) p1, * (char * const *) p2); -} +int cmpstringp(const void *p1, const void *p2) { return strcmp(*(char *const *)p1, *(char *const *)p2); } -char* add_to_regexp(char *expr, const char *next){ - char *re=NULL; +char *add_to_regexp(char *expr, const char *next) { + char *re = NULL; - if(expr==NULL){ - re=malloc(sizeof(char)*(strlen("()")+strlen(next)+1)); - if(!re) die(STATE_UNKNOWN, "malloc failed!\n"); + if (expr == NULL) { + re = malloc(sizeof(char) * (strlen("()") + strlen(next) + 1)); + if (!re) + die(STATE_UNKNOWN, "malloc failed!\n"); sprintf(re, "(%s)", next); } else { /* resize it, adding an extra char for the new '|' separator */ - re=realloc(expr, sizeof(char)*(strlen(expr)+1+strlen(next)+1)); - if(!re) die(STATE_UNKNOWN, "realloc failed!\n"); + re = realloc(expr, sizeof(char) * (strlen(expr) + 1 + strlen(next) + 1)); + if (!re) + die(STATE_UNKNOWN, "realloc failed!\n"); /* append it starting at ')' in the old re */ - sprintf((char*)(re+strlen(re)-1), "|%s)", next); + sprintf((char *)(re + strlen(re) - 1), "|%s)", next); } return re; } -char* construct_cmdline(upgrade_type u, const char *opts){ - int len=0; - const char *opts_ptr=NULL, *aptcmd=NULL; - char *cmd=NULL; +char *construct_cmdline(upgrade_type u, const char *opts) { + int len = 0; + const char *opts_ptr = NULL, *aptcmd = NULL; + char *cmd = NULL; - switch(u){ + switch (u) { case UPGRADE: - if(opts==NULL) opts_ptr=UPGRADE_DEFAULT_OPTS; - else opts_ptr=opts; - aptcmd="upgrade"; + if (opts == NULL) + opts_ptr = UPGRADE_DEFAULT_OPTS; + else + opts_ptr = opts; + aptcmd = "upgrade"; break; case DIST_UPGRADE: - if(opts==NULL) opts_ptr=UPGRADE_DEFAULT_OPTS; - else opts_ptr=opts; - aptcmd="dist-upgrade"; + if (opts == NULL) + opts_ptr = UPGRADE_DEFAULT_OPTS; + else + opts_ptr = opts; + aptcmd = "dist-upgrade"; break; case NO_UPGRADE: - if(opts==NULL) opts_ptr=UPDATE_DEFAULT_OPTS; - else opts_ptr=opts; - aptcmd="update"; + if (opts == NULL) + opts_ptr = UPDATE_DEFAULT_OPTS; + else + opts_ptr = opts; + aptcmd = "update"; break; } - len+=strlen(PATH_TO_APTGET)+1; /* "/usr/bin/apt-get " */ - len+=strlen(opts_ptr)+1; /* "opts " */ - len+=strlen(aptcmd)+1; /* "upgrade\0" */ + len += strlen(PATH_TO_APTGET) + 1; /* "/usr/bin/apt-get " */ + len += strlen(opts_ptr) + 1; /* "opts " */ + len += strlen(aptcmd) + 1; /* "upgrade\0" */ - cmd=(char*)malloc(sizeof(char)*len); - if(cmd==NULL) die(STATE_UNKNOWN, "malloc failed"); + cmd = (char *)malloc(sizeof(char) * len); + if (cmd == NULL) + die(STATE_UNKNOWN, "malloc failed"); sprintf(cmd, "%s %s %s", PATH_TO_APTGET, opts_ptr, aptcmd); return cmd; } /* informative help message */ -void -print_help (void) -{ - print_revision(progname, NP_VERSION); - - printf(_(COPYRIGHT), copyright, email); - - printf("%s\n", _("This plugin checks for software updates on systems that use")); - printf("%s\n", _("package management systems based on the apt-get(8) command")); - printf("%s\n", _("found in Debian GNU/Linux")); - - printf ("\n\n"); - - print_usage(); - - printf(UT_HELP_VRSN); - printf(UT_EXTRA_OPTS); - - printf(UT_PLUG_TIMEOUT, timeout_interval); - - printf (" %s\n", "-n, --no-upgrade"); - printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); - printf (" %s\n", "-l, --list"); - printf (" %s\n", _("List packages available for upgrade. Packages are printed sorted by")); - printf (" %s\n", _("name with security packages listed first.")); - printf (" %s\n", "-i, --include=REGEXP"); - printf (" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times")); - printf (" %s\n", _("the values will be combined together. Any packages matching this list")); - printf (" %s\n", _("cause the plugin to return WARNING status. Others will be ignored.")); - printf (" %s\n", _("Default is to include all packages.")); - printf (" %s\n", "-e, --exclude=REGEXP"); - printf (" %s\n", _("Exclude packages matching REGEXP from the list of packages that would")); - printf (" %s\n", _("otherwise be included. Can be specified multiple times; the values")); - printf (" %s\n", _("will be combined together. Default is to exclude no packages.")); - printf (" %s\n", "-c, --critical=REGEXP"); - printf (" %s\n", _("If the full package information of any of the upgradable packages match")); - printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified")); - printf (" %s\n", _("multiple times like above. Default is a regexp matching security")); - printf (" %s\n", _("upgrades for Debian and Ubuntu:")); - printf (" \t%s\n", SECURITY_RE); - printf (" %s\n", _("Note that the package must first match the include list before its")); - printf (" %s\n", _("information is compared against the critical list.")); - printf (" %s\n", "-o, --only-critical"); - printf (" %s\n", _("Only warn about upgrades matching the critical list. The total number")); - printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause")); - printf (" %s\n", _("the plugin to return WARNING status.")); - printf (" %s\n", "-w, --packages-warning"); - printf (" %s\n", _("Minimum number of packages available for upgrade to return WARNING status.")); - printf (" %s\n\n", _("Default is 1 package.")); - - printf ("%s\n\n", _("The following options require root privileges and should be used with care:")); - printf (" %s\n", "-u, --update=OPTS"); - printf (" %s\n", _("First perform an 'apt-get update'. An optional OPTS parameter overrides")); - printf (" %s\n", _("the default options. Note: you may also need to adjust the global")); - printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get")); - printf (" %s\n", _("upgrade is expected to take longer than the default timeout.")); - printf (" %s\n", "-U, --upgrade=OPTS"); - printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,")); - printf (" %s\n", _("apt-get will be run with these command line options instead of the")); - printf (" %s", _("default ")); - printf ("(%s).\n", UPGRADE_DEFAULT_OPTS); - printf (" %s\n", _("Note that you may be required to have root privileges if you do not use")); - printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade")); - printf (" %s\n", "-d, --dist-upgrade=OPTS"); - printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS")); - printf (" %s\n", _("can be provided to override the default options.")); - - printf(UT_SUPPORT); +void print_help(void) { + print_revision(progname, NP_VERSION); + + printf(_(COPYRIGHT), copyright, email); + + printf("%s\n", _("This plugin checks for software updates on systems that use")); + printf("%s\n", _("package management systems based on the apt-get(8) command")); + printf("%s\n", _("found in Debian GNU/Linux")); + + printf("\n\n"); + + print_usage(); + + printf(UT_HELP_VRSN); + printf(UT_EXTRA_OPTS); + + printf(UT_PLUG_TIMEOUT, timeout_interval); + + printf(" %s\n", "-n, --no-upgrade"); + printf(" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); + printf(" %s\n", "-l, --list"); + printf(" %s\n", _("List packages available for upgrade. Packages are printed sorted by")); + printf(" %s\n", _("name with security packages listed first.")); + printf(" %s\n", "-i, --include=REGEXP"); + printf(" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times")); + printf(" %s\n", _("the values will be combined together. Any packages matching this list")); + printf(" %s\n", _("cause the plugin to return WARNING status. Others will be ignored.")); + printf(" %s\n", _("Default is to include all packages.")); + printf(" %s\n", "-e, --exclude=REGEXP"); + printf(" %s\n", _("Exclude packages matching REGEXP from the list of packages that would")); + printf(" %s\n", _("otherwise be included. Can be specified multiple times; the values")); + printf(" %s\n", _("will be combined together. Default is to exclude no packages.")); + printf(" %s\n", "-c, --critical=REGEXP"); + printf(" %s\n", _("If the full package information of any of the upgradable packages match")); + printf(" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified")); + printf(" %s\n", _("multiple times like above. Default is a regexp matching security")); + printf(" %s\n", _("upgrades for Debian and Ubuntu:")); + printf(" \t%s\n", SECURITY_RE); + printf(" %s\n", _("Note that the package must first match the include list before its")); + printf(" %s\n", _("information is compared against the critical list.")); + printf(" %s\n", "-o, --only-critical"); + printf(" %s\n", _("Only warn about upgrades matching the critical list. The total number")); + printf(" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause")); + printf(" %s\n", _("the plugin to return WARNING status.")); + printf(" %s\n", "-w, --packages-warning"); + printf(" %s\n", _("Minimum number of packages available for upgrade to return WARNING status.")); + printf(" %s\n\n", _("Default is 1 package.")); + + printf("%s\n\n", _("The following options require root privileges and should be used with care:")); + printf(" %s\n", "-u, --update=OPTS"); + printf(" %s\n", _("First perform an 'apt-get update'. An optional OPTS parameter overrides")); + printf(" %s\n", _("the default options. Note: you may also need to adjust the global")); + printf(" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get")); + printf(" %s\n", _("upgrade is expected to take longer than the default timeout.")); + printf(" %s\n", "-U, --upgrade=OPTS"); + printf(" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,")); + printf(" %s\n", _("apt-get will be run with these command line options instead of the")); + printf(" %s", _("default ")); + printf("(%s).\n", UPGRADE_DEFAULT_OPTS); + printf(" %s\n", _("Note that you may be required to have root privileges if you do not use")); + printf(" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade")); + printf(" %s\n", "-d, --dist-upgrade=OPTS"); + printf(" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS")); + printf(" %s\n", _("can be provided to override the default options.")); + + printf(UT_SUPPORT); } - /* simple usage heading */ -void -print_usage(void) -{ - printf ("%s\n", _("Usage:")); - printf ("%s [[-d|-u|-U]opts] [-n] [-l] [-t timeout] [-w packages-warning]\n", progname); +void print_usage(void) { + printf("%s\n", _("Usage:")); + printf("%s [[-d|-u|-U]opts] [-n] [-l] [-t timeout] [-w packages-warning]\n", progname); } From git at monitoring-plugins.org Fri Nov 8 23:00:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:00:12 +0100 (CET) Subject: [monitoring-plugins] check_apt: mindless linter fixes Message-ID: <20241108220012.6A1A12000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: d7671b8a4a8f7a46f5576be7d6d6644c9cd77000 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com> Committer: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Sat Oct 26 22:52:23 2024 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=d7671b8 check_apt: mindless linter fixes --- plugins/check_apt.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/plugins/check_apt.c b/plugins/check_apt.c index 02af1a4..16c34ca 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -57,7 +57,7 @@ typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type; #define SECURITY_RE "^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)" /* some standard functions */ -int process_arguments(int, char **); +int process_arguments(int /*argc*/, char ** /*argv*/); void print_help(void); void print_usage(void); @@ -94,8 +94,11 @@ 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; - char **packages_list = NULL, **secpackages_list = NULL; + int result = STATE_UNKNOWN; + int packages_available = 0; + int sec_count = 0; + char **packages_list = NULL; + char **secpackages_list = NULL; /* Parse extra opts if any */ argv = np_extra_opts(&argc, argv, progname); @@ -246,10 +249,17 @@ int process_arguments(int argc, char **argv) { /* run an apt-get upgrade */ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist) { - 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]; + int result = STATE_UNKNOWN; + int regres = 0; + int pc = 0; + int spc = 0; + struct output chld_out; + struct output chld_err; + regex_t ireg; + regex_t ereg; + regex_t sreg; + char *cmdline = NULL; + char rerrbuf[64]; /* initialize ereg as it is possible it is printed while uninitialized */ memset(&ereg, '\0', sizeof(ereg.buffer)); @@ -365,7 +375,8 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg /* run an apt-get update (needs root) */ int run_update(void) { int result = STATE_UNKNOWN; - struct output chld_out, chld_err; + struct output chld_out; + struct output chld_err; char *cmdline; /* run the update */ @@ -401,7 +412,9 @@ int run_update(void) { } char *pkg_name(char *line) { - char *start = NULL, *space = NULL, *pkg = NULL; + char *start = NULL; + char *space = NULL; + char *pkg = NULL; int len = 0; start = line + strlen(PKGINST_PREFIX); @@ -446,7 +459,8 @@ char *add_to_regexp(char *expr, const char *next) { char *construct_cmdline(upgrade_type u, const char *opts) { int len = 0; - const char *opts_ptr = NULL, *aptcmd = NULL; + const char *opts_ptr = NULL; + const char *aptcmd = NULL; char *cmd = NULL; switch (u) { From git at monitoring-plugins.org Fri Nov 8 23:00:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:00:12 +0100 (CET) Subject: [monitoring-plugins] clang-format: always add braces Message-ID: <20241108220012.8379C2000125@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: b43e913b2c2a380ef59ed3046cac1f0f92b65a9d Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com> Committer: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Sat Oct 26 22:54:15 2024 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b43e913 clang-format: always add braces --- .clang-format | 1 + plugins/check_apt.c | 69 ++++++++++++++++++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/.clang-format b/.clang-format index 877a53b..ca411ed 100644 --- a/.clang-format +++ b/.clang-format @@ -9,3 +9,4 @@ IndentPPDirectives: AfterHash SortIncludes: Never AllowShortEnumsOnASingleLine: false BinPackArguments: true +InsertBraces: true diff --git a/plugins/check_apt.c b/plugins/check_apt.c index 16c34ca..288d37c 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -103,8 +103,9 @@ int main(int argc, char **argv) { /* Parse extra opts if any */ argv = np_extra_opts(&argc, argv, progname); - if (process_arguments(argc, argv) == ERROR) + if (process_arguments(argc, argv) == ERROR) { usage_va(_("Could not parse arguments")); + } /* Set signal handling and alarm timeout */ if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) { @@ -115,8 +116,9 @@ int main(int argc, char **argv) { alarm(timeout_interval); /* if they want to run apt-get update first... */ - if (do_update) + if (do_update) { result = run_update(); + } /* apt-get upgrade */ result = max_state(result, run_upgrade(&packages_available, &sec_count, &packages_list, &secpackages_list)); @@ -138,12 +140,14 @@ 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 (int 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 (int i = 0; i < packages_available - sec_count; i++) + for (int i = 0; i < packages_available - sec_count; i++) { printf("%s\n", packages_list[i]); + } } } @@ -174,8 +178,9 @@ int process_arguments(int argc, char **argv) { while (1) { c = getopt_long(argc, argv, "hVvt:u::U::d::nli:e:c:ow:", longopts, NULL); - if (c == -1 || c == EOF || c == 1) + if (c == -1 || c == EOF || c == 1) { break; + } switch (c) { case 'h': @@ -194,16 +199,18 @@ int process_arguments(int argc, char **argv) { upgrade = DIST_UPGRADE; if (optarg != NULL) { upgrade_opts = strdup(optarg); - if (upgrade_opts == NULL) + if (upgrade_opts == NULL) { die(STATE_UNKNOWN, "strdup failed"); + } } break; case 'U': upgrade = UPGRADE; if (optarg != NULL) { upgrade_opts = strdup(optarg); - if (upgrade_opts == NULL) + if (upgrade_opts == NULL) { die(STATE_UNKNOWN, "strdup failed"); + } } break; case 'n': @@ -213,8 +220,9 @@ int process_arguments(int argc, char **argv) { do_update = true; if (optarg != NULL) { update_opts = strdup(optarg); - if (update_opts == NULL) + if (update_opts == NULL) { die(STATE_UNKNOWN, "strdup failed"); + } } break; case 'l': @@ -264,8 +272,9 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg /* initialize ereg as it is possible it is printed while uninitialized */ memset(&ereg, '\0', sizeof(ereg.buffer)); - if (upgrade == NO_UPGRADE) + if (upgrade == NO_UPGRADE) { return STATE_OK; + } /* compile the regexps */ if (do_include != NULL) { @@ -310,11 +319,13 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg } *pkglist = malloc(sizeof(char *) * chld_out.lines); - if (!pkglist) + if (!pkglist) { die(STATE_UNKNOWN, "malloc failed!\n"); + } *secpkglist = malloc(sizeof(char *) * chld_out.lines); - if (!secpkglist) + if (!secpkglist) { die(STATE_UNKNOWN, "malloc failed!\n"); + } /* parse the output, which should only consist of lines like * @@ -338,8 +349,9 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg pc++; if (regexec(&sreg, chld_out.line[i], 0, NULL, 0) == 0) { spc++; - if (verbose) + if (verbose) { printf("*"); + } (*secpkglist)[spc - 1] = pkg_name(chld_out.line[i]); } else { (*pkglist)[pc - spc - 1] = pkg_name(chld_out.line[i]); @@ -363,11 +375,13 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg } } } - if (do_include != NULL) + if (do_include != NULL) { regfree(&ireg); + } regfree(&sreg); - if (do_exclude != NULL) + if (do_exclude != NULL) { regfree(&ereg); + } free(cmdline); return result; } @@ -426,8 +440,9 @@ char *pkg_name(char *line) { } pkg = malloc(sizeof(char) * (len + 1)); - if (!pkg) + if (!pkg) { die(STATE_UNKNOWN, "malloc failed!\n"); + } strncpy(pkg, start, len); pkg[len] = '\0'; @@ -442,14 +457,16 @@ char *add_to_regexp(char *expr, const char *next) { if (expr == NULL) { re = malloc(sizeof(char) * (strlen("()") + strlen(next) + 1)); - if (!re) + if (!re) { die(STATE_UNKNOWN, "malloc failed!\n"); + } sprintf(re, "(%s)", next); } else { /* resize it, adding an extra char for the new '|' separator */ re = realloc(expr, sizeof(char) * (strlen(expr) + 1 + strlen(next) + 1)); - if (!re) + if (!re) { die(STATE_UNKNOWN, "realloc failed!\n"); + } /* append it starting at ')' in the old re */ sprintf((char *)(re + strlen(re) - 1), "|%s)", next); } @@ -465,24 +482,27 @@ char *construct_cmdline(upgrade_type u, const char *opts) { switch (u) { case UPGRADE: - if (opts == NULL) + if (opts == NULL) { opts_ptr = UPGRADE_DEFAULT_OPTS; - else + } else { opts_ptr = opts; + } aptcmd = "upgrade"; break; case DIST_UPGRADE: - if (opts == NULL) + if (opts == NULL) { opts_ptr = UPGRADE_DEFAULT_OPTS; - else + } else { opts_ptr = opts; + } aptcmd = "dist-upgrade"; break; case NO_UPGRADE: - if (opts == NULL) + if (opts == NULL) { opts_ptr = UPDATE_DEFAULT_OPTS; - else + } else { opts_ptr = opts; + } aptcmd = "update"; break; } @@ -492,8 +512,9 @@ char *construct_cmdline(upgrade_type u, const char *opts) { len += strlen(aptcmd) + 1; /* "upgrade\0" */ cmd = (char *)malloc(sizeof(char) * len); - if (cmd == NULL) + if (cmd == NULL) { die(STATE_UNKNOWN, "malloc failed"); + } sprintf(cmd, "%s %s %s", PATH_TO_APTGET, opts_ptr, aptcmd); return cmd; } From git at monitoring-plugins.org Fri Nov 8 23:00:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:00:12 +0100 (CET) Subject: [monitoring-plugins] check_apt: declare local functions static Message-ID: <20241108220012.9D3692000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: ebb4bf4bb4c14807878dab488a66868f7f5751e3 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com> Committer: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Sat Oct 26 22:57:58 2024 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=ebb4bf4 check_apt: declare local functions static --- plugins/check_apt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/check_apt.c b/plugins/check_apt.c index 288d37c..eb08a06 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -57,22 +57,22 @@ typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type; #define SECURITY_RE "^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)" /* some standard functions */ -int process_arguments(int /*argc*/, char ** /*argv*/); -void print_help(void); +static int process_arguments(int /*argc*/, char ** /*argv*/); +static void print_help(void); void print_usage(void); /* construct the appropriate apt-get cmdline */ -char *construct_cmdline(upgrade_type u, const char *opts); +static char *construct_cmdline(upgrade_type u, const char *opts); /* run an apt-get update */ -int run_update(void); +static int run_update(void); /* run an apt-get upgrade */ -int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist); +static int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist); /* add another clause to a regexp */ -char *add_to_regexp(char *expr, const char *next); +static char *add_to_regexp(char *expr, const char *next); /* extract package name from Inst line */ -char *pkg_name(char *line); +static char *pkg_name(char *line); /* string comparison function for qsort */ -int cmpstringp(const void *p1, const void *p2); +static int cmpstringp(const void *p1, const void *p2); /* configuration variables */ static int verbose = 0; /* -v */ From git at monitoring-plugins.org Fri Nov 8 23:00:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:00:12 +0100 (CET) Subject: [monitoring-plugins] check_apt: localize variables Message-ID: <20241108220012.BB1D62000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 75ff5b3b51a76081196f41c4b428dc3db50f2664 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com> Committer: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Sat Oct 26 23:18:26 2024 +0200 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=75ff5b3 check_apt: localize variables --- plugins/check_apt.c | 65 +++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/plugins/check_apt.c b/plugins/check_apt.c index eb08a06..c2c693e 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -94,12 +94,6 @@ 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; - int packages_available = 0; - int sec_count = 0; - char **packages_list = NULL; - char **secpackages_list = NULL; - /* Parse extra opts if any */ argv = np_extra_opts(&argc, argv, progname); @@ -115,11 +109,16 @@ int main(int argc, char **argv) { /* handle timeouts gracefully... */ alarm(timeout_interval); + int result = STATE_UNKNOWN; /* if they want to run apt-get update first... */ if (do_update) { result = run_update(); } + int packages_available = 0; + int sec_count = 0; + char **packages_list = NULL; + char **secpackages_list = NULL; /* apt-get upgrade */ result = max_state(result, run_upgrade(&packages_available, &sec_count, &packages_list, &secpackages_list)); @@ -156,8 +155,6 @@ int main(int argc, char **argv) { /* process command-line arguments */ int process_arguments(int argc, char **argv) { - int c; - static struct option longopts[] = {{"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, {"verbose", no_argument, 0, 'v'}, @@ -175,14 +172,14 @@ int process_arguments(int argc, char **argv) { {"packages-warning", required_argument, 0, 'w'}, {0, 0, 0, 0}}; - while (1) { - c = getopt_long(argc, argv, "hVvt:u::U::d::nli:e:c:ow:", longopts, NULL); + while (true) { + int option_char = getopt_long(argc, argv, "hVvt:u::U::d::nli:e:c:ow:", longopts, NULL); - if (c == -1 || c == EOF || c == 1) { + if (option_char == -1 || option_char == EOF || option_char == 1) { break; } - switch (c) { + switch (option_char) { case 'h': print_help(); exit(STATE_UNKNOWN); @@ -257,18 +254,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 result = STATE_UNKNOWN; - int regres = 0; - int pc = 0; - int spc = 0; - struct output chld_out; - struct output chld_err; - regex_t ireg; regex_t ereg; - regex_t sreg; - char *cmdline = NULL; - char rerrbuf[64]; - /* initialize ereg as it is possible it is printed while uninitialized */ memset(&ereg, '\0', sizeof(ereg.buffer)); @@ -276,6 +262,9 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg return STATE_OK; } + int regres = 0; + regex_t ireg; + char rerrbuf[64]; /* compile the regexps */ if (do_include != NULL) { regres = regcomp(&ireg, do_include, REG_EXTENDED); @@ -293,6 +282,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg } } + regex_t sreg; const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE; regres = regcomp(&sreg, crit_ptr, REG_EXTENDED); if (regres != 0) { @@ -300,6 +290,10 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); } + int result = STATE_UNKNOWN; + struct output chld_out; + struct output chld_err; + char *cmdline = NULL; cmdline = construct_cmdline(upgrade, upgrade_opts); if (input_filename != NULL) { /* read input from a file for testing */ @@ -336,6 +330,8 @@ 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. */ + int pc = 0; + int spc = 0; for (size_t i = 0; i < chld_out.lines; i++) { if (verbose) { printf("%s\n", chld_out.line[i]); @@ -389,12 +385,12 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg /* run an apt-get update (needs root) */ int run_update(void) { int result = STATE_UNKNOWN; - struct output chld_out; - struct output chld_err; char *cmdline; - /* run the update */ cmdline = construct_cmdline(NO_UPGRADE, update_opts); + + struct output chld_out; + struct output chld_err; result = np_runcmd(cmdline, &chld_out, &chld_err, 0); /* apt-get update changes exit status if it can't fetch packages. * since we were explicitly asked to do so, this is treated as @@ -426,20 +422,16 @@ int run_update(void) { } char *pkg_name(char *line) { - char *start = NULL; - char *space = NULL; - char *pkg = NULL; - int len = 0; + char *start = line + strlen(PKGINST_PREFIX); - start = line + strlen(PKGINST_PREFIX); - len = strlen(start); + int len = strlen(start); - space = index(start, ' '); + char *space = index(start, ' '); if (space != NULL) { len = space - start; } - pkg = malloc(sizeof(char) * (len + 1)); + char *pkg = malloc(sizeof(char) * (len + 1)); if (!pkg) { die(STATE_UNKNOWN, "malloc failed!\n"); } @@ -475,10 +467,8 @@ char *add_to_regexp(char *expr, const char *next) { } char *construct_cmdline(upgrade_type u, const char *opts) { - int len = 0; const char *opts_ptr = NULL; const char *aptcmd = NULL; - char *cmd = NULL; switch (u) { case UPGRADE: @@ -507,11 +497,12 @@ char *construct_cmdline(upgrade_type u, const char *opts) { break; } + int len = 0; len += strlen(PATH_TO_APTGET) + 1; /* "/usr/bin/apt-get " */ len += strlen(opts_ptr) + 1; /* "opts " */ len += strlen(aptcmd) + 1; /* "upgrade\0" */ - cmd = (char *)malloc(sizeof(char) * len); + char *cmd = (char *)malloc(sizeof(char) * len); if (cmd == NULL) { die(STATE_UNKNOWN, "malloc failed"); } From git at monitoring-plugins.org Fri Nov 8 23:00:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:00:12 +0100 (CET) Subject: [monitoring-plugins] check_apt: clang-format Message-ID: <20241108220012.EB0742000125@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 540d609d845869a5c826f8190bdfed47db1e4259 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 10:50:22 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=540d609 check_apt: clang-format --- plugins/check_apt.c | 64 ++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/plugins/check_apt.c b/plugins/check_apt.c index c2c693e..ac89f81 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -1,33 +1,33 @@ /***************************************************************************** -* -* Monitoring check_apt plugin -* -* License: GPL -* Copyright (c) 2006-2024 Monitoring Plugins Development Team -* -* Original author: Sean Finney -* -* Description: -* -* This file contains the check_apt plugin -* -* Check for available updates in apt package management systems -* -* -* 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 . -* -*****************************************************************************/ + * + * Monitoring check_apt plugin + * + * License: GPL + * Copyright (c) 2006-2024 Monitoring Plugins Development Team + * + * Original author: Sean Finney + * + * Description: + * + * This file contains the check_apt plugin + * + * Check for available updates in apt package management systems + * + * + * 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 . + * + *****************************************************************************/ const char *progname = "check_apt"; const char *copyright = "2006-2024"; @@ -39,7 +39,11 @@ const char *email = "devel at monitoring-plugins.org"; #include "regex.h" /* some constants */ -typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type; +typedef enum { + UPGRADE, + DIST_UPGRADE, + NO_UPGRADE +} upgrade_type; /* Character for hidden input file option (for testing). */ #define INPUT_FILE_OPT CHAR_MAX + 1 From git at monitoring-plugins.org Fri Nov 8 23:00:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:00:13 +0100 (CET) Subject: [monitoring-plugins] check_apt: Purify run_upgrade function Message-ID: <20241108220013.122002000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 4079ba3c474054af6c8bb2c3b426540b2de01628 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 11:37:30 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=4079ba3 check_apt: Purify run_upgrade function --- plugins/check_apt.c | 66 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/plugins/check_apt.c b/plugins/check_apt.c index ac89f81..1eda45d 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -69,8 +69,18 @@ void print_usage(void); static char *construct_cmdline(upgrade_type u, const char *opts); /* run an apt-get update */ static int run_update(void); + +typedef struct { + int errorcode; + int package_count; + int security_package_count; + char **packages_list; + char **secpackages_list; +} run_upgrade_result; + /* run an apt-get upgrade */ -static int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist); +static run_upgrade_result run_upgrade(void); + /* add another clause to a regexp */ static char *add_to_regexp(char *expr, const char *next); /* extract package name from Inst line */ @@ -119,12 +129,14 @@ int main(int argc, char **argv) { result = run_update(); } - int packages_available = 0; - int sec_count = 0; - char **packages_list = NULL; - char **secpackages_list = NULL; /* apt-get upgrade */ - result = max_state(result, run_upgrade(&packages_available, &sec_count, &packages_list, &secpackages_list)); + run_upgrade_result upgrad_res = run_upgrade(); + + result = max_state(result, upgrad_res.errorcode); + int packages_available = upgrad_res.package_count; + int sec_count = upgrad_res.security_package_count; + char **packages_list = upgrad_res.packages_list; + char **secpackages_list = upgrad_res.secpackages_list; if (sec_count > 0) { result = max_state(result, STATE_CRITICAL); @@ -257,13 +269,18 @@ int process_arguments(int argc, char **argv) { } /* run an apt-get upgrade */ -int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist) { +run_upgrade_result run_upgrade(void) { regex_t ereg; /* initialize ereg as it is possible it is printed while uninitialized */ memset(&ereg, '\0', sizeof(ereg.buffer)); + run_upgrade_result result = { + .errorcode = STATE_UNKNOWN, + }; + if (upgrade == NO_UPGRADE) { - return STATE_OK; + result.errorcode = STATE_OK; + return result; } int regres = 0; @@ -294,33 +311,32 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); } - int result = STATE_UNKNOWN; struct output chld_out; struct output chld_err; char *cmdline = NULL; cmdline = construct_cmdline(upgrade, upgrade_opts); if (input_filename != NULL) { /* read input from a file for testing */ - result = cmd_file_read(input_filename, &chld_out, 0); + result.errorcode = cmd_file_read(input_filename, &chld_out, 0); } else { /* run the upgrade */ - result = np_runcmd(cmdline, &chld_out, &chld_err, 0); + result.errorcode = np_runcmd(cmdline, &chld_out, &chld_err, 0); } /* apt-get upgrade only changes exit status if there is an * internal error when run in dry-run mode. therefore we will * treat such an error as UNKNOWN */ - if (result != 0) { + if (result.errorcode != STATE_OK) { exec_warning = 1; - result = STATE_UNKNOWN; + result.errorcode = STATE_UNKNOWN; fprintf(stderr, _("'%s' exited with non-zero status.\n"), cmdline); } - *pkglist = malloc(sizeof(char *) * chld_out.lines); + char **pkglist = malloc(sizeof(char *) * chld_out.lines); if (!pkglist) { die(STATE_UNKNOWN, "malloc failed!\n"); } - *secpkglist = malloc(sizeof(char *) * chld_out.lines); + char **secpkglist = malloc(sizeof(char *) * chld_out.lines); if (!secpkglist) { die(STATE_UNKNOWN, "malloc failed!\n"); } @@ -334,8 +350,8 @@ 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. */ - int pc = 0; - int spc = 0; + int package_counter = 0; + int security_package_counter = 0; for (size_t i = 0; i < chld_out.lines; i++) { if (verbose) { printf("%s\n", chld_out.line[i]); @@ -346,15 +362,15 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg /* if we're not excluding, or it's not in the * list of stuff to exclude */ if (do_exclude == NULL || regexec(&ereg, chld_out.line[i], 0, NULL, 0) != 0) { - pc++; + package_counter++; if (regexec(&sreg, chld_out.line[i], 0, NULL, 0) == 0) { - spc++; + security_package_counter++; if (verbose) { printf("*"); } - (*secpkglist)[spc - 1] = pkg_name(chld_out.line[i]); + (secpkglist)[security_package_counter - 1] = pkg_name(chld_out.line[i]); } else { - (*pkglist)[pc - spc - 1] = pkg_name(chld_out.line[i]); + (pkglist)[package_counter - security_package_counter - 1] = pkg_name(chld_out.line[i]); } if (verbose) { printf("*%s\n", chld_out.line[i]); @@ -362,13 +378,15 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg } } } - *pkgcount = pc; - *secpkgcount = spc; + result.package_count = package_counter; + result.security_package_count = security_package_counter; + result.packages_list = pkglist; + result.secpackages_list = secpkglist; /* If we get anything on stderr, at least set warning */ if (input_filename == NULL && chld_err.buflen) { stderr_warning = 1; - result = max_state(result, STATE_WARNING); + result.errorcode = max_state(result.errorcode, STATE_WARNING); if (verbose) { for (size_t i = 0; i < chld_err.lines; i++) { fprintf(stderr, "%s\n", chld_err.line[i]); From git at monitoring-plugins.org Fri Nov 8 23:00:13 2024 From: git at monitoring-plugins.org (GitHub) Date: Fri, 8 Nov 2024 23:00:13 +0100 (CET) Subject: [monitoring-plugins] Merge branch 'master' into cleanup/check_apt Message-ID: <20241108220013.3446D2000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 82f1a167f60ee8c82475ec474328fbc2c7ee538e Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Fri Nov 8 19:45:04 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=82f1a16 Merge branch 'master' into cleanup/check_apt --- From git at monitoring-plugins.org Fri Nov 8 23:00:13 2024 From: git at monitoring-plugins.org (GitHub) Date: Fri, 8 Nov 2024 23:00:13 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2032 from ... Message-ID: <20241108220013.49C2E2000125@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: ef39064f5148d96a6923f60a2fadd12810fcfa06 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Fri Nov 8 22:59:54 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=ef39064 Merge pull request #2032 from RincewindsHat/cleanup/check_apt Cleanup/check apt --- From git at monitoring-plugins.org Fri Nov 8 23:10:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:12 +0100 (CET) Subject: [monitoring-plugins] check_overcr: delare file local variables static Message-ID: <20241108221012.6B7EC2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 2031a5acebc8ade6b3775bae769b1decc1747be9 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:20:03 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=2031a5a check_overcr: delare file local variables static --- plugins/check_overcr.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c index e80d477..599540b 100644 --- a/plugins/check_overcr.c +++ b/plugins/check_overcr.c @@ -52,23 +52,22 @@ enum { PORT = 2000 }; -char *server_address = NULL; -int server_port = PORT; -double warning_value = 0L; -double critical_value = 0L; -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]; - -int process_arguments(int, char **); +static char *server_address = NULL; +static int server_port = PORT; +static double warning_value = 0L; +static double critical_value = 0L; +static bool check_warning_value = false; +static bool check_critical_value = false; +static enum checkvar vars_to_check = NONE; + +static int netstat_port = 0; +static char *disk_name = NULL; +static char *process_name = NULL; +static char send_buffer[MAX_INPUT_BUFFER]; + +static int process_arguments(int, char **); void print_usage(void); -void print_help(void); +static void print_help(void); int main(int argc, char **argv) { int result = STATE_UNKNOWN; From git at monitoring-plugins.org Fri Nov 8 23:10:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:12 +0100 (CET) Subject: [monitoring-plugins] check_ldap: delare file local variables static Message-ID: <20241108221012.7AD962000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: b7b8abb8533d8d21e76481eb26bae9215e56b2fd Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:30:38 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b7b8abb check_ldap: delare file local variables static --- plugins/check_ldap.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index 1c72829..87818da 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c @@ -47,37 +47,37 @@ enum { DEFAULT_PORT = 389 }; -int process_arguments (int, char **); -int validate_arguments (void); -void print_help (void); +static int process_arguments (int, char **); +static int validate_arguments (void); +static void print_help (void); void print_usage (void); -char ld_defattr[] = "(objectclass=*)"; -char *ld_attr = ld_defattr; -char *ld_host = NULL; -char *ld_base = NULL; -char *ld_passwd = NULL; -char *ld_binddn = NULL; -int ld_port = -1; +static char ld_defattr[] = "(objectclass=*)"; +static char *ld_attr = ld_defattr; +static char *ld_host = NULL; +static char *ld_base = NULL; +static char *ld_passwd = NULL; +static char *ld_binddn = NULL; +static int ld_port = -1; #ifdef HAVE_LDAP_SET_OPTION -int ld_protocol = DEFAULT_PROTOCOL; +static int ld_protocol = DEFAULT_PROTOCOL; #endif #ifndef LDAP_OPT_SUCCESS # define LDAP_OPT_SUCCESS LDAP_SUCCESS #endif -double warn_time = UNDEFINED; -double crit_time = UNDEFINED; -thresholds *entries_thresholds = NULL; -struct timeval tv; -char* warn_entries = NULL; -char* crit_entries = NULL; -bool starttls = false; -bool ssl_on_connect = false; -bool verbose = false; +static double warn_time = UNDEFINED; +static double crit_time = UNDEFINED; +static thresholds *entries_thresholds = NULL; +static struct timeval tv; +static char* warn_entries = NULL; +static char* crit_entries = NULL; +static bool starttls = false; +static bool ssl_on_connect = false; +static bool verbose = false; /* for ldap tls */ -char *SERVICE = "LDAP"; +static char *SERVICE = "LDAP"; int main (int argc, char *argv[]) From git at monitoring-plugins.org Fri Nov 8 23:10:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:12 +0100 (CET) Subject: [monitoring-plugins] check_mysql: delare file local variables static Message-ID: <20241108221012.8D5B52000125@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 458af516886dc6e6373734f4c5b48ea0ffa7e987 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:32:45 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=458af51 check_mysql: delare file local variables static --- plugins/check_mysql.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 1f0b709..8a73772 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -45,23 +45,23 @@ const char *email = "devel at monitoring-plugins.org"; #include #include -char *db_user = NULL; -char *db_host = NULL; -char *db_socket = NULL; -char *db_pass = NULL; -char *db = NULL; -char *ca_cert = NULL; -char *ca_dir = NULL; -char *cert = NULL; -char *key = NULL; -char *ciphers = NULL; -bool ssl = false; -char *opt_file = NULL; -char *opt_group = NULL; -unsigned int db_port = MYSQL_PORT; -bool check_slave = false; -bool ignore_auth = false; -int verbose = 0; +static char *db_user = NULL; +static char *db_host = NULL; +static char *db_socket = NULL; +static char *db_pass = NULL; +static char *db = NULL; +static char *ca_cert = NULL; +static char *ca_dir = NULL; +static char *cert = NULL; +static char *key = NULL; +static char *ciphers = NULL; +static bool ssl = false; +static char *opt_file = NULL; +static char *opt_group = NULL; +static unsigned int db_port = MYSQL_PORT; +static bool check_slave = false; +static bool ignore_auth = false; +static int verbose = 0; static double warning_time = 0; static double critical_time = 0; @@ -91,11 +91,11 @@ static const char *metric_counter[LENGTH_METRIC_COUNTER] = { #define MYSQLDUMP_THREADS_QUERY "SELECT COUNT(1) mysqldumpThreads FROM information_schema.processlist WHERE info LIKE 'SELECT /*!40001 SQL_NO_CACHE */%'" -thresholds *my_threshold = NULL; +static thresholds *my_threshold = NULL; -int process_arguments (int, char **); -int validate_arguments (void); -void print_help (void); +static int process_arguments (int, char **); +static int validate_arguments (void); +static void print_help (void); void print_usage (void); int From git at monitoring-plugins.org Fri Nov 8 23:10:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:12 +0100 (CET) Subject: [monitoring-plugins] check_nt: delare file local variables static Message-ID: <20241108221012.A1E942000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: c7124379cd4e70d91e9af6eec4cf414849dc77d7 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:34:24 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=c712437 check_nt: delare file local variables static --- plugins/check_nt.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/plugins/check_nt.c b/plugins/check_nt.c index 413aad6..dec0b66 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c @@ -59,26 +59,25 @@ enum { PORT = 1248 }; -char *server_address = NULL; -char *volume_name = NULL; -int server_port = PORT; -char *value_list = NULL; -char *req_password = NULL; -unsigned long lvalue_list[MAX_VALUE_LIST]; -unsigned long warning_value = 0L; -unsigned long critical_value = 0L; -bool check_warning_value = false; -bool check_critical_value = false; -enum checkvars vars_to_check = CHECK_NONE; -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); -bool strtoularray(unsigned long *array, char *string, const char *delim); -void print_help(void); +static char *server_address = NULL; +static int server_port = PORT; +static char *value_list = NULL; +static char *req_password = NULL; +static unsigned long lvalue_list[MAX_VALUE_LIST]; +static unsigned long warning_value = 0L; +static unsigned long critical_value = 0L; +static bool check_warning_value = false; +static bool check_critical_value = false; +static enum checkvars vars_to_check = CHECK_NONE; +static bool show_all = false; + +static char recv_buffer[MAX_INPUT_BUFFER]; + +static void fetch_data(const char *address, int port, const char *sendb); +static int process_arguments(int /*argc*/, char ** /*argv*/); +static void preparelist(char *string); +static bool strtoularray(unsigned long *array, char *string, const char *delim); +static void print_help(void); void print_usage(void); int main(int argc, char **argv) { From git at monitoring-plugins.org Fri Nov 8 23:10:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:12 +0100 (CET) Subject: [monitoring-plugins] check_ntp: delare file local variables static Message-ID: <20241108221012.B76472000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: e3efbb796a58e02eceeef2e12b1f159d687a1b2b Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:35:27 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=e3efbb7 check_ntp: delare file local variables static --- plugins/check_ntp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index 55a4946..d33f878 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c @@ -47,10 +47,10 @@ static bool do_jitter = false; static char *jwarn="5000"; static char *jcrit="10000"; -int process_arguments (int, char **); -thresholds *offset_thresholds = NULL; -thresholds *jitter_thresholds = NULL; -void print_help (void); +static int process_arguments (int /*argc*/, char ** /*argv*/); +static thresholds *offset_thresholds = NULL; +static thresholds *jitter_thresholds = NULL; +static void print_help (void); void print_usage (void); /* number of times to perform each request to get a good average. */ From git at monitoring-plugins.org Fri Nov 8 23:10:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:12 +0100 (CET) Subject: [monitoring-plugins] check_nwstat: delare file local variables static Message-ID: <20241108221012.CFC222000126@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 5130e5b0d3591866488bd03b00ca383cd7674b3c Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:36:41 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=5130e5b check_nwstat: delare file local variables static --- plugins/check_nwstat.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index 3af6360..176dfbc 100644 --- a/plugins/check_nwstat.c +++ b/plugins/check_nwstat.c @@ -89,30 +89,30 @@ enum { PORT = 9999 }; -char *server_address = NULL; -char *volume_name = NULL; -char *nlm_name = NULL; -char *nrmp_name = NULL; -char *nrmm_name = NULL; -char *nrms_name = NULL; -char *nss1_name = NULL; -char *nss2_name = NULL; -char *nss3_name = NULL; -char *nss4_name = NULL; -char *nss5_name = NULL; -char *nss6_name = NULL; -char *nss7_name = NULL; -int server_port = PORT; -unsigned long warning_value = 0L; -unsigned long critical_value = 0L; -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; - -int process_arguments(int, char **); -void print_help(void); +static char *server_address = NULL; +static char *volume_name = NULL; +static char *nlm_name = NULL; +static char *nrmp_name = NULL; +static char *nrmm_name = NULL; +static char *nrms_name = NULL; +static char *nss1_name = NULL; +static char *nss2_name = NULL; +static char *nss3_name = NULL; +static char *nss4_name = NULL; +static char *nss5_name = NULL; +static char *nss6_name = NULL; +static char *nss7_name = NULL; +static int server_port = PORT; +static unsigned long warning_value = 0L; +static unsigned long critical_value = 0L; +static bool check_warning_value = false; +static bool check_critical_value = false; +static bool check_netware_version = false; +static enum checkvar vars_to_check = NONE; +static int sap_number = -1; + +static int process_arguments(int /*argc*/, char ** /*argv*/); +static void print_help(void); void print_usage(void); int main(int argc, char **argv) { From git at monitoring-plugins.org Fri Nov 8 23:10:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:12 +0100 (CET) Subject: [monitoring-plugins] check_procs: delare file local variables static Message-ID: <20241108221012.E541E2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 99bb7dd0f8f6962e12a3b0e4cd8bab0ebb278f0f Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:39:08 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=99bb7dd check_procs: delare file local variables static --- plugins/check_procs.c | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 5777ba0..53c93c0 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -51,17 +51,17 @@ const char *email = "devel at monitoring-plugins.org"; #include #endif -int process_arguments (int, char **); -int validate_arguments (void); -int convert_to_seconds (char *); -void print_help (void); +static int process_arguments (int /*argc*/, char ** /*argv*/); +static int validate_arguments (void); +static int convert_to_seconds (char * /*etime*/); +static void print_help (void); void print_usage (void); -char *warning_range = NULL; -char *critical_range = NULL; -thresholds *procs_thresholds = NULL; +static char *warning_range = NULL; +static char *critical_range = NULL; +static thresholds *procs_thresholds = NULL; -int options = 0; /* bitmask of filter criteria to test against */ +static int options = 0; /* bitmask of filter criteria to test against */ #define ALL 1 #define STAT 2 #define PPID 4 @@ -89,27 +89,25 @@ enum metric { }; enum metric metric = METRIC_PROCS; -int verbose = 0; -int uid; -pid_t ppid; -int vsz; -int rss; -float pcpu; -char *statopts; -char *prog; -char *exclude_progs; -char **exclude_progs_arr = NULL; -char exclude_progs_counter = 0; -char *args; -char *input_filename = NULL; -regex_t re_args; -char *fmt; -char *fails; -char tmp[MAX_INPUT_BUFFER]; -int kthread_filter = 0; -int usepid = 0; /* whether to test for pid or /proc/pid/exe */ - -FILE *ps_input = NULL; +static int verbose = 0; +static int uid; +static pid_t ppid; +static int vsz; +static int rss; +static float pcpu; +static char *statopts; +static char *prog; +static char *exclude_progs; +static char **exclude_progs_arr = NULL; +static char exclude_progs_counter = 0; +static char *args; +static char *input_filename = NULL; +static regex_t re_args; +static char *fmt; +static char *fails; +static char tmp[MAX_INPUT_BUFFER]; +static int kthread_filter = 0; +static int usepid = 0; /* whether to test for pid or /proc/pid/exe */ static int stat_exe (const pid_t pid, struct stat *buf) { From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] check_procs: use proper escape for % Message-ID: <20241108221013.02C942000125@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 54042ac52f7883cf45176f084f63f22b3fdc235c Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:39:44 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=54042ac check_procs: use proper escape for % --- plugins/check_procs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 53c93c0..1d78cce 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -832,7 +832,7 @@ be the total number of running processes\n\n")); printf (" %s\n", "check_procs -w 50000 -c 100000 --metric=VSZ"); printf (" %s\n\n", _("Alert if VSZ of any processes over 50K or 100K")); 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 (" %s\n", _("Alert if CPU of any processes over 10%% or 20%%")); printf (UT_SUPPORT); } From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] check_ide_smart: fix misleading static declaration Message-ID: <20241108221013.15603200014F@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 0c592fa860367099924841cf390ea9f580a922ec Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:44:21 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=0c592fa check_ide_smart: fix misleading static declaration --- plugins/check_ide_smart.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 381dbd8..9640ef7 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c @@ -113,12 +113,10 @@ typedef struct values_s { __u8 checksum; } __attribute__((packed)) values_t; -struct { +static struct { __u8 value; char *text; -} - -static offline_status_text[] = {{0x00, "NeverStarted"}, {0x02, "Completed"}, {0x04, "Suspended"}, +} offline_status_text[] = {{0x00, "NeverStarted"}, {0x02, "Completed"}, {0x04, "Suspended"}, {0x05, "Aborted"}, {0x06, "Failed"}, {0, 0}}; static struct { From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] check_radius: delare file local variables static Message-ID: <20241108221013.2DC332000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 6644a81c5795f71ec8acd60da76f8cef052e5ad5 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:45:53 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=6644a81 check_radius: delare file local variables static --- plugins/check_radius.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 8ed19e5..d9ff8fa 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c @@ -46,8 +46,8 @@ const char *email = "devel at monitoring-plugins.org"; #include #endif -int process_arguments (int, char **); -void print_help (void); +static int process_arguments (int /*argc*/, char ** /*argv*/); +static void print_help (void); void print_usage (void); #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) @@ -78,22 +78,22 @@ void print_usage (void); #define REJECT_RC BADRESP_RC #endif -int my_rc_read_config(char *); +static int my_rc_read_config(char * /*a*/); #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) -rc_handle *rch = NULL; +static rc_handle *rch = NULL; #endif -char *server = NULL; -char *username = NULL; -char *password = NULL; -char *nasid = NULL; -char *nasipaddress = NULL; -char *expect = NULL; -char *config_file = NULL; -unsigned short port = PW_AUTH_UDP_PORT; -int retries = 1; -bool verbose = false; +static char *server = NULL; +static char *username = NULL; +static char *password = NULL; +static char *nasid = NULL; +static char *nasipaddress = NULL; +static char *expect = NULL; +static char *config_file = NULL; +static unsigned short port = PW_AUTH_UDP_PORT; +static int retries = 1; +static bool verbose = false; /****************************************************************************** From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] check_ups: delare file local variables static Message-ID: <20241108221013.7F2092000125@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 6848e618c0eb54563707bf473fbd8c4acf6d2b2d Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:49:37 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=6848e61 check_ups: delare file local variables static --- plugins/check_ups.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/check_ups.c b/plugins/check_ups.c index adb7ab8..5dfa72a 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -97,13 +97,13 @@ ups_config ups_config_init(void) { } // Forward declarations -int determine_status(ups_config *, int *supported_options); -int get_ups_variable(const char *, char *, const ups_config config); +static int determine_status(ups_config * /*config*/, int *supported_options); +static int get_ups_variable(const char * /*varname*/, char * /*buf*/, ups_config config); -int process_arguments(int, char **, ups_config *); -int validate_arguments(ups_config); -void print_help(void); -void print_usage(void); +static int process_arguments(int /*argc*/, char ** /*argv*/, ups_config * /*config*/); +static int validate_arguments(ups_config /*config*/); +static void print_help(void); +static void print_usage(void); int main(int argc, char **argv) { setlocale(LC_ALL, ""); From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] check_smtp: delare file local variables static Message-ID: <20241108221013.5B9F22000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: d330b975b3c580c385c736c8a52209919de1d582 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:47:32 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=d330b97 check_smtp: delare file local variables static --- plugins/check_smtp.c | 94 +++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index bc17528..c73693c 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -64,61 +64,59 @@ enum { #define EHLO_SUPPORTS_STARTTLS 1 -int process_arguments (int, char **); -int validate_arguments (void); -void print_help (void); +static int process_arguments (int, char **); +static int validate_arguments (void); +static void print_help (void); void print_usage (void); -void smtp_quit(void); -int recvline(char *, size_t); -int recvlines(char *, size_t); -int my_close(void); +static void smtp_quit(void); +static int recvline(char *, size_t); +static int recvlines(char *, size_t); +static int my_close(void); #include "regex.h" -char regex_expect[MAX_INPUT_BUFFER] = ""; -regex_t preg; -regmatch_t pmatch[10]; -char timestamp[20] = ""; -char errbuf[MAX_INPUT_BUFFER]; -int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; -int eflags = 0; -int errcode, excode; - -int server_port = SMTP_PORT; -int server_port_option = 0; -char *server_address = NULL; -char *server_expect = NULL; -char *mail_command = NULL; -char *from_arg = NULL; -int send_mail_from=0; -int ncommands=0; -int command_size=0; -int nresponses=0; -int response_size=0; -char **commands = NULL; -char **responses = NULL; -char *authtype = NULL; -char *authuser = NULL; -char *authpass = NULL; -double warning_time = 0; -bool check_warning_time = false; -double critical_time = 0; -bool check_critical_time = false; -int verbose = 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]; +static regex_t preg; +static regmatch_t pmatch[10]; +static char errbuf[MAX_INPUT_BUFFER]; +static int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; +static int eflags = 0; +static int errcode, excode; + +static int server_port = SMTP_PORT; +static int server_port_option = 0; +static char *server_address = NULL; +static char *server_expect = NULL; +static char *mail_command = NULL; +static char *from_arg = NULL; +static int send_mail_from=0; +static int ncommands=0; +static int command_size=0; +static int nresponses=0; +static int response_size=0; +static char **commands = NULL; +static char **responses = NULL; +static char *authtype = NULL; +static char *authuser = NULL; +static char *authpass = NULL; +static double warning_time = 0; +static bool check_warning_time = false; +static double critical_time = 0; +static bool check_critical_time = false; +static int verbose = 0; +static bool use_ssl = false; +static bool use_starttls = false; +static bool use_sni = false; +static bool use_proxy_prefix = false; +static bool use_ehlo = false; +static bool use_lhlo = false; +static bool ssl_established = false; +static char *localhostname = NULL; +static int sd; +static char buffer[MAX_INPUT_BUFFER]; enum { TCP_PROTOCOL = 1, UDP_PROTOCOL = 2, }; -bool ignore_send_quit_failure = false; +static bool ignore_send_quit_failure = false; int From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] check_smtp: delare previously missed file local ... Message-ID: <20241108221013.A5FD32000126@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: b830c7a3e07ea5cd7b8253c4c9fadecd9ad621b6 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:51:14 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b830c7a check_smtp: delare previously missed file local variables static --- plugins/check_smtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index c73693c..e6369e6 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -40,8 +40,8 @@ const char *email = "devel at monitoring-plugins.org"; #include #ifdef HAVE_SSL -bool check_cert = false; -int days_till_exp_warn, days_till_exp_crit; +static bool check_cert = false; +static 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)) #else /* ifndef HAVE_SSL */ From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] check_ups: do not declare print_usage static Message-ID: <20241108221013.C50892000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: bd5608b9fc5d2b3db9f3c9026d279f8928ab4d0c Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Fri Nov 8 12:51:39 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=bd5608b check_ups: do not declare print_usage static --- plugins/check_ups.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 5dfa72a..526a29d 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -103,7 +103,7 @@ static int get_ups_variable(const char * /*varname*/, char * /*buf*/, ups_config static int process_arguments(int /*argc*/, char ** /*argv*/, ups_config * /*config*/); static int validate_arguments(ups_config /*config*/); static void print_help(void); -static void print_usage(void); +void print_usage(void); int main(int argc, char **argv) { setlocale(LC_ALL, ""); From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (GitHub) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] Merge branch 'master' into cleanup/leftovers Message-ID: <20241108221013.D790D200014F@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: e8905c9e9c96b5b57f64edf0d5c7429aa39341b8 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Fri Nov 8 13:55:57 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=e8905c9 Merge branch 'master' into cleanup/leftovers --- From git at monitoring-plugins.org Fri Nov 8 23:10:13 2024 From: git at monitoring-plugins.org (GitHub) Date: Fri, 8 Nov 2024 23:10:13 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2043 from ... Message-ID: <20241108221013.EB1FC2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: b370072a5a1e21876abf8cf95f4622c02565ae07 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Fri Nov 8 23:04:19 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b370072 Merge pull request #2043 from RincewindsHat/cleanup/leftovers Cleanup/leftovers --- From git at monitoring-plugins.org Sat Nov 9 11:40:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Sat, 9 Nov 2024 11:40:12 +0100 (CET) Subject: [monitoring-plugins] Fix argument order of calloc on several occasions Message-ID: <20241109104012.53B3E2000122@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 6eb5be9e30b23035632b674f6b46c18313cde63b Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Sat Nov 9 10:49:21 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=6eb5be9 Fix argument order of calloc on several occasions --- lib/utils_cmd.c | 2 +- plugins/check_tcp.c | 2 +- plugins/runcmd.c | 2 +- plugins/utils.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c index 416cf82..18350ac 100644 --- a/lib/utils_cmd.c +++ b/lib/utils_cmd.c @@ -290,7 +290,7 @@ int cmd_run(const char *cmdstring, output *out, output *err, int flags) { /* each arg must be whitespace-separated, so args can be a maximum * of (len / 2) + 1. We add 1 extra to the mix for NULL termination */ argc = (cmdlen >> 1) + 2; - argv = calloc(sizeof(char *), argc); + argv = calloc((size_t)argc, sizeof(char *)); if (argv == NULL) { printf("%s\n", _("Could not malloc argv array in popen()")); diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index c13ac76..49ad096 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -119,7 +119,7 @@ int main(int argc, char **argv) { /* set up a reasonable buffer at first (will be realloc()'ed if * user specifies other options) */ - server_expect = calloc(sizeof(char *), 2); + server_expect = calloc(2, sizeof(char *)); /* determine defaults for this service's protocol */ if (!strncmp(SERVICE, "UDP", 3)) { diff --git a/plugins/runcmd.c b/plugins/runcmd.c index 2e53dc0..7484314 100644 --- a/plugins/runcmd.c +++ b/plugins/runcmd.c @@ -130,7 +130,7 @@ static int np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr) { /* each arg must be whitespace-separated, so args can be a maximum * of (len / 2) + 1. We add 1 extra to the mix for NULL termination */ argc = (cmdlen >> 1) + 2; - argv = calloc(sizeof(char *), argc); + argv = calloc(argc, sizeof(char *)); if (argv == NULL) { printf("%s\n", _("Could not malloc argv array in popen()")); diff --git a/plugins/utils.c b/plugins/utils.c index f11db73..6d366e3 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -185,7 +185,7 @@ bool is_percentage_expression(const char str[]) { return false; } - char *foo = calloc(sizeof(char), len + 1); + char *foo = calloc(len + 1, sizeof(char)); if (!foo) { die(STATE_UNKNOWN, _("calloc failed \n")); From git at monitoring-plugins.org Sat Nov 9 11:40:12 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Sat, 9 Nov 2024 11:40:12 +0100 (CET) Subject: [monitoring-plugins] Fix false formatting directive in printf Message-ID: <20241109104012.665992000124@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: f1dae440753b7d36346b0e0a516f69b3ff5d1546 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Sat Nov 9 11:26:09 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=f1dae44 Fix false formatting directive in printf --- plugins/check_curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 1d27da2..8ea73ce 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -525,7 +525,7 @@ int check_http(void) { // 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) { - snprintf(msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %d"), server_address, res, + snprintf(msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"), server_address, res, gai_strerror(res)); die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); } From git at monitoring-plugins.org Sat Nov 9 11:40:12 2024 From: git at monitoring-plugins.org (GitHub) Date: Sat, 9 Nov 2024 11:40:12 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2045 from ... Message-ID: <20241109104012.77EA22000125@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: ed52a7dbb7997c8fa9779e89fd2012eae85b2ce0 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Sat Nov 9 11:31:48 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=ed52a7d Merge pull request #2045 from RincewindsHat/fix/calloc_argument_order Fix argument order of calloc on several occasions --- From git at monitoring-plugins.org Sat Nov 9 11:40:12 2024 From: git at monitoring-plugins.org (GitHub) Date: Sat, 9 Nov 2024 11:40:12 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2046 from ... Message-ID: <20241109104012.8A7842000126@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 5d7d620903a2fb40f8cd3140081bfb7ceaf125d5 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Sat Nov 9 11:37:46 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=5d7d620 Merge pull request #2046 from RincewindsHat/fix/format_string Fix false formatting directive in printf --- From git at monitoring-plugins.org Wed Nov 27 15:00:13 2024 From: git at monitoring-plugins.org (Lorenz Kästle) Date: Wed, 27 Nov 2024 15:00:13 +0100 (CET) Subject: [monitoring-plugins] check_curl: update TLS notification notes Message-ID: <20241127140013.1FC59200014F@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 8de299308c52d083b893a87e6924405b652f1f7b Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Date: Wed Nov 27 14:22:02 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=8de2993 check_curl: update TLS notification notes --- plugins/check_curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 8ea73ce..ef7d4ee 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -1912,7 +1912,7 @@ void print_help(void) { printf(" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents")); printf(" %s\n", _("auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,")); printf(" %s\n", _("1.2 = TLSv1.2, 1.3 = TLSv1.3). With a '+' suffix, newer versions are also accepted.")); - printf(" %s\n", _("Note: SSLv2 and SSLv3 are deprecated and are usually disabled in libcurl")); + printf(" %s\n", _("Note: SSLv2, SSLv3, TLSv1.0 and TLSv1.1 are deprecated and are usually disabled in libcurl")); printf(" %s\n", "--sni"); printf(" %s\n", _("Enable SSL/TLS hostname extension support (SNI)")); # if LIBCURL_VERSION_NUM >= 0x071801 From git at monitoring-plugins.org Wed Nov 27 15:00:13 2024 From: git at monitoring-plugins.org (GitHub) Date: Wed, 27 Nov 2024 15:00:13 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2050 from ... Message-ID: <20241127140013.2CB672000154@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 5a5d7537a2bda2bfca4b89d217c0835bc6d74396 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Wed Nov 27 14:58:09 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=5a5d753 Merge pull request #2050 from RincewindsHat/fix/ssl_version_documentation check_curl: update TLS notification notes, mention deprecation of TLSv1.0 and TLSv1.1 --- From git at monitoring-plugins.org Thu Nov 28 09:10:12 2024 From: git at monitoring-plugins.org (Sven Nierlein) Date: Thu, 28 Nov 2024 09:10:12 +0100 (CET) Subject: [monitoring-plugins] check_icmp: clang-format Message-ID: <20241128081012.4473E200014F@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: eb9f9cf8c47fc37553cc17d349a47c9dab0a5e8b Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: Sven Nierlein Date: Wed Nov 27 15:19:21 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=eb9f9cf check_icmp: clang-format --- plugins-root/check_icmp.c | 294 +++++++++++++++++++++++++++++----------------- 1 file changed, 188 insertions(+), 106 deletions(-) diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 960ab8f..ea17b3a 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -272,8 +272,9 @@ static void crash(const char *fmt, ...) { vprintf(fmt, ap); va_end(ap); - if (errno) + if (errno) { printf(": %s", strerror(errno)); + } puts(""); exit(3); @@ -282,8 +283,9 @@ static void crash(const char *fmt, ...) { static const char *get_icmp_error_msg(unsigned char icmp_type, unsigned char icmp_code) { const char *msg = "unreachable"; - if (debug > 1) + if (debug > 1) { printf("get_icmp_error_msg(%u, %u)\n", icmp_type, icmp_code); + } switch (icmp_type) { case ICMP_UNREACH: switch (icmp_code) { @@ -392,8 +394,9 @@ static int handle_random_icmp(unsigned char *packet, struct sockaddr_storage *ad return 0; } - if (debug) + if (debug) { printf("handle_random_icmp(%p, %p)\n", (void *)&p, (void *)addr); + } /* only handle a few types, since others can't possibly be replies to * us in a sane network (if it is anyway, it will be counted as lost @@ -413,8 +416,9 @@ static int handle_random_icmp(unsigned char *packet, struct sockaddr_storage *ad * to RFC 792). If it isn't, just ignore it */ memcpy(&sent_icmp, packet + 28, sizeof(sent_icmp)); if (sent_icmp.icmp_type != ICMP_ECHO || ntohs(sent_icmp.icmp_id) != pid || ntohs(sent_icmp.icmp_seq) >= targets * packets) { - if (debug) + if (debug) { printf("Packet is no response to a packet we sent\n"); + } return 0; } @@ -429,8 +433,9 @@ static int handle_random_icmp(unsigned char *packet, struct sockaddr_storage *ad icmp_lost++; host->icmp_lost++; /* don't spend time on lost hosts any more */ - if (host->flags & FLAG_LOST_CAUSE) + if (host->flags & FLAG_LOST_CAUSE) { return 0; + } /* source quench means we're sending too fast, so increase the * interval and mark this packet lost */ @@ -488,10 +493,11 @@ int main(int argc, char **argv) { /* get calling name the old-fashioned way for portability instead * of relying on the glibc-ism __progname */ ptr = strrchr(argv[0], '/'); - if (ptr) + if (ptr) { progname = &ptr[1]; - else + } else { progname = argv[0]; + } /* now set defaults. Use progname to set them initially (allows for * superfast check_host program when target host is up */ @@ -534,10 +540,12 @@ int main(int argc, char **argv) { /* support "--help" and "--version" */ if (argc == 2) { - if (!strcmp(argv[1], "--help")) + if (!strcmp(argv[1], "--help")) { strcpy(argv[1], "-h"); - if (!strcmp(argv[1], "--version")) + } + if (!strcmp(argv[1], "--version")) { strcpy(argv[1], "-V"); + } } /* Parse protocol arguments first */ @@ -545,14 +553,16 @@ int main(int argc, char **argv) { while ((arg = getopt(argc, argv, opts_str)) != EOF) { switch (arg) { case '4': - if (address_family != -1) + if (address_family != -1) { crash("Multiple protocol versions not supported"); + } address_family = AF_INET; break; case '6': #ifdef USE_IPV6 - if (address_family != -1) + if (address_family != -1) { crash("Multiple protocol versions not supported"); + } address_family = AF_INET6; #else usage(_("IPv6 support not available\n")); @@ -579,9 +589,10 @@ int main(int argc, char **argv) { if (size >= (sizeof(struct icmp) + sizeof(struct icmp_ping_data)) && size < MAX_PING_DATA) { icmp_data_size = size; icmp_pkt_size = size + ICMP_MINLEN; - } else + } else { usage_va("ICMP data length must be between: %lu and %lu", sizeof(struct icmp) + sizeof(struct icmp_ping_data), MAX_PING_DATA - 1); + } break; case 'i': pkt_interval = get_timevar(optarg); @@ -601,8 +612,9 @@ int main(int argc, char **argv) { break; case 't': timeout = strtoul(optarg, NULL, 0); - if (!timeout) + if (!timeout) { timeout = 10; + } break; case 'H': add_target(optarg); @@ -709,18 +721,22 @@ int main(int argc, char **argv) { default: crash("Address family not supported"); } - if ((icmp_sock = socket(address_family, SOCK_RAW, icmp_proto)) != -1) + if ((icmp_sock = socket(address_family, SOCK_RAW, icmp_proto)) != -1) { sockets |= HAVE_ICMP; - else + } else { icmp_sockerrno = errno; + } - if (source_ip) + if (source_ip) { set_source_ip(source_ip); + } #ifdef SO_TIMESTAMP - if (setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on))) - if (debug) + if (setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on))) { + if (debug) { printf("Warning: no SO_TIMESTAMP support\n"); + } + } #endif // SO_TIMESTAMP /* now drop privileges (no effect if not setsuid or geteuid() == 0) */ @@ -746,16 +762,18 @@ int main(int argc, char **argv) { /* return -1; */ /* } */ } - if (!ttl) + if (!ttl) { ttl = 64; + } if (icmp_sock) { result = setsockopt(icmp_sock, SOL_IP, IP_TTL, &ttl, sizeof(ttl)); if (debug) { - if (result == -1) + if (result == -1) { printf("setsockopt failed\n"); - else + } else { printf("ttl set to %u\n", ttl); + } } } @@ -763,18 +781,24 @@ int main(int argc, char **argv) { * (nothing will break if they do), but some anal plugin maintainer * will probably add some printf() thing here later, so it might be * best to at least show them where to do it. ;) */ - if (warn.pl > crit.pl) + if (warn.pl > crit.pl) { warn.pl = crit.pl; - if (warn.rta > crit.rta) + } + if (warn.rta > crit.rta) { warn.rta = crit.rta; - if (warn_down > crit_down) + } + if (warn_down > crit_down) { crit_down = warn_down; - if (warn.jitter > crit.jitter) + } + if (warn.jitter > crit.jitter) { crit.jitter = warn.jitter; - if (warn.mos < crit.mos) + } + if (warn.mos < crit.mos) { warn.mos = crit.mos; - if (warn.score < crit.score) + } + if (warn.score < crit.score) { warn.score = crit.score; + } #ifdef HAVE_SIGACTION sig_action.sa_sigaction = NULL; @@ -791,8 +815,9 @@ int main(int argc, char **argv) { signal(SIGTERM, finish); signal(SIGALRM, finish); #endif /* HAVE_SIGACTION */ - if (debug) + if (debug) { printf("Setting alarm timeout to %u seconds\n", timeout); + } alarm(timeout); /* make sure we don't wait any longer than necessary */ @@ -863,11 +888,13 @@ static void run_checks(void) { for (i = 0; i < packets; i++) { for (t = 0; t < targets; t++) { /* don't send useless packets */ - if (!targets_alive) + if (!targets_alive) { finish(0); + } if (table[t]->flags & FLAG_LOST_CAUSE) { - if (debug) + if (debug) { printf("%s is a lost cause. not sending any more\n", table[t]->name); + } continue; } @@ -886,15 +913,17 @@ static void run_checks(void) { printf("time_passed: %u final_wait: %u max_completion_time: %llu\n", time_passed, final_wait, max_completion_time); } if (time_passed > max_completion_time) { - if (debug) + if (debug) { printf("Time passed. Finishing up\n"); + } finish(0); } /* catch the packets that might come in within the timeframe, but * haven't yet */ - if (debug) + if (debug) { printf("Waiting for %u micro-seconds (%0.3f msecs)\n", final_wait, (float)final_wait / 1000); + } wait_for_reply(icmp_sock, final_wait); } } @@ -955,8 +984,9 @@ static int wait_for_reply(int sock, u_int t) { continue; /* timeout for this one, so keep trying */ } if (n < 0) { - if (debug) + if (debug) { printf("recvfrom_wto() returned errors\n"); + } free(packet.buf); return n; } @@ -1003,8 +1033,9 @@ static int wait_for_reply(int sock, u_int t) { ntohs(packet.icp->icmp_seq) >= targets * packets)) || (address_family == PF_INET6 && (ntohs(packet.icp6->icmp6_id) != pid || packet.icp6->icmp6_type != ICMP6_ECHO_REPLY || ntohs(packet.icp6->icmp6_seq) >= targets * packets))) { - if (debug > 2) + if (debug > 2) { printf("not a proper ICMP_ECHOREPLY\n"); + } handle_random_icmp(buf + hlen, &resp_addr); continue; } @@ -1012,15 +1043,17 @@ static int wait_for_reply(int sock, u_int t) { /* this is indeed a valid response */ if (address_family == PF_INET) { memcpy(&data, packet.icp->icmp_data, sizeof(data)); - if (debug > 2) + if (debug > 2) { printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n", (unsigned long)sizeof(data), ntohs(packet.icp->icmp_id), ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum); + } host = table[ntohs(packet.icp->icmp_seq) / packets]; } else { memcpy(&data, &packet.icp6->icmp6_dataun.icmp6_un_data8[4], sizeof(data)); - if (debug > 2) + if (debug > 2) { printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n", (unsigned long)sizeof(data), ntohs(packet.icp6->icmp6_id), ntohs(packet.icp6->icmp6_seq), packet.icp6->icmp6_cksum); + } host = table[ntohs(packet.icp6->icmp6_seq) / packets]; } @@ -1051,8 +1084,9 @@ static int wait_for_reply(int sock, u_int t) { } /* Check if packets in order */ - if (host->last_icmp_seq >= packet.icp->icmp_seq) + if (host->last_icmp_seq >= packet.icp->icmp_seq) { host->order_status = STATE_CRITICAL; + } } host->last_tdiff = tdiff; @@ -1061,10 +1095,12 @@ static int wait_for_reply(int sock, u_int t) { host->time_waited += tdiff; host->icmp_recv++; icmp_recv++; - if (tdiff > (unsigned int)host->rtmax) + if (tdiff > (unsigned int)host->rtmax) { host->rtmax = tdiff; - if (tdiff < (unsigned int)host->rtmin) + } + if (tdiff < (unsigned int)host->rtmin) { host->rtmin = tdiff; + } if (debug) { char address[INET6_ADDRSTRLEN]; @@ -1142,9 +1178,10 @@ static int send_icmp_ping(int sock, struct rta_host *host) { icp->icmp_seq = htons(host->id++); icp->icmp_cksum = icmp_checksum((uint16_t *)buf, (size_t)icmp_pkt_size); - if (debug > 2) + if (debug > 2) { printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n", (unsigned long)sizeof(data), ntohs(icp->icmp_id), ntohs(icp->icmp_seq), icp->icmp_cksum, host->name); + } } else { struct icmp6_hdr *icp6 = (struct icmp6_hdr *)buf; addrlen = sizeof(struct sockaddr_in6); @@ -1216,8 +1253,9 @@ static int recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr * #endif if (!*timo) { - if (debug) + if (debug) { printf("*timo is not\n"); + } return 0; } @@ -1230,13 +1268,15 @@ static int recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr * errno = 0; gettimeofday(&then, &tz); n = select(sock + 1, &rd, &wr, NULL, &to); - if (n < 0) + if (n < 0) { crash("select() in recvfrom_wto"); + } gettimeofday(&now, &tz); *timo = get_timevaldiff(&then, &now); - if (!n) + if (!n) { return 0; /* timeout */ + } slen = sizeof(struct sockaddr_storage); @@ -1281,15 +1321,19 @@ static void finish(int sig) { double R; alarm(0); - if (debug > 1) + if (debug > 1) { printf("finish(%d) called\n", sig); + } - if (icmp_sock != -1) + if (icmp_sock != -1) { close(icmp_sock); - if (udp_sock != -1) + } + if (udp_sock != -1) { close(udp_sock); - if (tcp_sock != -1) + } + if (tcp_sock != -1) { close(tcp_sock); + } if (debug) { printf("icmp_sent: %u icmp_recv: %u icmp_lost: %u\n", icmp_sent, icmp_recv, icmp_lost); @@ -1310,8 +1354,9 @@ static void finish(int sig) { rta = 0; status = STATE_CRITICAL; /* up the down counter if not already counted */ - if (!(host->flags & FLAG_LOST_CAUSE) && targets_alive) + if (!(host->flags & FLAG_LOST_CAUSE) && targets_alive) { targets_down++; + } } else { pl = ((host->icmp_sent - host->icmp_recv) * 100) / host->icmp_sent; rta = (double)host->time_waited / host->icmp_recv; @@ -1444,26 +1489,30 @@ static void finish(int sig) { } /* this is inevitable */ - if (!targets_alive) + if (!targets_alive) { status = STATE_CRITICAL; + } if (min_hosts_alive > -1) { - if (hosts_ok >= min_hosts_alive) + if (hosts_ok >= min_hosts_alive) { status = STATE_OK; - else if ((hosts_ok + hosts_warn) >= min_hosts_alive) + } else if ((hosts_ok + hosts_warn) >= min_hosts_alive) { status = STATE_WARNING; + } } printf("%s - ", status_string[status]); host = list; while (host) { - if (debug) + if (debug) { puts(""); + } if (i) { - if (i < targets) + if (i < targets) { printf(" :: "); - else + } else { printf("\n"); + } } i++; if (!host->icmp_recv) { @@ -1481,55 +1530,61 @@ static void finish(int sig) { printf("%s", host->name); /* rta text output */ if (rta_mode) { - if (status == STATE_OK) + if (status == STATE_OK) { printf(" rta %0.3fms", host->rta / 1000); - else if (status == STATE_WARNING && host->rta_status == status) + } else if (status == STATE_WARNING && host->rta_status == status) { printf(" rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)warn.rta / 1000); - else if (status == STATE_CRITICAL && host->rta_status == status) + } else if (status == STATE_CRITICAL && host->rta_status == status) { printf(" rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)crit.rta / 1000); + } } /* pl text output */ if (pl_mode) { - if (status == STATE_OK) + if (status == STATE_OK) { printf(" lost %u%%", host->pl); - else if (status == STATE_WARNING && host->pl_status == status) + } else if (status == STATE_WARNING && host->pl_status == status) { printf(" lost %u%% > %u%%", host->pl, warn.pl); - else if (status == STATE_CRITICAL && host->pl_status == status) + } else if (status == STATE_CRITICAL && host->pl_status == status) { printf(" lost %u%% > %u%%", host->pl, crit.pl); + } } /* jitter text output */ if (jitter_mode) { - if (status == STATE_OK) + if (status == STATE_OK) { printf(" jitter %0.3fms", (float)host->jitter); - else if (status == STATE_WARNING && host->jitter_status == status) + } else if (status == STATE_WARNING && host->jitter_status == status) { printf(" jitter %0.3fms > %0.3fms", (float)host->jitter, warn.jitter); - else if (status == STATE_CRITICAL && host->jitter_status == status) + } else if (status == STATE_CRITICAL && host->jitter_status == status) { printf(" jitter %0.3fms > %0.3fms", (float)host->jitter, crit.jitter); + } } /* mos text output */ if (mos_mode) { - if (status == STATE_OK) + if (status == STATE_OK) { printf(" MOS %0.1f", (float)host->mos); - else if (status == STATE_WARNING && host->mos_status == status) + } else if (status == STATE_WARNING && host->mos_status == status) { printf(" MOS %0.1f < %0.1f", (float)host->mos, (float)warn.mos); - else if (status == STATE_CRITICAL && host->mos_status == status) + } else if (status == STATE_CRITICAL && host->mos_status == status) { printf(" MOS %0.1f < %0.1f", (float)host->mos, (float)crit.mos); + } } /* score text output */ if (score_mode) { - if (status == STATE_OK) + if (status == STATE_OK) { printf(" Score %u", (int)host->score); - else if (status == STATE_WARNING && host->score_status == status) + } else if (status == STATE_WARNING && host->score_status == status) { printf(" Score %u < %u", (int)host->score, (int)warn.score); - else if (status == STATE_CRITICAL && host->score_status == status) + } else if (status == STATE_CRITICAL && host->score_status == status) { printf(" Score %u < %u", (int)host->score, (int)crit.score); + } } /* order statis text output */ if (order_mode) { - if (status == STATE_OK) + if (status == STATE_OK) { printf(" Packets in order"); - else if (status == STATE_CRITICAL && host->order_status == status) + } else if (status == STATE_CRITICAL && host->order_status == status) { printf(" Packets out of order"); + } } } host = host->next; @@ -1542,8 +1597,9 @@ static void finish(int sig) { i = 0; host = list; while (host) { - if (debug) + if (debug) { puts(""); + } if (rta_mode) { if (host->pl < 100) { @@ -1593,17 +1649,19 @@ static void finish(int sig) { } if (min_hosts_alive > -1) { - if (hosts_ok >= min_hosts_alive) + if (hosts_ok >= min_hosts_alive) { status = STATE_OK; - else if ((hosts_ok + hosts_warn) >= min_hosts_alive) + } else if ((hosts_ok + hosts_warn) >= min_hosts_alive) { status = STATE_WARNING; + } } /* finish with an empty line */ puts(""); - if (debug) + if (debug) { printf("targets: %u, targets_alive: %u, hosts_ok: %u, hosts_warn: %u, min_hosts_alive: %i\n", targets, targets_alive, hosts_ok, hosts_warn, min_hosts_alive); + } exit(status); } @@ -1616,8 +1674,9 @@ static u_int get_timevaldiff(struct timeval *early, struct timeval *later) { gettimeofday(&now, &tz); later = &now; } - if (!early) + if (!early) { early = &prog_start; + } /* if early > later we return 0 so as to indicate a timeout */ if (early->tv_sec > later->tv_sec || (early->tv_sec == later->tv_sec && early->tv_usec > later->tv_usec)) { @@ -1634,10 +1693,11 @@ static int add_target_ip(char *arg, struct sockaddr_storage *in) { struct sockaddr_in *sin, *host_sin; struct sockaddr_in6 *sin6, *host_sin6; - if (address_family == AF_INET) + if (address_family == AF_INET) { sin = (struct sockaddr_in *)in; - else + } else { sin6 = (struct sockaddr_in6 *)in; + } /* disregard obviously stupid addresses * (I didn't find an ipv6 equivalent to INADDR_NONE) */ @@ -1654,8 +1714,9 @@ static int add_target_ip(char *arg, struct sockaddr_storage *in) { if ((address_family == AF_INET && host_sin->sin_addr.s_addr == sin->sin_addr.s_addr) || (address_family == AF_INET6 && host_sin6->sin6_addr.s6_addr == sin6->sin6_addr.s6_addr)) { - if (debug) + if (debug) { printf("Identical IP already exists. Not adding %s\n", arg); + } return -1; } host = host->next; @@ -1700,10 +1761,11 @@ static int add_target_ip(char *arg, struct sockaddr_storage *in) { host->score_status = 0; host->pl_status = 0; - if (!list) + if (!list) { list = cursor = host; - else + } else { cursor->next = host; + } cursor = host; targets++; @@ -1777,8 +1839,9 @@ static int add_target(char *arg) { /* this is silly, but it works */ if (mode == MODE_HOSTCHECK || mode == MODE_ALL) { - if (debug > 2) + if (debug > 2) { printf("mode: %d\n", mode); + } continue; } break; @@ -1793,10 +1856,12 @@ static void set_source_ip(char *arg) { memset(&src, 0, sizeof(src)); src.sin_family = address_family; - if ((src.sin_addr.s_addr = inet_addr(arg)) == INADDR_NONE) + if ((src.sin_addr.s_addr = inet_addr(arg)) == INADDR_NONE) { src.sin_addr.s_addr = get_ip_address(arg); - if (bind(icmp_sock, (struct sockaddr *)&src, sizeof(src)) == -1) + } + if (bind(icmp_sock, (struct sockaddr *)&src, sizeof(src)) == -1) { crash("Cannot bind to IP address %s", arg); + } } /* TODO: Move this to netutils.c and also change check_dhcp to use that. */ @@ -1811,8 +1876,9 @@ static in_addr_t get_ip_address(const char *ifname) { ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; - if (ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) + if (ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) { crash("Cannot determine IP address of interface %s", ifname); + } memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); #else @@ -1835,47 +1901,57 @@ static u_int get_timevar(const char *str) { u_int i, d; /* integer and decimal, respectively */ u_int factor = 1000; /* default to milliseconds */ - if (!str) + if (!str) { return 0; + } len = strlen(str); - if (!len) + if (!len) { return 0; + } /* unit might be given as ms|m (millisec), * us|u (microsec) or just plain s, for seconds */ p = '\0'; u = str[len - 1]; - if (len >= 2 && !isdigit((int)str[len - 2])) + if (len >= 2 && !isdigit((int)str[len - 2])) { p = str[len - 2]; - if (p && u == 's') + } + if (p && u == 's') { u = p; - else if (!p) + } else if (!p) { p = u; - if (debug > 2) + } + if (debug > 2) { printf("evaluating %s, u: %c, p: %c\n", str, u, p); + } - if (u == 'u') + if (u == 'u') { factor = 1; /* microseconds */ - else if (u == 'm') + } else if (u == 'm') { factor = 1000; /* milliseconds */ - else if (u == 's') + } else if (u == 's') { factor = 1000000; /* seconds */ - if (debug > 2) + } + if (debug > 2) { printf("factor is %u\n", factor); + } i = strtoul(str, &ptr, 0); - if (!ptr || *ptr != '.' || strlen(ptr) < 2 || factor == 1) + if (!ptr || *ptr != '.' || strlen(ptr) < 2 || factor == 1) { return i * factor; + } /* time specified in usecs can't have decimal points, so ignore them */ - if (factor == 1) + if (factor == 1) { return i; + } d = strtoul(ptr + 1, NULL, 0); /* d is decimal, so get rid of excess digits */ - while (d >= factor) + while (d >= factor) { d /= 10; + } /* the last parenthesis avoids floating point exceptions. */ return ((i * factor) + (d * (factor / 10))); @@ -1885,15 +1961,16 @@ static u_int get_timevar(const char *str) { static int get_threshold(char *str, threshold *th) { char *p = NULL, i = 0; - if (!str || !strlen(str) || !th) + if (!str || !strlen(str) || !th) { return -1; + } /* pointer magic slims code by 10 lines. i is bof-stop on stupid libc's */ p = &str[strlen(str) - 1]; while (p != &str[1]) { - if (*p == '%') + if (*p == '%') { *p = '\0'; - else if (*p == ',' && i) { + } else if (*p == ',' && i) { *p = '\0'; /* reset it so get_timevar(str) works nicely later */ th->pl = (unsigned char)strtoul(p + 1, NULL, 0); break; @@ -1903,13 +1980,16 @@ static int get_threshold(char *str, threshold *th) { } th->rta = get_timevar(str); - if (!th->rta) + if (!th->rta) { return -1; + } - if (th->rta > MAXTTL * 1000000) + if (th->rta > MAXTTL * 1000000) { th->rta = MAXTTL * 1000000; - if (th->pl > 100) + } + if (th->pl > 100) { th->pl = 100; + } return 0; } @@ -1925,8 +2005,9 @@ static int get_threshold(char *str, threshold *th) { * @param[in] mode Determines whether this a threshold for rta, packet_loss, jitter, mos or score (exclusively) */ static bool get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, threshold_mode mode) { - if (!str || !length || !warn || !crit) + if (!str || !length || !warn || !crit) { return false; + } // p points to the last char in str char *p = &str[length - 1]; @@ -1999,8 +2080,9 @@ unsigned short icmp_checksum(uint16_t *p, size_t n) { } /* mop up the occasional odd byte */ - if (n == 1) + if (n == 1) { sum += *((uint8_t *)p - 1); + } sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ sum += (sum >> 16); /* add carry */ From git at monitoring-plugins.org Thu Nov 28 09:10:12 2024 From: git at monitoring-plugins.org (Sven Nierlein) Date: Thu, 28 Nov 2024 09:10:12 +0100 (CET) Subject: [monitoring-plugins] check_icmp: Add some lines to introduce some ... Message-ID: <20241128081012.52CB42000154@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 714fd1aceb22014eae64be288fa148bbbf835e33 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: Sven Nierlein Date: Wed Nov 27 15:28:53 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=714fd1a check_icmp: Add some lines to introduce some readability --- plugins-root/check_icmp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index ea17b3a..e6a0096 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -1095,6 +1095,7 @@ static int wait_for_reply(int sock, u_int t) { host->time_waited += tdiff; host->icmp_recv++; icmp_recv++; + if (tdiff > (unsigned int)host->rtmax) { host->rtmax = tdiff; } @@ -1503,10 +1504,10 @@ static void finish(int sig) { host = list; while (host) { - if (debug) { puts(""); } + if (i) { if (i < targets) { printf(" :: "); @@ -1514,11 +1515,14 @@ static void finish(int sig) { printf("\n"); } } + i++; + if (!host->icmp_recv) { status = STATE_CRITICAL; host->rtmin = 0; host->jitter_min = 0; + if (host->flags & FLAG_LOST_CAUSE) { char address[INET6_ADDRSTRLEN]; parse_address(&host->error_addr, address, sizeof(address)); @@ -1538,6 +1542,7 @@ static void finish(int sig) { printf(" rta %0.3fms > %0.3fms", (float)host->rta / 1000, (float)crit.rta / 1000); } } + /* pl text output */ if (pl_mode) { if (status == STATE_OK) { @@ -1548,6 +1553,7 @@ static void finish(int sig) { printf(" lost %u%% > %u%%", host->pl, crit.pl); } } + /* jitter text output */ if (jitter_mode) { if (status == STATE_OK) { @@ -1558,6 +1564,7 @@ static void finish(int sig) { printf(" jitter %0.3fms > %0.3fms", (float)host->jitter, crit.jitter); } } + /* mos text output */ if (mos_mode) { if (status == STATE_OK) { @@ -1568,6 +1575,7 @@ static void finish(int sig) { printf(" MOS %0.1f < %0.1f", (float)host->mos, (float)crit.mos); } } + /* score text output */ if (score_mode) { if (status == STATE_OK) { @@ -1578,6 +1586,7 @@ static void finish(int sig) { printf(" Score %u < %u", (int)host->score, (int)crit.score); } } + /* order statis text output */ if (order_mode) { if (status == STATE_OK) { From git at monitoring-plugins.org Thu Nov 28 09:10:12 2024 From: git at monitoring-plugins.org (Sven Nierlein) Date: Thu, 28 Nov 2024 09:10:12 +0100 (CET) Subject: [monitoring-plugins] check_icmp: set rtmin initially Message-ID: <20241128081012.684E62000156@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 89f79cf2d216fed07de554ef01e230de7e2a5c56 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: Sven Nierlein Date: Wed Nov 27 15:29:19 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=89f79cf check_icmp: set rtmin initially --- plugins-root/check_icmp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index e6a0096..dcacedd 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -64,6 +64,7 @@ const char *email = "devel at monitoring-plugins.org"; #include #include #include +#include /** sometimes undefined system macros (quite a few, actually) **/ #ifndef MAXTTL @@ -1099,7 +1100,8 @@ static int wait_for_reply(int sock, u_int t) { if (tdiff > (unsigned int)host->rtmax) { host->rtmax = tdiff; } - if (tdiff < (unsigned int)host->rtmin) { + + if ((host->rtmin == INFINITY) || (tdiff < (unsigned int)host->rtmin)) { host->rtmin = tdiff; } From git at monitoring-plugins.org Thu Nov 28 23:20:12 2024 From: git at monitoring-plugins.org (GitHub) Date: Thu, 28 Nov 2024 23:20:12 +0100 (CET) Subject: [monitoring-plugins] Merge pull request #2053 from klaernie/support Message-ID: <20241128222012.126EA2000154@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: afb1734ec488b72e17b3fe8d14d9a0473e1449a4 Author: Lorenz K?stle <12514511+RincewindsHat at users.noreply.github.com> Committer: GitHub Date: Thu Nov 28 23:14:51 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=afb1734 Merge pull request #2053 from klaernie/support fix typo in SUPPORT --- From git at monitoring-plugins.org Thu Nov 28 23:20:12 2024 From: git at monitoring-plugins.org (Andre Klaerner) Date: Thu, 28 Nov 2024 23:20:12 +0100 (CET) Subject: [monitoring-plugins] fix typo in SUPPORT Message-ID: <20241128222012.067DD200014F@orwell.monitoring-plugins.org> Module: monitoring-plugins Branch: master Commit: 28e7fe33729a42c6338fcdced65acbb62cf99065 Author: Andre Klaerner Date: Thu Nov 28 22:52:41 2024 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=28e7fe3 fix typo in SUPPORT --- SUPPORT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUPPORT b/SUPPORT index d2a2b7d..d98c6c1 100644 --- a/SUPPORT +++ b/SUPPORT @@ -8,7 +8,7 @@ support offerings. There are two mailing lists associated with Monitoring Plugins development: 'help' (mailto:help at monitoring-plugins.org), and 'devel' -(mailto:help at monitoring-plugins.org). Unless you are fairly +(mailto:devel at monitoring-plugins.org). Unless you are fairly certain you have found a bug or that you are requesting a new feature, please direct support requests to 'help'.