HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/thread-self/root/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