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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib64/nagios/plugins/check_a2_packets.mvps
#!/bin/bash
# Ref - SYSENG-26866 - Alert if packets per second crosses 30k/s
#

_packet_per_sec_collect() {

  _packets_warn=20000
  _packets_crit=30000
  _packets_last_file="/tmp/packets_incoming_count"

  # first create a file to save first value
  if [ ! -f "${_packets_last_file}" ]; then
    grep -Ev 'lo:' /proc/net/dev | tail -1 | awk '{print $3}' > ${_packets_last_file}
    exit
  else
    # find delta packet value and calculate by seconds
    # alert or warn as needed

    _packets_last_file_age=$(stat -c %Y -- ${_packets_last_file})
    _packets_dt_current=$(date +%s)
    _packets_last_file_age_seconds=$(( _packets_dt_current - _packets_last_file_age ))
    _packets_last=$(cat ${_packets_last_file})
    _packets_current=$(grep -Ev 'lo:' /proc/net/dev | tail -1 | awk '{print $3}')

    if [ "${_packets_current}" -gt "${_packets_last}" ] && [ "${_packets_last_file_age_seconds}" -gt 1 ]; then
      _packets_delta_f=$(( _packets_current - _packets_last ))
      _packets_delta=$(( _packets_delta_f / _packets_last_file_age_seconds ))
    fi

    if [ -n "${_packets_delta}" ]; then
      if [ "${_packets_delta}" -gt "${_packets_warn}" ] && [ "${_packets_delta}" -lt "${_packets_crit}" ]; then
        echo "$(hostname) has ${_packets_delta} received packets per second"
        exit 1
      elif [ "${_packets_delta}" -gt "${_packets_crit}" ]; then
        echo "$(hostname) has ${_packets_delta} received packets per second"
        exit 2
      else
        echo "$(hostname) has ${_packets_delta} received packets per second"
        exit 0
      fi
    else
      echo "$(hostname) has 0 received packets per second"
      exit 0
    fi
  fi
  grep -Ev 'lo:' /proc/net/dev | tail -1 | awk '{print $3}' > ${_packets_last_file}
}

_packet_per_sec_collect

Youez - 2016 - github.com/yon3zu
LinuXploit