Browse Source

check_reversetunnel -> check_process

master
Dirk Alders 3 months ago
parent
commit
af8a1ae836
2 changed files with 25 additions and 23 deletions
  1. 25
    0
      check_process
  2. 0
    23
      check_reversetunnel

+ 25
- 0
check_process View File

@@ -0,0 +1,25 @@
1
+#!/bin/bash
2
+#
3
+NAGIOS_OK=0
4
+NAGIOS_ERROR=2
5
+#
6
+NAGIOS_NAME="$2"
7
+PROCESS_NAME="$4"
8
+PROCESS_REGEX="$5"
9
+#
10
+PIDs=$(pidof $PROCESS_NAME)
11
+if [[ -z $PIDs ]]; then
12
+    # no such process running
13
+    echo "ERROR - No $NAGIOS_NAME process is running!"
14
+    exit $NAGIOS_ERROR
15
+else
16
+    # there is such a process
17
+    ps x -q "$PIDs" | grep "$PROCESS_REGEX" 2>&1 > /dev/null
18
+    if [[ $? -eq 0 ]]; then
19
+        echo "OK - The required $NAGIOS_NAME process is running"
20
+        exit $NAGIOS_OK
21
+    else
22
+        echo "ERROR - There are processes fitting to $PROCESS_NAME, but none of them fit to the required regex"
23
+        exit $NAGIOS_ERROR
24
+    fi
25
+fi

+ 0
- 23
check_reversetunnel View File

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

Loading…
Cancel
Save