Update upstream source from tag 'upstream/2.3.3'

Update to upstream version '2.3.3'
with Debian dir 39ec6a0f35
This commit is contained in:
Jan Wagner 2023-02-02 09:13:25 +00:00
commit dda4a52c26
52 changed files with 13068 additions and 34194 deletions

View file

@ -1,12 +0,0 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "04:00"
reviewers:
- "waja"
pull-request-branch-name:
separator: "-"
open-pull-requests-limit: 10

View file

@ -1,36 +0,0 @@
name: Packaging Test
on:
push:
branches:
- $default-branch
- development
- master
# Run tests for any PRs
pull_request:
env:
SOURCE_DIR: ./
ARTIFACTS_DIR: debian/build/release/
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
env:
DEBIAN_FRONTEND: "noninteractive"
- name: Remove github artefacts
run: |
rm -rf .github*
- name: Adjust distibution in changelog file
run: |
sed -i '0,/restricted/s//stable/' debian/changelog
- name: Build Debian package
uses: dawidd6/action-debian-package@v1.4.4
with:
artifacts_directory: debian/build/release/
os_distribution: testing
- name: Debug
run: |
ls -la

View file

@ -1,71 +0,0 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'debian/*' # Push events to matching debian/*, i.e. debian/1.0-2, debian/20.15.10, debian/23.20020326
name: Release Process
env:
SOURCE_DIR: ./
ARTIFACTS_DIR: debian/build/release/
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
release-id: ${{ steps.create_release.outputs.id }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install needed packages
run: |
if [ $(dpkg -l | grep -c dpkg-dev) -ne 1 ]; then sudo apt-get update && sudo apt-get install -y dpkg-dev; fi
- name: Gather changelog
run: |
ls -la
dpkg-parsechangelog | tail -n +9 > debian.changelog
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: debian.changelog
draft: false
prerelease: false
build:
name: Build and upload packages
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
env:
DEBIAN_FRONTEND: "noninteractive"
- name: Remove github artefacts
run: |
rm -rf .github*
- name: Adjust distibution in changelog file
run: |
sed -i '0,/restricted/s//stable/' debian/changelog
- name: Build Debian package
uses: dawidd6/action-debian-package@v1.4.4
with:
artifacts_directory: debian/build/release/
os_distribution: testing
# - name: Build Debian package
# uses: pi-top/action-debian-package@v0.2.0
# with:
# artifacts_directory: debian/build/release/
# target_architectures: "amd64,i386"
- name: Upload the artifacts
uses: skx/github-action-publish-binaries@release-2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ needs.create-release.outputs.release-id }}
args: debian/build/release/*

22959
ChangeLog

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
Installation Instructions
*************************
Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
Foundation, Inc.
Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free
Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
@ -225,7 +225,7 @@ order to use an ANSI C compiler:
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX 'make' updates targets which have the same time stamps as their
HP-UX 'make' updates targets which have the same timestamps as their
prerequisites, which makes it generally unusable when shipped generated
files such as 'configure' are involved. Use GNU 'make' instead.

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -250,9 +250,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/test.pl.in $(top_srcdir)/build-aux/compile \
@ -337,6 +334,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = -DLOCALEDIR=\"$(localedir)\"
@ -356,6 +355,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -1640,7 +1640,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

38
NEWS
View file

@ -1,5 +1,43 @@
This file documents the major additions and syntax changes between releases.
2.3.3 2nd Feb 2023
ENHANCEMENTS
using PRId64 and PRIu64 instead of %ld directly
check_http: Make faster with larger files
check_snmp: add 'multiplier' to modify current value
check_http: Implement chunked encoding decoding
check_http/check_curl: add chunked encoding test
check_log: Added --exclude to exclude patterns
check_log: Add tests
check_disk: Clarify usage possibilites
FIXES
fixed two PRId64 to PRIu64 in perfdata_uint64
check_pgsql: Removing is_pg_dbname alltogether,using postgres API.
check_http: Remove superflous CRLF in HTTP-Requests
check_curl: detect ipv6
check_icmp: fix parsing help/version long options
check_http: fix test plan
check_disk: Find accessible mount path if multiple are available
check_apt: Fix unknown escape sequence error output
check_curl: fix checking large bodys
check_snmp: Improve tests for check_snmp & multiply option
check_snmp: always apply format when applying multiplier
check_http: Use real booleans instead of ints
check_http: Document process_arguments a little bit better
check_http: Remove dead code
check_http: Fix several bug in the implementation of unchunking
check_http: Reformat a part to increase readability
check_apt: Put upgrade options in the root sections
check_apt: Fix comment
check_apt: Use real booleans
check_mailq: Fixing nullmailer regex
check_snmp: Fix regex matches
check_log: Fixed a bug when using --all
check_log: Cleaned up duplicated code in the args
check_http: Fix memory reallocation error in chunk decoding logic
check_http: Add space for ending NULL byte in array for chunked encoding
2.3.2 20th Oct 2022
GENERAL
Use netcat-openbsd for debian explicitely (by @RincewindsHat #1704)

View file

@ -6,7 +6,7 @@
SRC_ROOT=`dirname $0`
NPVF=NP-VERSION-FILE
DEF_VER=2.3.2
DEF_VER=2.3.3
LF='
'

35
THANKS
View file

@ -2,28 +2,28 @@ This software is brought to you by the Monitoring Plugins Development Team. Howe
there have been many contributors to this project. Everyone below has helped in
raising bug reports, creating patches or contributing new plugins.
dag rob?le
Aksel Sjögren
Marc Sánchez
Wolfgang Karall-Ahlborn
Randy O'Meara
Elan Ruusamäe
Matthias Hähnel
Randy O'Meara
Wolfgang Karall-Ahlborn
Nicolai Søborg
fabiodds
dag rob?le
Diego Elio Pettenò
Matthias Hähnel
Marc Sánchez
Aksel Sjögren
fabiodds
Oskar Ahner
Lance Albertson
David Alden
Patrick Allen
Rodger Allen
Paul Allen
Patrick Allen
Felipe Gustavo de Almeida
Michael Almond
Michael Anthon
Bernd Apfel
Paula Arnold
Bernd Arnold
Paula Arnold
Kondoros Attila
Daniel Austin
Karol Babioch
@ -55,6 +55,7 @@ Prathamesh Bhanuse
Daniel Bimschas
Jeffery Blank
Tom De Blende
Robert Bohne
Eric Bollengier
Aurelien Bompard
Stéphane Bortzmeyer
@ -83,9 +84,9 @@ Lee Clemens
Ben Clewett
Jean-Claude Computing
Lionel Cons
Ollie Cook
Charlie Cook
Garry Cook
Charlie Cook
Ollie Cook
Luca Corti
Greg Cox
Jason Crawford
@ -155,12 +156,13 @@ Olaf Greis
Alex Griffin
Chris Grim
Steven Grimm
Lorenz Gruenwald
Sebastien Guay
Linda Guo
Jon Hallett
Steve Hanselman
Jacob Hansen
Ask Bjoern Hansen
Jacob Hansen
Sebastian Harl
Michael Haro
Olli Hauer
@ -237,8 +239,8 @@ Pawel Malachowski
Ricardo Maraschini
Michael Markstaller
John Marquart
Jason Martin
Ernst-Dieter Martin
Jason Martin
Christopher Maser
Mathieu Masseboeuf
Alexander Matey
@ -269,6 +271,7 @@ Jan-Frode Myklebust
Sivakumar Nellurandi
Peter Newman
Truongchinh Nguyen
Wolfgang Nieder
Simon L Nielsen
Thomas Nilsen
Sebastian Nohn
@ -326,8 +329,8 @@ Sven Schaffranneck
Christoph Schell
Thomas Schimpke
Benjamin Schmid
Christian Schmidt
Sebastian Schmidt
Christian Schmidt
Henning Schmiedehausen
Christian Schneemann
Cove Schneider
@ -356,6 +359,7 @@ David Sullivan
Kjell Sundtjonn
Ziya Suzen
Christian Tacke
Danijel Tasov
Michael Tiernan
Ben Timby
Ronald Tin
@ -398,9 +402,10 @@ Shawn Wills
Rob Windsor
Mario Witte
Alexander Wittig
Tobias Wolf
Brian De Wolf
Tobias Wolf
Eric Wunderlin
Patric Wust
Jamie Zawinski
Vadim Zhukov
andrew bezella

70
aclocal.m4 vendored
View file

@ -1,6 +1,6 @@
# generated automatically by aclocal 1.16.3 -*- Autoconf -*-
# generated automatically by aclocal 1.16.5 -*- Autoconf -*-
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -14,13 +14,13 @@
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
[m4_warning([this file was generated for autoconf 2.69.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],,
[m4_warning([this file was generated for autoconf 2.71.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# Copyright (C) 2002-2020 Free Software Foundation, Inc.
# Copyright (C) 2002-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.16'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.16.3], [],
m4_if([$1], [1.16.5], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.16.3])dnl
[AM_AUTOMAKE_VERSION([1.16.5])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001-2020 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997-2020 Free Software Foundation, Inc.
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -332,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -400,7 +400,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -428,6 +428,10 @@ m4_defn([AC_PROG_CC])
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.65])dnl
m4_ifdef([_$0_ALREADY_INIT],
[m4_fatal([$0 expanded multiple times
]m4_defn([_$0_ALREADY_INIT]))],
[m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
@ -464,7 +468,7 @@ m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
[ok:ok],,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
@ -516,6 +520,20 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
[m4_define([AC_PROG_OBJCXX],
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
])
# Variables for tags utilities; see am/tags.am
if test -z "$CTAGS"; then
CTAGS=ctags
fi
AC_SUBST([CTAGS])
if test -z "$ETAGS"; then
ETAGS=etags
fi
AC_SUBST([ETAGS])
if test -z "$CSCOPE"; then
CSCOPE=cscope
fi
AC_SUBST([CSCOPE])
AC_REQUIRE([AM_SILENT_RULES])dnl
dnl The testsuite driver may need to know about EXEEXT, so add the
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
@ -597,7 +615,7 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001-2020 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -618,7 +636,7 @@ if test x"${install_sh+set}" != xset; then
fi
AC_SUBST([install_sh])])
# Copyright (C) 2003-2020 Free Software Foundation, Inc.
# Copyright (C) 2003-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -640,7 +658,7 @@ AC_SUBST([am__leading_dot])])
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
# From Jim Meyering
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -675,7 +693,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001-2020 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -718,7 +736,7 @@ AC_SUBST([am__quote])])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2020 Free Software Foundation, Inc.
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -752,7 +770,7 @@ fi
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001-2020 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -781,7 +799,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -828,7 +846,7 @@ AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
# Copyright (C) 2001-2020 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -847,7 +865,7 @@ AC_DEFUN([AM_RUN_LOG],
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -928,7 +946,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file
])
# Copyright (C) 2009-2020 Free Software Foundation, Inc.
# Copyright (C) 2009-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -988,7 +1006,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
# Copyright (C) 2001-2020 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1016,7 +1034,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2020 Free Software Foundation, Inc.
# Copyright (C) 2006-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1035,7 +1053,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2020 Free Software Foundation, Inc.
# Copyright (C) 2004-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,

View file

@ -3,7 +3,7 @@
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify

1500
build-aux/config.guess vendored

File diff suppressed because it is too large Load diff

2855
build-aux/config.sub vendored

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -3,7 +3,7 @@
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify

View file

@ -3,7 +3,7 @@
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 2011-2020 Free Software Foundation, Inc.
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -105,8 +105,11 @@ trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15
# Test script is run here.
"$@" >$log_file 2>&1
# Test script is run here. We create the file first, then append to it,
# to ameliorate tests themselves also writing to the log file. Our tests
# don't, but others can (automake bug#35762).
: >"$log_file"
"$@" >>"$log_file" 2>&1
estatus=$?
if test $enable_hard_errors = no && test $estatus -eq 99; then
@ -128,7 +131,7 @@ esac
# know whether the test passed or failed simply by looking at the '.log'
# file, without the need of also peaking into the corresponding '.trs'
# file (automake bug#11814).
echo "$res $test_name (exit status: $estatus)" >>$log_file
echo "$res $test_name (exit status: $estatus)" >>"$log_file"
# Report outcome to console.
echo "${col}${res}${std}: $test_name"

View file

@ -27,12 +27,7 @@
/* Define if 2-argument SVR4 swapctl exists */
#undef CHECK_SWAP_SWAPCTL_SVR4
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
/* Define to 1 if using 'alloca.c'. */
#undef C_ALLOCA
/* Define as the bit index in the word where to find bit 0 of the exponent of
@ -177,8 +172,7 @@
may be supplied by this distribution. */
#undef HAVE_ALLOCA
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
/* Define to 1 if <alloca.h> works. */
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the <arpa/inet.h> header file. */
@ -537,9 +531,6 @@
/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <mntent.h> header file. */
#undef HAVE_MNTENT_H
@ -1481,6 +1472,9 @@
uintmax_t. */
#undef HAVE_STDINT_H_WITH_UINTMAX
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
@ -1493,7 +1487,7 @@
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the `strerror_r' function. */
/* Define if you have `strerror_r'. */
#undef HAVE_STRERROR_R
/* Define to 1 if you have the <strings.h> header file. */
@ -2085,7 +2079,9 @@
/* Define if statvfs64 should be preferred over statvfs. */
#undef STAT_STATVFS64
/* Define to 1 if you have the ANSI C header files. */
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
/* Define to 1 if strerror_r returns char *. */
@ -2103,7 +2099,8 @@
/* Format string for parsing swap output */
#undef SWAP_FORMAT
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This
macro is obsolete. */
#undef TIME_WITH_SYS_TIME
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
@ -2213,9 +2210,6 @@
# endif
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#undef _DARWIN_USE_64_BIT_INODE
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
@ -2373,7 +2367,7 @@
/* Define to `int' if <sys/types.h> does not define. */
#undef mode_t
/* Define to `int' if <sys/types.h> does not define. */
/* Define as a signed integer type capable of holding a process identifier. */
#undef pid_t
/* Define as the type of the result of subtracting two pointers, if the system
@ -2427,14 +2421,15 @@
/* Define to the equivalent of the C99 'restrict' keyword, or to
nothing if this is not supported. Do not define if restrict is
supported directly. */
supported only directly. */
#undef restrict
/* Work around a bug in Sun C++: it does not support _Restrict or
__restrict__, even though the corresponding Sun C compiler ends up with
"#define restrict _Restrict" or "#define restrict __restrict__" in the
previous line. Perhaps some future version of Sun C++ will work with
restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
#if defined __SUNPRO_CC && !defined __RESTRICT
/* Work around a bug in older versions of Sun C++, which did not
#define __restrict__ or support _Restrict or __restrict__
even though the corresponding Sun C compiler ended up with
"#define restrict _Restrict" or "#define restrict __restrict__"
in the previous line. This workaround can be removed once
we assume Oracle Developer Studio 12.5 (2016) or later. */
#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
# define _Restrict
# define __restrict__
#endif

16809
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(monitoring-plugins,2.3.2)
AC_INIT(monitoring-plugins,2.3.3)
AC_CONFIG_SRCDIR(NPTest.pm)
AC_CONFIG_FILES([gl/Makefile])
AC_CONFIG_AUX_DIR(build-aux)

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -359,8 +359,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/build-aux/depcomp \
@ -415,6 +413,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = @DEFS@
@ -434,6 +434,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -1930,7 +1931,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -293,8 +293,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/build-aux/depcomp \
@ -349,6 +347,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = @DEFS@
@ -368,6 +368,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -1660,7 +1661,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -319,8 +319,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
@ -553,6 +551,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = @DEFS@
@ -572,6 +572,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -2038,7 +2039,6 @@ recheck: all $(check_PROGRAMS)
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

View file

@ -28,6 +28,7 @@
#include "common.h"
#include "utils_disk.h"
#include "gl/fsusage.h"
void
np_add_name (struct name_list **list, const char *name)
@ -127,9 +128,12 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
size_t name_len = strlen(d->name);
size_t best_match_len = 0;
struct mount_entry *best_match = NULL;
struct fs_usage fsp;
/* set best match if path name exactly matches a mounted device name */
for (me = mount_list; me; me = me->me_next) {
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
continue; /* skip if permissions do not suffice for accessing device */
if (strcmp(me->me_devname, d->name)==0)
best_match = me;
}
@ -137,6 +141,8 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
/* set best match by directory name if no match was found by devname */
if (! best_match) {
for (me = mount_list; me; me = me->me_next) {
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
continue; /* skip if permissions do not suffice for accessing device */
size_t len = strlen (me->me_mountdir);
if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
(len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))

View file

@ -2,11 +2,11 @@ PKG="NGOSplugin"
NAME="monitoring-plugins"
DESC="Network Monitoring Plugins for Nagios and compatible"
ARCH="unknown"
VERSION="2.3.2,REV=2022.10.19.14.57"
VERSION="2.3.3,REV=2023.02.01.13.46"
CATEGORY="application"
VENDOR="Monitoring Plugins Development Team"
EMAIL="devel@monitoring-plugins.org"
PSTAMP="nag20221019145705"
PSTAMP="nag20230201134644"
BASEDIR="/"
CLASSES="none"

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -276,8 +276,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
@ -511,6 +509,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
@ -530,6 +530,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -1985,7 +1986,6 @@ recheck: all
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

View file

@ -451,6 +451,14 @@ main(int argc, char **argv)
packets = 5;
}
/* support "--help" and "--version" */
if(argc == 2) {
if(!strcmp(argv[1], "--help"))
strcpy(argv[1], "-h");
if(!strcmp(argv[1], "--version"))
strcpy(argv[1], "-V");
}
/* Parse protocol arguments first */
for(i = 1; i < argc; i++) {
while((arg = getopt(argc, argv, opts_str)) != EOF) {
@ -555,14 +563,6 @@ main(int argc, char **argv)
/* Parse extra opts if any */
argv=np_extra_opts(&argc, argv, progname);
/* support "--help" and "--version" */
if(argc == 2) {
if(!strcmp(argv[1], "--help"))
strcpy(argv[1], "-h");
if(!strcmp(argv[1], "--version"))
strcpy(argv[1], "-V");
}
argv = &argv[optind];
while(*argv) {
add_target(*argv);

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -448,6 +448,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = @DEFS@
@ -467,6 +469,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -1828,7 +1831,6 @@ recheck: all
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

View file

@ -18,7 +18,7 @@
# On the first run of the plugin, it will return an OK state with a message
# of "Log check data initialized". On successive runs, it will return an OK
# state if *no* pattern matches have been found in the *difference* between the
# log file and the older copy of the log file. If the plugin detects any
# log file and the older copy of the log file. If the plugin detects any
# pattern matches in the log diff, it will return a CRITICAL state and print
# out a message is the following format: "(x) last_match", where "x" is the
# total number of pattern matches found in the file and "last_match" is the
@ -76,6 +76,7 @@ print_usage() {
echo ""
echo "Other parameters:"
echo " -a|--all : Print all matching lines"
echo " --exclude: Exclude a pattern (-p or -e also applies here when used)"
echo " -p|--perl-regex : Use perl style regular expressions in the query"
echo " -e|--extended-regex : Use extended style regular expressions in the query (not necessary for GNU grep)"
}
@ -99,82 +100,46 @@ if [ $# -lt 1 ]; then
fi
# Grab the command line arguments
#logfile=$1
#oldlog=$2
#query=$3
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
case "$1" in
--help)
-h | --help)
print_help
exit "$STATE_OK"
;;
-h)
print_help
exit "$STATE_OK"
;;
--version)
-V | --version)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
;;
-V)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
;;
--filename)
-F | --filename)
logfile=$2
shift 2
;;
-F)
logfile=$2
shift 2
;;
--oldlog)
-O | --oldlog)
oldlog=$2
shift 2
;;
-O)
oldlog=$2
shift 2
;;
--query)
-q | --query)
query=$2
shift 2
;;
-q)
query=$2
--exclude)
exclude=$2
shift 2
;;
-x)
-x | --exitstatus)
exitstatus=$2
shift 2
;;
--exitstatus)
exitstatus=$2
shift 2
;;
--extended-regex)
-e | --extended-regex)
ERE=1
shift
;;
-e)
ERE=1
shift
;;
--perl-regex)
-p | --perl-regex)
PRE=1
shift
;;
-p)
PRE=1
shift
;;
--all)
ALL=1
shift
;;
-a)
-a | --all)
ALL=1
shift
;;
@ -188,18 +153,18 @@ done
# Parameter sanity check
if [ $ERE ] && [ $PRE ] ; then
echo "Can not use extended and perl regex at the same time"
exit "$STATE_UNKNOWN"
echo "Can not use extended and perl regex at the same time"
exit "$STATE_UNKNOWN"
fi
GREP="grep"
if [ $ERE ]; then
GREP="grep -E"
GREP="grep -E"
fi
if [ $PRE ]; then
GREP="grep -P"
GREP="grep -P"
fi
# If the source log file doesn't exist, exit
@ -213,8 +178,8 @@ elif [ ! -r "$logfile" ] ; then
fi
# If no oldlog was given this can not work properly, abort then
if [ -z "$oldlog" ]; then
echo "Oldlog parameter is needed"
exit $STATE_UNKNOWN
echo "Oldlog parameter is needed"
exit $STATE_UNKNOWN
fi
# If the old log file doesn't exist, this must be the first time
@ -245,18 +210,24 @@ diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
if [ $ALL ]; then
# Get the last matching entry in the diff file
entry=$($GREP "$query" "$tempdiff")
# Count the number of matching log entries we have
count=$(echo "$entry" | wc -l)
# Get all matching entries in the diff file
if [ -n "$exclude" ]; then
entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude")
count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude")
else
entry=$($GREP "$query" "$tempdiff")
count=$($GREP -c "$query" "$tempdiff")
fi
else
# Count the number of matching log entries we have
count=$($GREP -c "$query" "$tempdiff")
# Get the last matching entry in the diff file
entry=$($GREP "$query" "$tempdiff" | tail -1)
# Get the last matching entry in the diff file
if [ -n "$exclude" ]; then
entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude" | tail -1)
count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude")
else
entry=$($GREP "$query" "$tempdiff" | tail -1)
count=$($GREP -c "$query" "$tempdiff")
fi
fi
rm -f "$tempdiff"

View file

@ -537,9 +537,9 @@ elsif ( $mailq eq "nullmailer" ) {
}
while (<MAILQ>) {
#2006-06-22 16:00:00 282 bytes
#2022-08-25 01:30:40 502 bytes from <user@example.com>
if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]\s+[0-9]+\sbytes/) {
if (/^\d{4}-\d{2}-\d{2}\s+\d{2}\:\d{2}\:\d{2}\s+\d+\sbytes/) {
$msg_q++ ;
}
}

View file

@ -0,0 +1,82 @@
#!/usr/bin/perl -w -I ..
#
# check_log tests
#
#
use strict;
use Test::More;
use NPTest;
my $tests = 18;
plan tests => $tests;
my $firstTimeOutput ='/^Log check data initialized/';
my $okOutput = '/^Log check ok - 0 pattern matches found/';
my $criticalOutput = '/^\(\d+\) < /';
my $multilineOutput = '/\(3\) <.*\n.*\n.*$/';
my $unknownOutput = '/^Usage: /';
my $unknownArgOutput = '/^Unknown argument: /';
my $bothRegexOutput = '/^Can not use extended and perl regex/';
my $result;
my $temp_file = "/tmp/check_log.tmp";
my $oldlog = "/tmp/oldlog.tmp";
open(FH, '>', $temp_file) or die $!;
close(FH);
$result = NPTest->testCmd("./check_log");
cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
like ( $result->output, $unknownOutput, "Output for unknown correct" );
$result = NPTest->testCmd("./check_log -f");
cmp_ok( $result->return_code, '==', 3, "Wrong parameters" );
like ( $result->output, $unknownArgOutput, "Output for unknown correct" );
$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match' -e -p");
cmp_ok( $result->return_code, '==', 3, "Both regex parameters" );
like ( $result->output, $bothRegexOutput, "Output for unknown correct" );
$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match'");
cmp_ok( $result->return_code, '==', 0, "First time executing" );
like ( $result->output, $firstTimeOutput, "Output for first time executing correct" );
open(FH, '>>', $temp_file) or die $!;
print FH "This is some text, that should not match\n";
close(FH);
$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'No match'");
cmp_ok( $result->return_code, '==', 0, "No match" );
like ( $result->output, $okOutput, "Output for no match correct" );
open(FH, '>>', $temp_file) or die $!;
print FH "This text should match\n";
close(FH);
$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'should match'");
cmp_ok( $result->return_code, '==', 2, "Pattern match" );
like ( $result->output, $criticalOutput, "Output for match correct" );
open(FH, '>>', $temp_file) or die $!;
print FH "This text should not match, because it is excluded\n";
close(FH);
$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' --exclude 'because'");
cmp_ok( $result->return_code, '==', 0, "Exclude a pattern" );
like ( $result->output, $okOutput, "Output for no match correct" );
open(FH, '>>', $temp_file) or die $!;
print FH "Trying\nwith\nmultiline\nignore me\n";
close(FH);
$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Trying\\|with\\|multiline\\|ignore' --exclude 'me' --all");
cmp_ok( $result->return_code, '==', 2, "Multiline pattern match with --all" );
like ( $result->output, $multilineOutput, "Output for multiline match correct" );
$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' -a");
cmp_ok( $result->return_code, '==', 0, "Non matching --all" );
like ( $result->output, $okOutput, "Output for no match correct" );
unlink($oldlog);
unlink($temp_file);

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -515,8 +515,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
@ -775,6 +773,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
# gettext docs say to use AM_CPPFLAGS, but per module_CPPFLAGS override this
@ -795,6 +795,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -2608,7 +2609,6 @@ recheck: all
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

View file

@ -1,32 +1,32 @@
/*****************************************************************************
*
*
* Monitoring check_apt plugin
*
*
* License: GPL
* Copyright (c) 2006-2008 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 <http://www.gnu.org/licenses/>.
*
*
*****************************************************************************/
const char *progname = "check_apt";
@ -76,9 +76,9 @@ int cmpstringp(const void *p1, const void *p2);
/* configuration variables */
static int verbose = 0; /* -v */
static int list = 0; /* list packages available for upgrade */
static int do_update = 0; /* whether to call apt-get update */
static int only_critical = 0; /* whether to warn about non-critical updates */
static 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 */
@ -119,7 +119,7 @@ int main (int argc, char **argv) {
if(sec_count > 0){
result = max_state(result, STATE_CRITICAL);
} else if(packages_available >= packages_warning && only_critical == 0){
} else if(packages_available >= packages_warning && only_critical == false){
result = max_state(result, STATE_WARNING);
} else if(result > STATE_UNKNOWN){
result = STATE_UNKNOWN;
@ -144,7 +144,7 @@ int main (int argc, char **argv) {
for(i = 0; i < sec_count; i++)
printf("%s (security)\n", secpackages_list[i]);
if (only_critical == 0) {
if (only_critical == false) {
for(i = 0; i < packages_available - sec_count; i++)
printf("%s\n", packages_list[i]);
}
@ -166,7 +166,7 @@ int process_arguments (int argc, char **argv) {
{"upgrade", optional_argument, 0, 'U'},
{"no-upgrade", no_argument, 0, 'n'},
{"dist-upgrade", optional_argument, 0, 'd'},
{"list", no_argument, 0, 'l'},
{"list", no_argument, false, 'l'},
{"include", required_argument, 0, 'i'},
{"exclude", required_argument, 0, 'e'},
{"critical", required_argument, 0, 'c'},
@ -212,14 +212,14 @@ int process_arguments (int argc, char **argv) {
upgrade=NO_UPGRADE;
break;
case 'u':
do_update=1;
do_update=true;
if(optarg!=NULL){
update_opts=strdup(optarg);
if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
}
break;
case 'l':
list=1;
list=true;
break;
case 'i':
do_include=add_to_regexp(do_include, optarg);
@ -231,7 +231,7 @@ int process_arguments (int argc, char **argv) {
do_critical=add_to_regexp(do_critical, optarg);
break;
case 'o':
only_critical=1;
only_critical=true;
break;
case INPUT_FILE_OPT:
input_filename = optarg;
@ -269,7 +269,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf);
}
}
if(do_exclude!=NULL){
regres=regcomp(&ereg, do_exclude, REG_EXTENDED);
if(regres!=0) {
@ -278,7 +278,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
progname, rerrbuf);
}
}
const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE;
regres=regcomp(&sreg, crit_ptr, REG_EXTENDED);
if(regres!=0) {
@ -295,7 +295,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
/* run the upgrade */
result = 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 */
@ -371,7 +371,7 @@ int run_update(void){
struct output chld_out, chld_err;
char *cmdline;
/* run the upgrade */
/* run the update */
cmdline = construct_cmdline(NO_UPGRADE, update_opts);
result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
/* apt-get update changes exit status if it can't fetch packages.
@ -501,16 +501,6 @@ print_help (void)
printf(UT_PLUG_TIMEOUT, timeout_interval);
printf (" %s\n", "-U, --upgrade=OPTS");
printf (" %s\n", _("[Default] 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."));
printf (" %s\n", "-d, --dist-upgrade=OPTS");
printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
printf (" %s\n", _("can be provided to override the default options."));
printf (" %s\n", "-n, --no-upgrade");
printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
printf (" %s\n", "-l, --list");
@ -530,7 +520,7 @@ print_help (void)
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 (" \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");
@ -538,7 +528,7 @@ print_help (void)
printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause"));
printf (" %s\n", _("the plugin to return WARNING status."));
printf (" %s\n", "-w, --packages-warning");
printf (" %s\n", _("Minumum number of packages available for upgrade to return WARNING status."));
printf (" %s\n", _("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:"));
@ -547,6 +537,16 @@ print_help (void)
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);
}

View file

@ -476,6 +476,18 @@ check_http (void)
printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache);
}
// If server_address is an IPv6 address it must be surround by square brackets
struct in6_addr tmp_in_addr;
if (inet_pton(AF_INET6, server_address, &tmp_in_addr) == 1) {
char *new_server_address = malloc(strlen(server_address) + 3);
if (new_server_address == NULL) {
die(STATE_UNKNOWN, "HTTP UNKNOWN - Unable to allocate memory\n");
}
snprintf(new_server_address, strlen(server_address)+3, "[%s]", server_address);
free(server_address);
server_address = new_server_address;
}
/* compose URL: use the address we want to connect to, set Host: header later */
snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
use_ssl ? "https" : "http",
@ -999,10 +1011,12 @@ GOT_FIRST_CERT:
result = max_state_alt(get_status(total_time, thlds), result);
/* Cut-off trailing characters */
if(msg[strlen(msg)-2] == ',')
msg[strlen(msg)-2] = '\0';
else
msg[strlen(msg)-3] = '\0';
if (strlen(msg) >= 2) {
if(msg[strlen(msg)-2] == ',')
msg[strlen(msg)-2] = '\0';
else
msg[strlen(msg)-3] = '\0';
}
/* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
@ -1666,7 +1680,7 @@ process_arguments (int argc, char **argv)
curl_http_version = CURL_HTTP_VERSION_NONE;
#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0) */
} else {
fprintf (stderr, "unkown http-version parameter: %s\n", optarg);
fprintf (stderr, "unknown http-version parameter: %s\n", optarg);
exit (STATE_WARNING);
}
break;
@ -2010,9 +2024,12 @@ curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *s
curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream;
while (buf->bufsize < buf->buflen + size * nmemb + 1) {
buf->bufsize *= buf->bufsize * 2;
buf->bufsize = buf->bufsize * 2;
buf->buf = (char *)realloc (buf->buf, buf->bufsize);
if (buf->buf == NULL) return -1;
if (buf->buf == NULL) {
fprintf(stderr, "malloc failed (%d) %s\n", errno, strerror(errno));
return -1;
}
}
memcpy (buf->buf + buf->buflen, buffer, size * nmemb);

View file

@ -951,7 +951,7 @@ void
print_usage (void)
{
printf ("%s\n", _("Usage:"));
printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname);
printf (" %s {-w absolute_limit |-w percentage_limit% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit% | -K inode_percentage_limit } {-p path | -x device}\n", progname);
printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n");
}

View file

@ -492,7 +492,7 @@ void print_help (void) {
printf (" %s\n", "-c, --critical=THRESHOLD");
printf (" %s\n", _("critical threshold pair"));
printf (" %s\n", "-a, --alive");
printf (" %s\n", _("Return OK after first successfull reply"));
printf (" %s\n", _("Return OK after first successful reply"));
printf (" %s\n", "-b, --bytes=INTEGER");
printf (" %s (default: %d)\n", _("size of ICMP packet"),PACKET_SIZE);
printf (" %s\n", "-n, --number=INTEGER");

View file

@ -31,13 +31,14 @@
*
*****************************************************************************/
/* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */
const char *progname = "check_http";
const char *copyright = "1999-2013";
const char *copyright = "1999-2022";
const char *email = "devel@monitoring-plugins.org";
// Do NOT sort those headers, it will break the build
// TODO: Fix this
#include "common.h"
#include "base64.h"
#include "netutils.h"
#include "utils.h"
#include "base64.h"
@ -57,8 +58,8 @@ enum {
};
#ifdef HAVE_SSL
int check_cert = FALSE;
int continue_after_check_cert = FALSE;
bool check_cert = false;
bool continue_after_check_cert = false;
int ssl_version = 0;
int days_till_exp_warn, days_till_exp_crit;
char *randbuff;
@ -69,7 +70,7 @@ X509 *server_cert;
# define my_recv(buf, len) read(sd, buf, len)
# define my_send(buf, len) send(sd, buf, len, 0)
#endif /* HAVE_SSL */
int no_body = FALSE;
bool no_body = false;
int maximum_age = -1;
enum {
@ -91,7 +92,7 @@ struct timeval tv_temp;
#define HTTP_URL "/"
#define CRLF "\r\n"
int specify_port = FALSE;
bool specify_port = false;
int server_port = HTTP_PORT;
int virtual_port = 0;
char server_port_text[6] = "";
@ -106,23 +107,21 @@ int server_expect_yn = 0;
char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
char header_expect[MAX_INPUT_BUFFER] = "";
char string_expect[MAX_INPUT_BUFFER] = "";
char output_header_search[30] = "";
char output_string_search[30] = "";
char *warning_thresholds = NULL;
char *critical_thresholds = NULL;
thresholds *thlds;
char user_auth[MAX_INPUT_BUFFER] = "";
char proxy_auth[MAX_INPUT_BUFFER] = "";
int display_html = FALSE;
bool display_html = false;
char **http_opt_headers;
int http_opt_headers_count = 0;
int onredirect = STATE_OK;
int followsticky = STICKY_NONE;
int use_ssl = FALSE;
int use_sni = FALSE;
int verbose = FALSE;
int show_extended_perfdata = FALSE;
int show_body = FALSE;
bool use_ssl = false;
bool use_sni = false;
bool verbose = false;
bool show_extended_perfdata = false;
bool show_body = false;
int sd;
int min_page_len = 0;
int max_page_len = 0;
@ -136,10 +135,11 @@ char buffer[MAX_INPUT_BUFFER];
char *client_cert = NULL;
char *client_privkey = NULL;
int process_arguments (int, char **);
// Forward function declarations
bool process_arguments (int, char **);
int check_http (void);
void redir (char *pos, char *status_line);
int server_type_check(const char *type);
bool server_type_check(const char *type);
int server_port_check(int ssl_flag);
char *perfd_time (double microsec);
char *perfd_time_connect (double microsec);
@ -150,6 +150,7 @@ char *perfd_time_transfer (double microsec);
char *perfd_size (int page_len);
void print_help (void);
void print_usage (void);
char *unchunk_content(const char *content);
int
main (int argc, char **argv)
@ -169,10 +170,10 @@ 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) == false)
usage4 (_("Could not parse arguments"));
if (display_html == TRUE)
if (display_html == true)
printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">",
use_ssl ? "https" : "http", host_name ? host_name : server_address,
server_port, server_url);
@ -195,9 +196,11 @@ test_file (char *path)
usage2 (_("file does not exist or is not readable"), path);
}
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
/*
* process command-line arguments
* returns true on succes, false otherwise
*/
bool process_arguments (int argc, char **argv)
{
int c = 1;
char *p;
@ -252,7 +255,7 @@ process_arguments (int argc, char **argv)
};
if (argc < 2)
return ERROR;
return false;
for (c = 1; c < argc; c++) {
if (strcmp ("-to", argv[c]) == 0)
@ -308,10 +311,10 @@ process_arguments (int argc, char **argv)
/* xasprintf (&http_opt_headers, "%s", optarg); */
break;
case 'L': /* show html link */
display_html = TRUE;
display_html = true;
break;
case 'n': /* do not show html link */
display_html = FALSE;
display_html = false;
break;
case 'C': /* Check SSL cert validity */
#ifdef HAVE_SSL
@ -332,12 +335,12 @@ process_arguments (int argc, char **argv)
usage2 (_("Invalid certificate expiration period"), optarg);
days_till_exp_warn = atoi (optarg);
}
check_cert = TRUE;
check_cert = true;
goto enable_ssl;
#endif
case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */
#ifdef HAVE_SSL
continue_after_check_cert = TRUE;
continue_after_check_cert = true;
break;
#endif
case 'J': /* use client certificate */
@ -357,7 +360,7 @@ process_arguments (int argc, char **argv)
enable_ssl:
/* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple
parameters, like -S and -C combinations */
use_ssl = TRUE;
use_ssl = true;
if (c=='S' && optarg != NULL) {
int got_plus = strchr(optarg, '+') != NULL;
@ -374,7 +377,7 @@ process_arguments (int argc, char **argv)
else
usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)"));
}
if (specify_port == FALSE)
if (specify_port == false)
server_port = HTTPS_PORT;
#else
/* -C -J and -K fall through to here without SSL */
@ -382,7 +385,7 @@ process_arguments (int argc, char **argv)
#endif
break;
case SNI_OPTION:
use_sni = TRUE;
use_sni = true;
break;
case MAX_REDIRS_OPTION:
if (!is_intnonneg (optarg))
@ -420,7 +423,7 @@ process_arguments (int argc, char **argv)
host_name_length = strlen (host_name) - strlen (p) - 1;
free (host_name);
host_name = strndup (optarg, host_name_length);
if (specify_port == FALSE)
if (specify_port == false)
server_port = virtual_port;
}
} else if ((p = strchr (host_name, ':')) != NULL
@ -430,7 +433,7 @@ process_arguments (int argc, char **argv)
host_name_length = strlen (host_name) - strlen (p) - 1;
free (host_name);
host_name = strndup (optarg, host_name_length);
if (specify_port == FALSE)
if (specify_port == false)
server_port = virtual_port;
}
break;
@ -446,7 +449,7 @@ process_arguments (int argc, char **argv)
usage2 (_("Invalid port number"), optarg);
else {
server_port = atoi (optarg);
specify_port = TRUE;
specify_port = true;
}
break;
case 'a': /* authorization info */
@ -502,7 +505,7 @@ process_arguments (int argc, char **argv)
if (errcode != 0) {
(void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
printf (_("Could Not Compile Regular Expression: %s"), errbuf);
return ERROR;
return false;
}
break;
case INVERT_REGEX:
@ -519,7 +522,7 @@ process_arguments (int argc, char **argv)
#endif
break;
case 'v': /* verbose */
verbose = TRUE;
verbose = true;
break;
case 'm': /* min_page_length */
{
@ -544,7 +547,7 @@ process_arguments (int argc, char **argv)
break;
}
case 'N': /* no-body */
no_body = TRUE;
no_body = true;
break;
case 'M': /* max-age */
{
@ -565,10 +568,10 @@ process_arguments (int argc, char **argv)
}
break;
case 'E': /* show extended perfdata */
show_extended_perfdata = TRUE;
show_extended_perfdata = true;
break;
case 'B': /* print body content after status line */
show_body = TRUE;
show_body = true;
break;
}
}
@ -605,7 +608,7 @@ process_arguments (int argc, char **argv)
if (virtual_port == 0)
virtual_port = server_port;
return TRUE;
return true;
}
@ -945,7 +948,7 @@ check_http (void)
/* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */
if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
&& host_name != NULL && use_ssl == TRUE) {
&& host_name != NULL && use_ssl == true) {
if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT);
asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent);
@ -979,7 +982,7 @@ check_http (void)
}
#ifdef HAVE_SSL
elapsed_time_connect = (double)microsec_connect / 1.0e6;
if (use_ssl == TRUE) {
if (use_ssl == true) {
gettimeofday (&tv_temp, NULL);
result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey);
if (verbose) printf ("SSL initialized\n");
@ -987,9 +990,9 @@ check_http (void)
die (STATE_CRITICAL, NULL);
microsec_ssl = deltime (tv_temp);
elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
if (check_cert == TRUE) {
if (check_cert == true) {
result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
if (continue_after_check_cert == FALSE) {
if (continue_after_check_cert == false) {
if (sd) close(sd);
np_net_ssl_cleanup();
return result;
@ -999,7 +1002,7 @@ check_http (void)
#endif /* HAVE_SSL */
if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
&& host_name != NULL && use_ssl == TRUE)
&& host_name != NULL && use_ssl == true)
asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method_proxy, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
else
asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
@ -1027,10 +1030,10 @@ check_http (void)
* 14.23). Some server applications/configurations cause trouble if the
* (default) port is explicitly specified in the "Host:" header line.
*/
if ((use_ssl == FALSE && virtual_port == HTTP_PORT) ||
(use_ssl == TRUE && virtual_port == HTTPS_PORT) ||
if ((use_ssl == false && virtual_port == HTTP_PORT) ||
(use_ssl == true && virtual_port == HTTPS_PORT) ||
(server_address != NULL && strcmp(http_method, "CONNECT") == 0
&& host_name != NULL && use_ssl == TRUE))
&& host_name != NULL && use_ssl == true))
xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
else
xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port);
@ -1070,9 +1073,8 @@ check_http (void)
}
xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
}
else {
xasprintf (&buf, "%s%s", buf, http_post_data);
} else {
/* or just a newline so the server knows we're done with the request */
xasprintf (&buf, "%s%s", buf, CRLF);
}
@ -1096,9 +1098,14 @@ check_http (void)
*pos = ' ';
}
buffer[i] = '\0';
xasprintf (&full_page_new, "%s%s", full_page, buffer);
free (full_page);
if ((full_page_new = realloc(full_page, pagesize + i + 1)) == NULL)
die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate memory for full_page\n"));
memmove(&full_page_new[pagesize], buffer, i + 1);
full_page = full_page_new;
pagesize += i;
if (no_body && document_headers_done (full_page)) {
@ -1110,25 +1117,7 @@ check_http (void)
elapsed_time_transfer = (double)microsec_transfer / 1.0e6;
if (i < 0 && errno != ECONNRESET) {
#ifdef HAVE_SSL
/*
if (use_ssl) {
sslerr=SSL_get_error(ssl, i);
if ( sslerr == SSL_ERROR_SSL ) {
die (STATE_WARNING, _("HTTP WARNING - Client Certificate Required\n"));
} else {
die (STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
}
}
else {
*/
#endif
die (STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
#ifdef HAVE_SSL
/* XXX
}
*/
#endif
die(STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
}
/* return a CRITICAL status if we couldn't read any data */
@ -1253,32 +1242,73 @@ check_http (void)
}
/* Page and Header content checks go here */
if (strlen (header_expect)) {
if (!strstr (header, header_expect)) {
strncpy(&output_header_search[0],header_expect,sizeof(output_header_search));
if(output_header_search[sizeof(output_header_search)-1]!='\0') {
bcopy("...",&output_header_search[sizeof(output_header_search)-4],4);
if (strlen(header_expect) > 0) {
if (strstr(header, header_expect) == NULL) {
// We did not find the header, the rest is for building the output and setting the state
char output_header_search[30] = "";
strncpy(&output_header_search[0], header_expect,
sizeof(output_header_search));
if (output_header_search[sizeof(output_header_search) - 1] != '\0') {
bcopy("...",
&output_header_search[sizeof(output_header_search) - 4],
4);
}
xasprintf (&msg, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
xasprintf (&msg,
_("%sheader '%s' not found on '%s://%s:%d%s', "),
msg,
output_header_search, use_ssl ? "https" : "http",
host_name ? host_name : server_address, server_port,
server_url);
result = STATE_CRITICAL;
}
}
// At this point we should test if the content is chunked and unchunk it, so
// it can be searched (and possibly printed)
const char *chunked_header_regex_string = "Transfer-Encoding: *chunked *";
regex_t chunked_header_regex;
if (strlen (string_expect)) {
if (!strstr (page, string_expect)) {
strncpy(&output_string_search[0],string_expect,sizeof(output_string_search));
if(output_string_search[sizeof(output_string_search)-1]!='\0') {
bcopy("...",&output_string_search[sizeof(output_string_search)-4],4);
if (regcomp(&chunked_header_regex, chunked_header_regex_string, REG_ICASE)) {
die(STATE_UNKNOWN, "HTTP %s: %s\n", state_text(STATE_UNKNOWN), "Failed to compile chunked_header_regex regex");
}
regmatch_t chre_pmatch[1]; // We actually do not care about this, since we only want to know IF it was found
if (regexec(&chunked_header_regex, header, 1, chre_pmatch, 0) == 0) {
if (verbose) {
printf("Found chunked content\n");
}
// We actually found the chunked header
char *tmp = unchunk_content(page);
if (tmp == NULL) {
die(STATE_UNKNOWN, "HTTP %s: %s\n", state_text(STATE_UNKNOWN), "Failed to unchunk message body");
}
page = tmp;
}
if (strlen(string_expect) > 0) {
if (!strstr(page, string_expect)) {
// We found the string the body, the rest is for building the output
char output_string_search[30] = "";
strncpy(&output_string_search[0], string_expect,
sizeof(output_string_search));
if (output_string_search[sizeof(output_string_search) - 1] != '\0') {
bcopy("...", &output_string_search[sizeof(output_string_search) - 4],
4);
}
xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
result = STATE_CRITICAL;
}
}
if (strlen (regexp)) {
errcode = regexec (&preg, page, REGS, pmatch, 0);
if ((errcode == 0 && invert_regex == 0) || (errcode == REG_NOMATCH && invert_regex == 1)) {
if (strlen(regexp) > 0) {
errcode = regexec(&preg, page, REGS, pmatch, 0);
if ((errcode == 0 && invert_regex == 0) ||
(errcode == REG_NOMATCH && invert_regex == 1)) {
/* OK - No-op to avoid changing the logic around it */
result = max_state_alt(STATE_OK, result);
}
@ -1330,7 +1360,7 @@ check_http (void)
perfd_time (elapsed_time),
perfd_size (page_len),
perfd_time_connect (elapsed_time_connect),
use_ssl == TRUE ? perfd_time_ssl (elapsed_time_ssl) : "",
use_ssl == true ? perfd_time_ssl (elapsed_time_ssl) : "",
perfd_time_headers (elapsed_time_headers),
perfd_time_firstbyte (elapsed_time_firstbyte),
perfd_time_transfer (elapsed_time_transfer));
@ -1352,7 +1382,89 @@ check_http (void)
return STATE_UNKNOWN;
}
/* Receivces a pointer to the beginning of the body of a HTTP message
* which is chunked and returns a pointer to a freshly allocated memory
* region containing the unchunked body or NULL if something failed.
* The result must be freed by the caller.
*/
char *unchunk_content(const char *content) {
// https://en.wikipedia.org/wiki/Chunked_transfer_encoding
// https://www.rfc-editor.org/rfc/rfc7230#section-4.1
char *result = NULL;
size_t content_length = strlen(content);
char *start_of_chunk;
char* end_of_chunk;
long size_of_chunk;
const char *pointer = content;
char *endptr;
long length_of_chunk = 0;
size_t overall_size = 0;
while (true) {
size_of_chunk = strtol(pointer, &endptr, 16);
if (size_of_chunk == LONG_MIN || size_of_chunk == LONG_MAX) {
// Apparently underflow or overflow, should not happen
if (verbose) {
printf("Got an underflow or overflow from strtol at: %u\n", __LINE__);
}
return NULL;
}
if (endptr == pointer) {
// Apparently this was not a number
if (verbose) {
printf("Chunked content did not start with a number at all (Line: %u)\n", __LINE__);
}
return NULL;
}
// So, we got the length of the chunk
if (*endptr == ';') {
// Chunk extension starts here
while (*endptr != '\r') {
endptr++;
}
}
start_of_chunk = endptr + 2;
end_of_chunk = start_of_chunk + size_of_chunk;
length_of_chunk = (long)(end_of_chunk - start_of_chunk);
pointer = end_of_chunk + 2; //Next number should be here
if (length_of_chunk == 0) {
// Chunk length is 0, so this is the last one
break;
}
overall_size += length_of_chunk;
if (result == NULL) {
// Size of the chunk plus the ending NULL byte
result = (char *)malloc(length_of_chunk +1);
if (result == NULL) {
if (verbose) {
printf("Failed to allocate memory for unchunked body\n");
}
return NULL;
}
} else {
// Enlarge memory to the new size plus the ending NULL byte
void *tmp = realloc(result, overall_size +1);
if (tmp == NULL) {
if (verbose) {
printf("Failed to allocate memory for unchunked body\n");
}
return NULL;
} else {
result = tmp;
}
}
memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk);
}
result[overall_size] = '\0';
return result;
}
/* per RFC 2396 */
#define URI_HTTP "%5[HTPShtps]"
@ -1525,13 +1637,13 @@ redir (char *pos, char *status_line)
}
int
bool
server_type_check (const char *type)
{
if (strcmp (type, "https"))
return FALSE;
return false;
else
return TRUE;
return true;
}
int
@ -1546,42 +1658,42 @@ server_port_check (int ssl_flag)
char *perfd_time (double elapsed_time)
{
return fperfdata ("time", elapsed_time, "s",
thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0,
thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0,
TRUE, 0, TRUE, socket_timeout);
thlds->warning?true:false, thlds->warning?thlds->warning->end:0,
thlds->critical?true:false, thlds->critical?thlds->critical->end:0,
true, 0, true, socket_timeout);
}
char *perfd_time_connect (double elapsed_time_connect)
{
return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
return fperfdata ("time_connect", elapsed_time_connect, "s", false, 0, false, 0, false, 0, true, socket_timeout);
}
char *perfd_time_ssl (double elapsed_time_ssl)
{
return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
return fperfdata ("time_ssl", elapsed_time_ssl, "s", false, 0, false, 0, false, 0, true, socket_timeout);
}
char *perfd_time_headers (double elapsed_time_headers)
{
return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
return fperfdata ("time_headers", elapsed_time_headers, "s", false, 0, false, 0, false, 0, true, socket_timeout);
}
char *perfd_time_firstbyte (double elapsed_time_firstbyte)
{
return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", false, 0, false, 0, false, 0, true, socket_timeout);
}
char *perfd_time_transfer (double elapsed_time_transfer)
{
return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout);
return fperfdata ("time_transfer", elapsed_time_transfer, "s", false, 0, false, 0, false, 0, true, socket_timeout);
}
char *perfd_size (int page_len)
{
return perfdata ("size", page_len, "B",
(min_page_len>0?TRUE:FALSE), min_page_len,
(min_page_len>0?TRUE:FALSE), 0,
TRUE, 0, FALSE, 0);
(min_page_len>0?true:false), min_page_len,
(min_page_len>0?true:false), 0,
true, 0, false, 0);
}
void

View file

@ -69,7 +69,6 @@ int process_arguments (int, char **);
int validate_arguments (void);
void print_usage (void);
void print_help (void);
int is_pg_dbname (char *);
int is_pg_logname (char *);
int do_query (PGconn *, char *);
@ -347,10 +346,10 @@ process_arguments (int argc, char **argv)
pgport = optarg;
break;
case 'd': /* database name */
if (!is_pg_dbname (optarg)) /* checks length and valid chars */
usage2 (_("Database name is not valid"), optarg);
else /* we know length, and know optarg is terminated, so us strcpy */
snprintf(dbName, NAMEDATALEN, "%s", optarg);
if (strlen(optarg) >= NAMEDATALEN) {
usage2 (_("Database name exceeds the maximum length"), optarg);
}
snprintf(dbName, NAMEDATALEN, "%s", optarg);
break;
case 'l': /* login name */
if (!is_pg_logname (optarg))
@ -414,45 +413,6 @@ validate_arguments ()
return OK;
}
/******************************************************************************
@@-
<sect3>
<title>is_pg_dbname</title>
<para>&PROTO_is_pg_dbname;</para>
<para>Given a database name, this function returns TRUE if the string
is a valid PostgreSQL database name, and returns false if it is
not.</para>
<para>Valid PostgreSQL database names are less than &NAMEDATALEN;
characters long and consist of letters, numbers, and underscores. The
first character cannot be a number, however.</para>
</sect3>
-@@
******************************************************************************/
int
is_pg_dbname (char *dbname)
{
char txt[NAMEDATALEN];
char tmp[NAMEDATALEN];
if (strlen (dbname) > NAMEDATALEN - 1)
return (FALSE);
strncpy (txt, dbname, NAMEDATALEN - 1);
txt[NAMEDATALEN - 1] = 0;
if (sscanf (txt, "%[_a-zA-Z]%[^_a-zA-Z0-9-]", tmp, tmp) == 1)
return (TRUE);
if (sscanf (txt, "%[_a-zA-Z]%[_a-zA-Z0-9-]%[^_a-zA-Z0-9-]", tmp, tmp, tmp) ==
2) return (TRUE);
return (FALSE);
}
/**
the tango program should eventually create an entity here based on the

View file

@ -1,31 +1,31 @@
/*****************************************************************************
*
*
* Monitoring check_snmp plugin
*
*
* License: GPL
* Copyright (c) 1999-2007 Monitoring Plugins Development Team
*
*
* Description:
*
*
* This file contains the check_snmp plugin
*
*
* Check status of remote machines and obtain system information via SNMP
*
*
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*
*
*****************************************************************************/
const char *progname = "check_snmp";
@ -90,6 +90,7 @@ char *thisarg (char *str);
char *nextarg (char *str);
void print_usage (void);
void print_help (void);
char *multiply (char *str);
#include "regex.h"
char regex_expect[MAX_INPUT_BUFFER] = "";
@ -154,6 +155,8 @@ double *previous_value;
size_t previous_size = OID_COUNT_STEP;
int perf_labels = 1;
char* ip_version = "";
double multiplier = 1.0;
char *fmtstr = "";
static char *fix_snmp_range(char *th)
{
@ -316,7 +319,7 @@ main (int argc, char **argv)
for (i = 0; i < numcontext; i++) {
command_line[10 + i] = contextargs[i];
}
for (i = 0; i < numauthpriv; i++) {
command_line[10 + numcontext + i] = authpriv[i];
}
@ -330,7 +333,7 @@ main (int argc, char **argv)
for (i = 0; i < numoids; i++) {
command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i];
xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
}
command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL;
@ -398,15 +401,15 @@ main (int argc, char **argv)
is_counter=0;
/* We strip out the datatype indicator for PHBs */
if (strstr (response, "Gauge: ")) {
show = strstr (response, "Gauge: ") + 7;
}
show = multiply (strstr (response, "Gauge: ") + 7);
}
else if (strstr (response, "Gauge32: ")) {
show = strstr (response, "Gauge32: ") + 9;
}
show = multiply (strstr (response, "Gauge32: ") + 9);
}
else if (strstr (response, "Counter32: ")) {
show = strstr (response, "Counter32: ") + 11;
is_counter=1;
if(!calculate_rate)
if(!calculate_rate)
strcpy(type, "c");
}
else if (strstr (response, "Counter64: ")) {
@ -416,7 +419,10 @@ main (int argc, char **argv)
strcpy(type, "c");
}
else if (strstr (response, "INTEGER: ")) {
show = strstr (response, "INTEGER: ") + 9;
show = multiply (strstr (response, "INTEGER: ") + 9);
if (fmtstr != "") {
conv = fmtstr;
}
}
else if (strstr (response, "OID: ")) {
show = strstr (response, "OID: ") + 5;
@ -616,7 +622,7 @@ main (int argc, char **argv)
state_string=malloc(string_length);
if(state_string==NULL)
die(STATE_UNKNOWN, _("Cannot malloc"));
current_length=0;
for(i=0; i<total_oids; i++) {
xasprintf(&temp_string,"%.0f",response_value[i]);
@ -638,7 +644,7 @@ main (int argc, char **argv)
state_string[--current_length]='\0';
if (verbose > 2)
printf("State string=%s\n",state_string);
/* This is not strictly the same as time now, but any subtle variations will cancel out */
np_state_write_string(current_time, state_string );
if(previous_state==NULL) {
@ -698,6 +704,8 @@ process_arguments (int argc, char **argv)
{"perf-oids", no_argument, 0, 'O'},
{"ipv4", no_argument, 0, '4'},
{"ipv6", no_argument, 0, '6'},
{"multiplier", required_argument, 0, 'M'},
{"fmtstr", required_argument, 0, 'f'},
{0, 0, 0, 0}
};
@ -715,7 +723,7 @@ process_arguments (int argc, char **argv)
}
while (1) {
c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:z:",
c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:M:f:z:",
longopts, &option);
if (c == -1 || c == EOF)
@ -953,6 +961,16 @@ process_arguments (int argc, char **argv)
if(verbose>2)
printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n");
break;
case 'M':
if ( strspn( optarg, "0123456789.," ) == strlen( optarg ) ) {
multiplier=strtod(optarg,NULL);
}
break;
case 'f':
if (multiplier != 1.0) {
fmtstr=optarg;
}
break;
}
}
@ -1022,7 +1040,7 @@ validate_arguments ()
contextargs[0] = strdup ("-n");
contextargs[1] = strdup (context);
}
if (seclevel == NULL)
xasprintf(&seclevel, "noAuthNoPriv");
@ -1143,6 +1161,44 @@ nextarg (char *str)
/* multiply result (values 0 < n < 1 work as divider) */
char *
multiply (char *str)
{
char *endptr;
double val;
char *conv = "%f";
if(verbose>2)
printf(" multiply input: %s\n", str);
val = strtod (str, &endptr);
if ((val == 0.0) && (endptr == str)) {
if(multiplier != 1) {
die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str);
}
return str;
}
if(verbose>2)
printf(" multiply extracted double: %f\n", val);
val *= multiplier;
if (fmtstr != "") {
conv = fmtstr;
}
if (val == (int)val) {
sprintf(str, "%.0f", val);
} else {
if(verbose>2)
printf(" multiply using format: %s\n", conv);
sprintf(str, conv, val);
}
if(verbose>2)
printf(" multiply result: %s\n", str);
return str;
}
void
print_help (void)
{
@ -1235,6 +1291,10 @@ print_help (void)
printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.')."));
printf (" %s\n", "-D, --output-delimiter=STRING");
printf (" %s\n", _("Separates output on multiple OID requests"));
printf (" %s\n", "-M, --multiplier=FLOAT");
printf (" %s\n", _("Multiplies current value, 0 < n < 1 works as divider, defaults to 1"));
printf (" %s\n", "-f, --fmtstr=STRING");
printf (" %s\n", _("C-style format string for float values (see option -M)"));
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5"));
@ -1287,4 +1347,5 @@ print_usage (void)
printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
printf ("[-M multiplier [-f format]]\n");
}

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -267,8 +267,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/build-aux/depcomp \
$(top_srcdir)/build-aux/mkinstalldirs
@ -297,6 +295,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = @DEFS@
@ -316,6 +316,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -1550,7 +1551,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

View file

@ -1,15 +1,22 @@
#! /usr/bin/perl -w -I ..
#
# HyperText Transfer Protocol (HTTP) Test via check_http
# HyperText Transfer Protocol (HTTP) Test via check_curl
#
#
use strict;
use Test::More;
use POSIX qw/mktime strftime/;
use NPTest;
plan tests => 57;
use vars qw($tests $has_ipv6);
BEGIN {
use NPTest;
$has_ipv6 = NPTest::has_ipv6();
$tests = $has_ipv6 ? 59 : 57;
plan tests => $tests;
}
my $successOutput = '/OK.*HTTP.*second/';
@ -18,6 +25,7 @@ my $plugin = 'check_http';
$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
my $host_tcp_http_ipv6 = getTestParameter("NP_HOST_TCP_HTTP_IPV6", "An IPv6 address providing a HTTP Service (a web server)", "::1");
my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost");
my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
@ -31,26 +39,35 @@ my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
$res = NPTest->testCmd(
"./$plugin $host_tcp_http -wt 300 -ct 600"
);
"./$plugin $host_tcp_http -wt 300 -ct 600"
);
cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
like( $res->output, $successOutput, "Output OK" );
if ($has_ipv6) {
# Test for IPv6 formatting
$res = NPTest->testCmd(
"./$plugin -I $host_tcp_http_ipv6 -wt 300 -ct 600"
);
cmp_ok( $res->return_code, '==', 0, "IPv6 URL formatting is working" );
like( $res->output, $successOutput, "Output OK" );
}
$res = NPTest->testCmd(
"./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
);
"./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
);
like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
$res = NPTest->testCmd(
"./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
);
"./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
);
cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK");
$res = NPTest->testCmd(
"./$plugin $hostname_invalid -wt 1 -ct 2"
);
"./$plugin $hostname_invalid -wt 1 -ct 2"
);
cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
# The first part of the message comes from the OS catalogue, so cannot check this.
# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename

View file

@ -103,7 +103,7 @@ SKIP: {
cmp_ok( $res->return_code, "==", 0, "And also when not found");
}
SKIP: {
skip "No internet access", 23 if $internet_access eq "no";
skip "No internet access", 22 if $internet_access eq "no";
$res = NPTest->testCmd(
"./$plugin --ssl $host_tls_http"

View file

@ -21,7 +21,7 @@ use FindBin qw($Bin);
$ENV{'LC_TIME'} = "C";
my $common_tests = 72;
my $common_tests = 73;
my $ssl_only_tests = 8;
# Check that all dependent modules are available
eval "use HTTP::Daemon 6.01;";
@ -200,6 +200,14 @@ sub run_server {
$c->send_basic_header;
$c->send_crlf;
$c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
} elsif ($r->url->path eq "/chunked") {
my $chunks = ["chunked", "encoding", "test\n"];
$c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
my $chunk = shift @{$chunks};
return unless $chunk;
sleep(1);
return($chunk);
}));
} else {
$c->send_error(HTTP::Status->RC_FORBIDDEN);
}
@ -472,7 +480,8 @@ sub run_common_tests {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm(2);
$result = NPTest->testCmd( $cmd );
alarm(0); };
};
alarm(0);
isnt( $@, "alarm\n", $cmd );
is( $result->return_code, 0, $cmd );
@ -482,7 +491,8 @@ sub run_common_tests {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm(2);
$result = NPTest->testCmd( $cmd );
alarm(0); };
};
alarm(0);
isnt( $@, "alarm\n", $cmd );
isnt( $result->return_code, 0, $cmd );
@ -508,4 +518,9 @@ sub run_common_tests {
};
is( $@, "", $cmd );
$cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
eval {
$result = NPTest->testCmd( $cmd, 5 );
};
is( $@, "", $cmd );
}

View file

@ -12,7 +12,7 @@ use FindBin qw($Bin);
$ENV{'LC_TIME'} = "C";
my $common_tests = 70;
my $common_tests = 71;
my $virtual_port_tests = 8;
my $ssl_only_tests = 12;
# Check that all dependent modules are available
@ -190,6 +190,14 @@ sub run_server {
$c->send_basic_header;
$c->send_crlf;
$c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
} elsif ($r->url->path eq "/chunked") {
my $chunks = ["chunked", "encoding", "test\n"];
$c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
my $chunk = shift @{$chunks};
return unless $chunk;
sleep(1);
return($chunk);
}));
} else {
$c->send_error(HTTP::Status->RC_FORBIDDEN);
}
@ -497,4 +505,9 @@ sub run_common_tests {
};
is( $@, "", $cmd );
$cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
eval {
$result = NPTest->testCmd( $cmd, 5 );
};
is( $@, "", $cmd );
}

View file

@ -9,7 +9,7 @@ use NPTest;
use FindBin qw($Bin);
use POSIX qw/strftime/;
my $tests = 73;
my $tests = 81;
# Check that all dependent modules are available
eval {
require NetSNMP::OID;
@ -57,9 +57,9 @@ if ($pid) {
exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp");
}
END {
END {
foreach my $pid (@pids) {
if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
}
};
@ -268,3 +268,19 @@ like($res->output, '/SNMP WARNING - \d+ \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w 1,2 -c 1" );
is($res->return_code, 2, "Multiple OIDs with some thresholds" );
like($res->output, '/SNMP CRITICAL - \*\d+\* \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1;2 iso.3.6.1.4.1.8072.3.2.67.17=-4;;/', "Multiple OIDs with thresholds output" );
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19");
is($res->return_code, 0, "Test plain .1.3.6.1.4.1.8072.3.2.67.6 RC" );
is($res->output,'SNMP OK - 42 | iso.3.6.1.4.1.8072.3.2.67.19=42 ', "Test plain value of .1.3.6.1.4.1.8072.3.2.67.1" );
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 -M .1");
is($res->return_code, 0, "Test multiply RC" );
is($res->output,'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ' , "Test multiply .1 output" );
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' ");
is($res->return_code, 0, "Test multiply RC + format" );
is($res->output, 'SNMP OK - 4.20 | iso.3.6.1.4.1.8072.3.2.67.19=4.20 ', "Test multiply .1 output + format" );
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' -w 1");
is($res->return_code, 1, "Test multiply RC + format + thresholds" );
is($res->output, 'SNMP WARNING - *4.20* | iso.3.6.1.4.1.8072.3.2.67.19=4.20;1 ', "Test multiply .1 output + format + thresholds" );

View file

@ -32,11 +32,11 @@ my $multilin5 = 'And now have fun with with this: "C:\\"
because we\'re not done yet!';
# Next are arrays of indexes (Type, initial value and increments)
# 0..16 <---- please update comment when adding/removing fields
my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR );
my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' );
# 0..19 <---- please update comment when adding/removing fields
my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER );
my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6', 42 );
# undef increments are randomized
my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef );
my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef, 0 );
# Number of elements in our OID
my $oidelts;

View file

@ -615,27 +615,27 @@ char *perfdata_uint64 (const char *label,
char *data = NULL;
if (strpbrk (label, "'= "))
xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
xasprintf (&data, "'%s'=%" PRIu64 "%s;", label, val, uom);
else
xasprintf (&data, "%s=%ld%s;", label, val, uom);
xasprintf (&data, "%s=%" PRIu64 "%s;", label, val, uom);
if (warnp)
xasprintf (&data, "%s%lu;", data, warn);
xasprintf (&data, "%s%" PRIu64 ";", data, warn);
else
xasprintf (&data, "%s;", data);
if (critp)
xasprintf (&data, "%s%lu;", data, crit);
xasprintf (&data, "%s%" PRIu64 ";", data, crit);
else
xasprintf (&data, "%s;", data);
if (minp)
xasprintf (&data, "%s%lu;", data, minv);
xasprintf (&data, "%s%" PRIu64 ";", data, minv);
else
xasprintf (&data, "%s;", data);
if (maxp)
xasprintf (&data, "%s%lu", data, maxv);
xasprintf (&data, "%s%" PRIu64, data, maxv);
return data;
}
@ -656,27 +656,27 @@ char *perfdata_int64 (const char *label,
char *data = NULL;
if (strpbrk (label, "'= "))
xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
else
xasprintf (&data, "%s=%ld%s;", label, val, uom);
xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
if (warnp)
xasprintf (&data, "%s%ld;", data, warn);
xasprintf (&data, "%s%" PRId64 ";", data, warn);
else
xasprintf (&data, "%s;", data);
if (critp)
xasprintf (&data, "%s%ld;", data, crit);
xasprintf (&data, "%s%" PRId64 ";", data, crit);
else
xasprintf (&data, "%s;", data);
if (minp)
xasprintf (&data, "%s%ld;", data, minv);
xasprintf (&data, "%s%" PRId64 ";", data, minv);
else
xasprintf (&data, "%s;", data);
if (maxp)
xasprintf (&data, "%s%ld", data, maxv);
xasprintf (&data, "%s%" PRId64, data, maxv);
return data;
}

596
po/de.po

File diff suppressed because it is too large Load diff

BIN
po/fr.gmo

Binary file not shown.

601
po/fr.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1 +1 @@
2.3.2
2.3.3

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -299,8 +299,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/build-aux/depcomp \
$(top_srcdir)/build-aux/mkinstalldirs README
@ -329,6 +327,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DBILIBS = @DBILIBS@
DEFS = @DEFS@
@ -348,6 +348,7 @@ ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
@ -1610,7 +1611,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am