Package: monitoring-plugins-contrib Version: 42.20230308 Severity: wishlist
Dear Maintainer, the (dsa-)check-statusfile plugin included in the package would be even more useful if the dsa-wrap-nagios-check script that can be used to generate the statusfile for the plugin would also be included. Without it the user needs to implement the dsa-wrap-nagios-check itself to use the dsa-check-statusfile. Attached patch against debian/42.20230308 of the nagios-plugins-contrib source package works for me. Please consider inclusion. Best regards -- Matthias Förste gnupg encrypted messages are welcome - key ID: 0F51DA21 gnupg fingerprint: 590C 5DF1 C3B8 D072 555B 54F5 9363 2C80 0F51 DA21 internet & unix support Heiko Schlittermann Tannenstraße 2 - 01099 Dresden Web: http://www.schlittermann.de/ Tel.: +49 351 8029981 Fax: +49 351 8029983
diff --git a/dsa/Makefile b/dsa/Makefile index 18c87c2..3451bee 100644 --- a/dsa/Makefile +++ b/dsa/Makefile @@ -1,9 +1,10 @@ #!/usr/bin/make -f PLUGIN:=$(shell cd checks; ls -1 | sed 's,^dsa-,,;s,-,_,g') -CRONJOBS:=$(shell cd sbin; ls -1 | sed 's,^dsa-,,') +CRONJOBS:=$(shell cd sbin; ls -1 dsa-update-*| sed 's,^dsa-,,') INIFILES:=etc/obsolete-packages-ignore DOCFILES:=$(wildcard *.cmd) +NAGIOSLIBDIR:=/usr/lib/nagios check_%: cp checks/dsa-`echo $@ | sed 's,_,-,g'` $@ @@ -20,4 +21,5 @@ include ../common.mk install:: install -d $(DESTDIR)$(INIDIR)/obsolete-packages-ignore.d - + install -d $(DESTDIR)$(NAGIOSLIBDIR) + install -m 755 -o root -g root sbin/dsa-wrap-nagios-check $(DESTDIR)$(NAGIOSLIBDIR)/wrap-nagios-check diff --git a/dsa/copyright b/dsa/copyright index 6006f7a..a9a109c 100644 --- a/dsa/copyright +++ b/dsa/copyright @@ -11,6 +11,7 @@ checks/dsa-check-running-kernel:# Copyright 2010 Uli Martens checks/dsa-check-running-kernel:# Copyright 2011 Alexander Reichle-Schmehl sbin/dsa-update-apt-status:# Copyright 2009 Peter Palfrader sbin/dsa-update-unowned-file-status:# Copyright 2012 Peter Palfrader +sbin/dsa-wrap-nagios-check:# Copyright 2017 Peter Palfrader Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/dsa/sbin/dsa-wrap-nagios-check b/dsa/sbin/dsa-wrap-nagios-check new file mode 100755 index 0000000..cda7b2d --- /dev/null +++ b/dsa/sbin/dsa-wrap-nagios-check @@ -0,0 +1,90 @@ +#!/bin/sh + +# Copyright 2017 Peter Palfrader +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# wrap a nagios check and write a status-file to be used with dsa-check-statusfile + +set -u + +STATUSDIR=/var/cache/dsa/nagios + +usage(){ + ret=$1 + + cat <<EOF +$0: usage: + $0 <options> <nagios-check> [nagios-check-options] + + Calls nagios-check and stores its result in a state + file in status-dir. The state file is named after + the nagios check (but can be overridden with -s). + + -S <dir> state dir ($STATUSDIR) + -s <filename> state file name + -h print this help +EOF + + exit $ret +} + + +while getopts S:s:h opt ; do + case "$opt" in + S) STATUSDIR="$OPTARG" ;; + s) STATUSFILE="$OPTARG";; + h) usage 0 ;; + ?) usage 1 ;; + esac +done +shift $(($OPTIND - 1)) +if [ "$#" = 0 ]; then + usage 1 >&2 +fi + +if [ -z "${STATUSFILE:-}" ]; then + STATUSFILE="$(basename "$1")" +fi + +if ! [ -d "$STATUSDIR" ]; then + echo >&2 "status directory $STATUSDIR does not exist." + exit 3 +fi + +tmp=`mktemp` +trap "rm -f '$tmp'" exit +"$@" > "$tmp" 2>&1 +result="$?" +case "$result" in + 0) + st="OK" + ;; + 1) + st="WARNING" + ;; + 2) + st="CRITICAL" + ;; + *) + st="UNKNOWN" + ;; +esac +(echo "$st"; cat "$tmp") > "$STATUSDIR/$STATUSFILE" diff --git a/dsa/update-files.sh b/dsa/update-files.sh index 6539cf3..c50ab5b 100755 --- a/dsa/update-files.sh +++ b/dsa/update-files.sh @@ -3,7 +3,7 @@ # update all files from the dsa nagios git find checks sbin share etc -type f | while read i; do tmp=`mktemp` - if wget -O "${tmp}" "https://salsa.debian.org/dsa-team/mirror/dsa-nagios/raw/master/dsa-nagios-checks/${i}"; then + if wget -O "${tmp}" "https://salsa.debian.org/dsa-team/mirror/dsa-nagios/-/raw/master/dsa-nagios-checks/${i}"; then mv "${tmp}" "$i" else rm -f "${tmp}"
signature.asc
Description: PGP signature