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: //usr/lib64/nagios/plugins/check_a2_jbk_client_limits.sh
#!/bin/bash
_zfs_clients=$(df -hm | grep "backups/" | grep -E "az|mi|nl|sg" -c)
_zfs_clients_gt3t=$(df -hm | grep "backups/"| awk '$3 > 3000000' | wc -l)
_zfs_clients_lt3t=$(df -hm | grep "backups/"| awk '$3 < 3000000' | wc -l)

if [[ "${_zfs_clients}" -gt 35 ]]; then
  if [[ "${_zfs_clients_gt3t}" -gt 5 ]] && [[ "${_zfs_clients_gt3t}" -lt 10 ]]; then
    echo -e "This server has ${_zfs_clients} clients, out of that ${_zfs_clients_gt3t} are > 3TBs and ${_zfs_clients_lt3t} are < 3TBs. Please consider migrating a couple of clients."
    exit 1
  elif [[ "${_zfs_clients_gt3t}" -gt 10 ]]; then
    echo -e "This server already has ${_zfs_clients_gt3t} large clients. Out of total ${_zfs_clients}, ${_zfs_clients_gt3t} are > 3TBs and ${_zfs_clients_lt3t} are < 3TBs, please consider migrating a couple of large clients for better storage balance."
    exit 1
  elif [[ "${_zfs_clients}" -gt 32 ]]; then
    echo -e "This server has ${_zfs_clients} clients, out of that ${_zfs_clients_gt3t} are > 3TBs and ${_zfs_clients_lt3t} are < 3TBs. Please consider migrating a couple of clients."
    exit 1
  fi
else
  echo "client total is healthy"
  exit 0
fi