HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //lib64/nagios/plugins/check_a2_dimm.shared
#!/bin/bash
# Ref - SYSENG-27573 - Simplified dimm check on SRTs
#

# If not physical server, exit
if ! [[ $(systemd-detect-virt) == "none" ]]; then
  exit
fi

# min max values for SRTs (64|128|256) GBs and other things
_mem_min_64GB=64000000
_mem_max_64GB=66000000
_mem_min_128GB=130000000
_mem_max_128GB=135000000
_mem_min_256GB=260000000
_mem_max_256GB=270000000
_mem_total=$(grep MemTotal /proc/meminfo  | awk '{print $2}')
_mem_total_in_gb=$(grep MemTotal /proc/meminfo  | awk '{print $2/1024/1024}')
_mem_total_in_gb_round=$(printf "%.0f" ${_mem_total_in_gb})
_mem_error=$(ipmitool sel elist | grep "Memory*.*DIMM")

# we will check if an SRT is one of 64|128|256 GB server, else alert
if [[ "${_mem_total}" -gt "${_mem_min_64GB}" && "${_mem_total}" -lt "${_mem_max_64GB}" ]]; then
  echo "server has ${_mem_total_in_gb_round}GB DIMMs"
  exit 0
elif [[ "${_mem_total}" -gt "${_mem_min_128GB}" && "${_mem_total}" -lt "${_mem_max_128GB}" ]]; then
  echo "server has ${_mem_total_in_gb_round}GB DIMMs"
  exit 0
elif [[ "${_mem_total}" -gt "${_mem_min_256GB}" && "${_mem_total}" -lt "${_mem_max_256GB}" ]]; then
  echo "server has ${_mem_total_in_gb_round}GB DIMMs"
  exit 0
else
  echo "server has ${_mem_total_in_gb_round}GB, server might be missing one or more dimms"
  exit 2
fi

# collect DIMM errors as warning, this will not alert for now
if [[ -n "${_mem_error}" ]]; then
  echo "found DIMM error event(s), clear if its old using command: ipmitool sel clear"
  exit 1
else
  echo "no DIMM errors found"
  exit 0
fi