Skip to content
Snippets Groups Projects
Commit 02f41b36 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

check_conn: no text on STDERR if portcheck fails

parent 39038e1a
No related branches found
No related tags found
1 merge request!291Simple task/7546 icinga check für ablaufende gitlab tokens
...@@ -9,16 +9,13 @@ ...@@ -9,16 +9,13 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2021-11-05 v0.0 <axel.hahn@iml.unibe.ch> # 2021-11-05 v0.0 <axel.hahn@iml.unibe.ch>
# 2023-07-27 v1.1 <axel.hahn@unibe.ch> update help page # 2023-07-27 v1.1 <axel.hahn@unibe.ch> update help page
# 2025-02-10 v1.2 <axel.hahn@unibe.ch> no text on STDERR if portcheck fails
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions || exit 1
export self_APPVERSION=1.2
export self_APPVERSION=1.1
cfgfile=$( dirname $0 )/$( basename $0 ).cfg cfgfile=$( dirname $0 )/$( basename $0 ).cfg
out="" out=""
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -87,12 +84,9 @@ case "$1" in ...@@ -87,12 +84,9 @@ case "$1" in
*) *)
esac esac
configline=$( ph.getValueWithParam "" t "$@" ) configline=$( ph.getValueWithParam "" t "$@"
test -z "$configline" || cfgfile="" test -z "$configline" || cfgfile=""
typeset -i iWarnings=0 typeset -i iWarnings=0
typeset -i iErrors=0 typeset -i iErrors=0
typeset -i iOK=0 typeset -i iOK=0
...@@ -107,18 +101,18 @@ do ...@@ -107,18 +101,18 @@ do
$myline" $myline"
# --- syntax check of config entry # --- syntax check of config entry
echo "$myline" | grep -E "^(tcp|udp)/[a-z][a-z0-9\.\-]*/[0-9]*$" >/dev/null 2>&1 if ! echo "$myline" | grep -Eq "^(tcp|udp)/[a-z][a-z0-9\.\-]*/[0-9]*$"
if [ $? -ne 0 ]; then then
out="$out SKIP: INVALID ENTRY" out="$out SKIP: INVALID ENTRY"
iWarnings=$iWarnings+1 iWarnings=$iWarnings+1
else else
>/dev/$myline if timeout 1 bash -c "> /dev/$myline " 2>/dev/null
if [ $? -ne 0 ]; then then
out="$out FAILED"
iErrors=$iErrors+1
else
out="$out OK" out="$out OK"
iOK=$iOK+1 iOK=$iOK+1
else
out="$out FAILED"
iErrors=$iErrors+1
fi fi
fi fi
done done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment