This commit is contained in:
2023-04-26 18:28:51 -05:00
parent 3e83f00868
commit 34ffc4eb5e
2 changed files with 23 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERS='4.3.28-04262023'
VERS='4.4.2-04262023'
NODETYPES=PW
NODETYPES=MYSQL,LB,WEB,NC,WPD,LPD,PW

View File

@@ -563,44 +563,40 @@ STATUS(){
[ "${ST_ACTION}" != "check" ] && echo -en " ${idsCL[LightCyan]}Getting drives from server ... ${idsCL[Default]}"
declare -A partitions
partitions=`${NCMD} df -hBM | grep -vE '^Filesystem|tmpfs|cdrom|loop|overlay|shm|-volume|Music|media-data|Software|ram|Backups' | awk '{ print $5 " " $1 }' | while read output; do echo $output | awk '{ print $2 }'; done;`
partitions2=`echo ${partitions[*]}`
partitions3=(${partitions2})
DRIVEINFO=$(ssh root@${host_ip[$hostid]} df -BM | grep -vE '^Filesystem|tmpfs|cdrom|@|ram|loop|udev|veeamimage|nvme|localhost|shm|mmcblk|overlay|-volume|Music|Software' | awk '{ print $1 " " $2 " " $4 }')
DRIVEINFO=(${DRIVEINFO})
echo -en "\e[1A";
echo -e "\e[0K\r"
echo -e "\e[0K\r"qqqaqq
for partition in "${partitions3[@]}"; do
if [ "${partition}" != "udev" ] && [ "${partition}" != "/dev/sda1" ]; then
pname=`echo "${partition}" | awk -F'/' ' { print $NF } '` >/dev/null 2>&1
pname=${pname#*vg-}
if [ "${ST_ACTION}" != "check" ]; then
c=0; cw=20; spc=''
spc1=${cw}-${#pname}
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
echo -en " ${pname}$spc: "
NUMDRIVES=$((${#DRIVEINFO[@]} / 3))
for ((i = 0 ; i <= $((${NUMDRIVES}-1)) ; i++)); do
ii=$((${i}*3))
pname=`echo "${DRIVEINFO[${ii}]}" | awk -F'/' ' { print $NF } '` >/dev/null 2>&1
pname=${pname#*vg-}
if [ ${DRIVEINFO[$((${ii}+1))]//M/} -gt 1024 ]; then
freespace=${DRIVEINFO[$((${ii}+2))]}
if [[ ${freespace} -gt 1024 ]]; then
fsdsp=$(bc <<< "scale=2; ${freespace}/1024")
fsdsp="${fsdsp} GB"
else
fsdsp="${freespace} MB"
fi
[[ "${partition}" == *"root"* ]] && prt="/" || prt=${partition}
freespace=`${NCMD} df -hPBM ${prt} | awk '{print $4}' |tail -1|sed 's/M$//g'` >/dev/null 2>&1
if [ "${freespace}" -le "1000" ]; then
if [ "${freespace}" -le "1024" ]; then
fs_status='error'
fs_status_color='Red'
SENDNOTICE "Free Space Critical: '${NM_NODETYPES[$NTYPE]}-Node${nid}'" "${partition} : ${freespace} MB free" 1
elif [ "${freespace}" -le "5000" ]; then
SENDNOTICE "Free Space Critical: '${NM_NODETYPES[$NTYPE]}-Node${nid}'" "${partition} : ${fsdsp} free" 1
elif [ "${freespace}" -le "5120" ]; then
fs_status='warn'
fs_status_color='Yellow'
SENDNOTICE "Free Space Warning: '${NM_NODETYPES[$NTYPE]}-Node${nid}'" "${partition} : ${freespace} MB free"
SENDNOTICE "Free Space Warning: '${NM_NODETYPES[$NTYPE]}-Node${nid}'" "${partition} : ${fsdsp} free"
else
fs_status=''
fs_status_color='Green'
fi
if [ "${ST_ACTION}" != "check" ]; then
if [[ ${freespace} -gt 1000 ]]; then
fsgb=$(bc <<< "scale=2; ${freespace}/1000")
if [[ ${freespace} -gt 1024 ]]; then
fsgb=$(bc <<< "scale=2; ${freespace}/1024")
fsdsp="${fsgb} GB"
else
fsdsp="${freespace} MB"