Browse Source

check_reversetunnel rework

master
Dirk Alders 5 months ago
parent
commit
0435acd697
1 changed files with 9 additions and 4 deletions
  1. 9
    4
      check_reversetunnel

+ 9
- 4
check_reversetunnel View File

1
 #!/bin/sh
1
 #!/bin/sh
2
 #
2
 #
3
+NAGIOS_OK = 0
4
+NAGIOS_ERROR = 2
5
+#
6
+MULTIMEDIA_TUNNEL_REGEX = "\-R 10022:localhost:22.*mount-mockery.de$"
7
+#
3
 AUTOSSH_PIDs=$(pidof autossh)
8
 AUTOSSH_PIDs=$(pidof autossh)
4
 if [ -z $AUTOSSH_PIDs ]; then
9
 if [ -z $AUTOSSH_PIDs ]; then
5
     # no autossh process running
10
     # no autossh process running
6
     echo "No autossh process is running!"
11
     echo "No autossh process is running!"
7
-    exit 2
12
+    exit $NAGIOS_ERROR
8
 else
13
 else
9
     # there is an autossh process
14
     # there is an autossh process
10
-    ps x -q $AUTOSSH_PIDs | grep "\-R 10022:localhost:22.*mount-mockery.de$" 2>&1 > /dev/null
15
+    ps x -q $AUTOSSH_PIDs | grep $MULTIMEDIA_TUNNEL_REGEX 2>&1 > /dev/null
11
     if [ $? -eq 0 ]; then
16
     if [ $? -eq 0 ]; then
12
         echo "The required autossh process is running"
17
         echo "The required autossh process is running"
13
-        exit 0
18
+        exit $NAGIOS_OK
14
     else
19
     else
15
         echo "There are autossh processes, but none of them fit to the required connection details"
20
         echo "There are autossh processes, but none of them fit to the required connection details"
16
-        exit 2
21
+        exit $NAGIOS_ERROR
17
     fi
22
     fi
18
 fi
23
 fi

Loading…
Cancel
Save