Make service configuring correct for rpm

This commit is contained in:
Alexey Berezhok
2024-05-04 22:15:25 +03:00
parent c1e7097201
commit c4646bd8e8
10 changed files with 89 additions and 31 deletions

View File

@@ -86,13 +86,23 @@ get_srv_state() {
rtime="0"
# Searching related pids
if [ -z $3 ]; then
pids=$(pidof $name | tr ' ' '|')
if [ -f /etc/redhat-release ] && [ "$name" = "php-fpm" ]; then
pids=''
for php_pid in $(pidof php-fpm); do
process_info=$(ps -p "$php_pid" -o args | tail -n1 | grep "$srv")
if [ -n "$process_info" ]; then
pids="${pids}|${php_pid}"
fi
done
else
pids=$(pidof -x $name | tr ' ' '|')
fi
if [ -z "$pids" ] && [ "$name" != 'nginx' ]; then
pids=$(pgrep $name | tr '\n' '|')
if [ -z $3 ]; then
pids=$(pidof $name | tr ' ' '|')
else
pids=$(pidof -x $name | tr ' ' '|')
fi
if [ -z "$pids" ] && [ "$name" != 'nginx' ]; then
pids=$(pgrep $name | tr '\n' '|')
fi
fi
# Prevent from an SSH false positive when there is a TTY or SFTP connection but service is down
@@ -164,14 +174,25 @@ fi
# Checking PHP intepreter
if [ -n "$WEB_BACKEND" ] && [ "$WEB_BACKEND" != 'remote' ]; then
php_versions=$(ls /usr/sbin/php*fpm* | cut -d'/' -f4 | sed 's|php-fpm||')
for version in $php_versions; do
proc_name="php-fpm${version}"
service_name="php${version}-fpm"
get_srv_state "$proc_name"
data="$data\nNAME='$service_name' SYSTEM='php interpreter' STATE='$state'"
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
done
if [ -f /etc/redhat-release ]; then
php_versions=$(ls /opt/remi/php*/root/sbin/php-fpm | cut -d'/' -f4 | sed 's|php||')
for version in $php_versions; do
proc_name="php-fpm"
service_name="php${version}"
get_srv_state "$proc_name"
data="$data\nNAME='$service_name-php-fpm' SYSTEM='php interpreter' STATE='$state'"
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
done
else
php_versions=$(ls /usr/sbin/php*fpm* | cut -d'/' -f4 | sed 's|php-fpm||')
for version in $php_versions; do
proc_name="php-fpm${version}"
service_name="php${version}-fpm"
get_srv_state "$service_name" "$proc_name"
data="$data\nNAME='$service_name' SYSTEM='php interpreter' STATE='$state'"
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
done
fi
fi
# Checking WEB Proxy
@@ -210,6 +231,11 @@ if [ -n "$ANTIVIRUS_SYSTEM" ] && [ "$ANTIVIRUS_SYSTEM" != 'remote' ]; then
if [ "$ANTIVIRUS_SYSTEM" == 'clamav' ]; then
ANTIVIRUS_SYSTEM='clamd'
fi
if [ -f /etc/redhat-release ]; then
if [ "$ANTIVIRUS_SYSTEM" == 'clamav-daemon' ]; then
ANTIVIRUS_SYSTEM='clamd'
fi
fi
get_srv_state "$ANTIVIRUS_SYSTEM"
else
if [ "$ANTIVIRUS_SYSTEM" == 'clamav-daemon' ]; then