403Webshell
Server IP : 198.38.94.67  /  Your IP : 216.73.217.74
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/lib64/nagios/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/lib64/nagios/plugins/check_qps_dnsdist.sh
#!/bin/bash
#
# Icinga check on DNS servers running DNSdist and
# dnsdist-query.py via cron, to detect QPS spikes
#
# Accepts argument with custom value to check for past minutes
# - default is 15 minutes
#

# Config Defaults
LOG_FILE="/var/log/dnsdist/query_monitor.log"
DEFAULT_AGE_MINUTES=15
SPIKE_MARKER="QPS spike detected!"
REST_MARKER="Traffic spike is distributed"
DOMAIN_MARKER="High query domain"

# CLI override
AGE_MINUTES=${1:-$DEFAULT_AGE_MINUTES}
MAX_AGE_SECONDS=$((AGE_MINUTES * 60))

# Check log file exists
if [ ! -f "${LOG_FILE}" ]; then
  echo "UNKNOWN - Log file not found: ${LOG_FILE}"
  exit 3
fi

# Get last spike line and timestamp
last_spike_line=$(grep -nF "${SPIKE_MARKER}" "${LOG_FILE}" | tail -n 1)
if [ -z "${last_spike_line}" ]; then
  echo "OK - No QPS spike logged"
  exit 0
fi

spike_line_no=$(echo "${last_spike_line}" | cut -d':' -f1)
spike_log_line=$(echo "${last_spike_line}" | cut -d':' -f2-)
spike_ts=$(echo "${spike_log_line}" | cut -d' ' -f1,2)
spike_epoch=$(date -d "${spike_ts}" +%s 2>/dev/null)
now_epoch=$(date +%s)

# Check if spike is within time window
if [ -z "${spike_epoch}" ] || [ $((now_epoch - spike_epoch)) -gt ${MAX_AGE_SECONDS} ]; then
  echo "OK - No spike detected in the last ${AGE_MINUTES} minute(s)"
  exit 0
fi

# Pull associated domain details from next few lines
next_lines=$(tail -n +"${spike_line_no}" "${LOG_FILE}" | head -n 10)
domains=$(echo "${next_lines}" | grep -F "${DOMAIN_MARKER}" | cut -d':' -f3-)

if [ -n "${domains}" ]; then
  echo -e "CRITICAL - QPS spike with dominant domain(s) in past ${AGE_MINUTES} minutes:\n${domains}"
else
  echo "CRITICAL - QPS spike detected in past ${AGE_MINUTES} minutes (distributed: 'Rest' traffic)"
fi
exit 2

Youez - 2016 - github.com/yon3zu
LinuXploit