From af8a1ae8363a14996d565a883c62a4fede372309 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sat, 14 Sep 2024 11:43:10 +0200 Subject: [PATCH] check_reversetunnel -> check_process --- check_process | 25 +++++++++++++++++++++++++ check_reversetunnel | 23 ----------------------- 2 files changed, 25 insertions(+), 23 deletions(-) create mode 100755 check_process delete mode 100755 check_reversetunnel diff --git a/check_process b/check_process new file mode 100755 index 0000000..db90f63 --- /dev/null +++ b/check_process @@ -0,0 +1,25 @@ +#!/bin/bash +# +NAGIOS_OK=0 +NAGIOS_ERROR=2 +# +NAGIOS_NAME="$2" +PROCESS_NAME="$4" +PROCESS_REGEX="$5" +# +PIDs=$(pidof $PROCESS_NAME) +if [[ -z $PIDs ]]; then + # no such process running + echo "ERROR - No $NAGIOS_NAME process is running!" + exit $NAGIOS_ERROR +else + # there is such a process + ps x -q "$PIDs" | grep "$PROCESS_REGEX" 2>&1 > /dev/null + if [[ $? -eq 0 ]]; then + echo "OK - The required $NAGIOS_NAME process is running" + exit $NAGIOS_OK + else + echo "ERROR - There are processes fitting to $PROCESS_NAME, but none of them fit to the required regex" + exit $NAGIOS_ERROR + fi +fi diff --git a/check_reversetunnel b/check_reversetunnel deleted file mode 100755 index 8123394..0000000 --- a/check_reversetunnel +++ /dev/null @@ -1,23 +0,0 @@ -#!/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 "ERROR - No autossh process is running!" - exit $NAGIOS_ERROR -else - # there is an autossh process - ps x -q $AUTOSSH_PIDs | grep "$MULTIMEDIA_TUNNEL_REGEX" 2>&1 > /dev/null - if [ $? -eq 0 ]; then - echo "OK - The required autossh process is running" - exit $NAGIOS_OK - else - echo "ERROR - There are autossh processes, but none of them fit to the required connection details" - exit $NAGIOS_ERROR - fi -fi