Server IP : 149.255.58.128 / Your IP : 216.73.216.44
System : Linux cloud516.thundercloud.uk 5.14.0-427.26.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 17 15:51:13 EDT 2024 x86_64
PHP Version : 8.2.28
Disable Function : allow_url_include, apache_child_terminate, apache_setenv, exec, passthru, pcntl_exec, posix_kill, posix_mkfifo, posix_getpwuid, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_seteuid, posix_setegid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, shell_exec, show_source, system
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Upload Files :
Command :
Current File : /lib64/nagios/plugins//check_mysql_replication.sh
#!/bin/sh
###################################################################
# The script is a plugin for nagios. The script is used to check
# the replication status between the Master and Slave. The script
# has to be executed from the master.
# Written by : Jithesh M K
# Created on : July, 2006
# Updates on : 09/12/15 Philip A. O'Malley (to make it work)
###################################################################
# Nagios alert status
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
# Script Variables
SLAVEIP_1=
REPLUSERNAME=
REPLPASSWD=
CRITICAL_VALUE=3000
WARNING_VALUE=1500
# Command Overrides
while test -n "$1"; do
case "$1" in
--slavehost|-H)
SLAVEIP_1=$2
shift
;;
--username|-u)
REPLUSERNAME=$2
shift
;;
--password|-p)
REPLPASSWD=$2
shift
;;
*)
echo "Unknown argument: $1"
exit $STATE_UNKNOWN
;;
esac
shift
done
# Calculations
iSlave_1=`mysql -h $SLAVEIP_1 -u $REPLUSERNAME -p$REPLPASSWD -e "show slave status" | grep bin | cut -f7`
iMaster=`mysql -u $REPLUSERNAME -p$REPLPASSWD -e "show master status" | grep bin | cut -f2`
if test -z $iSlave_1
then
echo "CRITICAL ERROR in IPC with $SLAVEIP_1"
exit $STATE_CRITICAL
exit
fi
if test -z $iSlave_1
then
echo "CRITICAL ERROR in IPC with localhost"
exit $STATE_CRITICAL
exit
fi
iDiff_1=`expr $iMaster - $iSlave_1`
perfData="replication_lag="$iDiff_1";"$WARNING_VALUE";"$CRITICAL_VALUE";0;"
if [ $iDiff_1 -gt $CRITICAL_VALUE ]
then
echo "CRITICAL Master Log Position : "$iMaster" 1st Slave Log Position : "$iSlave_1 " Difference : "$iDiff_1"|"$perfData
exit $STATE_CRITICAL
elif [ $iDiff_1 -gt $WARNING_VALUE ]
then
echo "WARNING Master Log Position : "$iMaster" 1st Slave Log Position : "$iSlave_1 " Difference : "$iDiff_1"|"$perfData
exit $STATE_WARNING
else
echo "OK Master Log Position : "$iMaster" 1st Slave Log Position : "$iSlave_1 " Difference : "$iDiff_1"|"$perfData
exit $STATE_OK
fi