From 0435acd69764471164061736b8b8a29c4bf471b9 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sat, 20 Jul 2024 18:30:58 +0200 Subject: [PATCH] check_reversetunnel rework --- check_reversetunnel | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/check_reversetunnel b/check_reversetunnel index 4533987..0508113 100755 --- a/check_reversetunnel +++ b/check_reversetunnel @@ -1,18 +1,23 @@ #!/bin/sh # +NAGIOS_OK = 0 +NAGIOS_ERROR = 2 +# +MULTIMEDIA_TUNNEL_REGEX = "\-R 10022:localhost:22.*mount-mockery.de$" +# AUTOSSH_PIDs=$(pidof autossh) if [ -z $AUTOSSH_PIDs ]; then # no autossh process running echo "No autossh process is running!" - exit 2 + exit $NAGIOS_ERROR else # there is an autossh process - ps x -q $AUTOSSH_PIDs | grep "\-R 10022:localhost:22.*mount-mockery.de$" 2>&1 > /dev/null + ps x -q $AUTOSSH_PIDs | grep $MULTIMEDIA_TUNNEL_REGEX 2>&1 > /dev/null if [ $? -eq 0 ]; then echo "The required autossh process is running" - exit 0 + exit $NAGIOS_OK else echo "There are autossh processes, but none of them fit to the required connection details" - exit 2 + exit $NAGIOS_ERROR fi fi