check_reversetunnel -> check_process
This commit is contained in:
parent
e502826cf4
commit
af8a1ae836
25
check_process
Executable file
25
check_process
Executable file
@ -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
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user