| Server IP : 198.38.94.67 / Your IP : 216.73.217.142 Web Server : LiteSpeed System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64 User : azfilmst ( 1070) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/lib64/nagios/plugins/ |
Upload File : |
#!/bin/bash
# check_nimbus - check nimbus core services and statuses
# Requirements: n/a
# Author: Tsvetan Gerov <tsvetan@worldhost.group>
# Version 0.3
# Initialize flags and error message
CRTIICAL=false
WARNING=false
ERROR_MESSAGE=""
# Check all PHP FPM services
check_fpm(){
INSTALLED_PHP=$(ls /usr/bin/php[0-9]*)
for PHP in $INSTALLED_PHP; do
FPM=$(echo "$(basename $PHP)-fpm.service")
if ! systemctl is-active $FPM >/dev/null 2>&1; then
CRTIICAL=true
ERROR_MESSAGE+="$FPM is down, "
fi
done
}
# Check Platform Agent
check_agent(){
local NAME="platform-agent.service"
if ! systemctl is-active $NAME >/dev/null 2>&1; then
CRTIICAL=true
ERROR_MESSAGE+="$NAME is down, "
fi
}
# Check Platform Metrics service
check_platform-metrics(){
local NAME="platform-metrics.service"
if ! systemctl is-active $NAME >/dev/null 2>&1; then
CRTIICAL=true
ERROR_MESSAGE+="$NAME is down, "
fi
}
# Check Platform Metrics Schedule service
check_platform-metrics-schedule(){
local NAME="platform-metrics-schedule.service"
if ! systemctl is-active $NAME >/dev/null 2>&1; then
CRTIICAL=true
ERROR_MESSAGE+="$NAME is down, "
fi
}
# Check ElasticSearch
check_elastic(){
CODE=$(curl 127.0.0.1:9200 -s -o /dev/null -w "%{http_code}")
if [ $CODE -ne "200" ]; then
CRTIICAL=true
ERROR_MESSAGE+="ElasticSearch is down, "
fi
}
# Check Redis
check_redis(){
if ! redis-cli ping >/dev/null 2>&1; then
CRTIICAL=true
ERROR_MESSAGE+="Redis is down, "
fi
}
# Perform checks
if ls /usr/bin/php[0-9]* 1>/dev/null 2>&1; then
check_fpm
fi
if [ -f "/etc/systemd/system/platform-agent.service" ]; then
check_agent
fi
if [ -f "/etc/systemd/system/platform-metrics.service" ]; then
check_platform-metrics
fi
if [ -f "/etc/systemd/system/platform-metrics-schedule.service" ]; then
check_platform-metrics-schedule
fi
if [ -f "/usr/share/elasticsearch/bin/elasticsearch" ]; then
check_elastic
fi
if [ -f "/usr/bin/redis-server" ]; then
check_redis
fi
# Return final state
if [ "$CRTIICAL" = true ]; then
echo "[CRTIICAL] ${ERROR_MESSAGE%, }"
exit 2
elif [ "$WARNING" = true ]; then
echo "[WARNING] ${ERROR_MESSAGE%, }"
exit 1
else
echo "[OK] All services are running correctly."
exit 0
fi