efk/scripts/Monitor.sh
2021-08-29 00:02:22 +08:00

26 lines
416 B
Bash
Executable File

#!/bin/bash
INTERVAL=2
function Init {
local self_count=$(pgrep -cx "$(basename $0)")
[ 0 -eq $? ] || exit 1
[ 1 -eq $self_count ] || exit 1
type sar > /dev/null || exit 1
}
function Main {
cd $(dirname $0) || exit 1
while sleep $INTERVAL; do
for proc in $(find . -type f -name "mon_*" \
-executable); do
$proc &
done
done
}
# start
Init
Main