check_reversetunnel -> check_process

这个提交包含在:
Dirk Alders 2024-09-14 11:43:10 +02:00
父节点 e502826cf4
当前提交 af8a1ae836
共有 2 个文件被更改,包括 25 次插入23 次删除

25
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

查看文件

@ -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