D7net
Home
Console
Upload
information
Create file
Create Folder
About
Tools
Path :
/
lib64
/
tls
/
..
/
sasl2
/
..
/
nagios
/
plugins
/
Filename :
check_mysql_uptime.sh
back
Edit
Copy
#!/bin/bash set -o pipefail MYSQLADMIN=$(which mysqladmin) AWK=$(which awk) CMD="status" [[ -z "$MYSQLADMIN" ]] && \ printf "\342\235\214 CRITICAL: mysqladmin binary not present on $HOSTNAME" \ && exit 2 CHK_ERR="$( ( sudo $MYSQLADMIN $CMD | $AWK '{print $2}' ) 2>&1 >/dev/null )" [[ ! -z "$CHK_ERR" ]] && \ printf "\342\235\214 CRITICAL: 'mysqladmin status' exited with error: $CHK_ERR\n" \ && exit 2 MYUPTIME=$(sudo $MYSQLADMIN $CMD | $AWK '{print $2}') WARNTIME="120" CRITTIME="20" [[ "$MYUPTIME" -le "$CRITTIME" ]] && \ printf "\342\235\214 CRITICAL: mysql server uptime less than or equal to $CRITTIME seconds\n" \ && exit 2 [[ "$MYUPTIME" -le "$WARNTIME" ]] && \ printf "⚠️ WARNING: mysql server uptime less than or equal to $WARNTIME seconds\n" \ && exit 1 printf "\360\237\222\232 OK: mysql server uptime is $MYUPTIME seconds\n" \ && exit 0