This commit is contained in:
2023-12-06 15:54:03 -06:00
parent bb68b10213
commit 5bb41e5915
2 changed files with 108 additions and 107 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERS='5.1.7-12062023' VERS='5.1.8-12062023'
NM_BETA=false NM_BETA=false
noheader=' service status-check nightlyrephp7.3-fpm,new backup report check checkcerts gitea update-nodes copynpmcerts singleservercheck update-dyndns backup-offsitepfsense gui nightlyreview update log betacheck ' noheader=' service status-check nightlyrephp7.3-fpm,new backup report check checkcerts gitea update-nodes copynpmcerts singleservercheck update-dyndns backup-offsitepfsense gui nightlyreview update log betacheck '

View File

@@ -28,7 +28,8 @@ STATUS(){
## REPLICATION CHECK SETUP ## REPLICATION CHECK SETUP
############################ ############################
if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then # if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then
if [ "${ST_ACTION}" == "repl" ]; then
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -en "${idsCL[LightCyan]}Setting up replication checks ... ${idsCL[Default]}" echo -en "${idsCL[LightCyan]}Setting up replication checks ... ${idsCL[Default]}"
fi fi
@@ -144,7 +145,8 @@ STATUS(){
## REPLICATION CHECK ## REPLICATION CHECK
######################## ########################
if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then # if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then
if [ "${ST_ACTION}" == "repl" ]; then
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsST[Bold]}"; DIVIDER echo -e "${idsST[Bold]}"; DIVIDER
echo -e "${idsCL[Yellow]} Replication Status Between the Primary and Secondary Nodes${idsCL[Default]}" echo -e "${idsCL[Yellow]} Replication Status Between the Primary and Secondary Nodes${idsCL[Default]}"
@@ -250,7 +252,8 @@ It was down for $(SHOW_TIME $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${
########################## ##########################
# REMOVE REPL CHECK FILES # REMOVE REPL CHECK FILES
########################## ##########################
if [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "repl" ] || [ "${ST_ACTION}" = "check" ] || [ "${ST_ACTION}" = "" ]; then # if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then
if [ "${ST_ACTION}" == "repl" ]; then
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -en "${idsCL[LightCyan]} Cleaning up status checks... ${idsCL[Default]}" echo -en "${idsCL[LightCyan]} Cleaning up status checks... ${idsCL[Default]}"
fi fi
@@ -285,113 +288,111 @@ It was down for $(SHOW_TIME $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${
######################## ########################
#if [ "${ST_ACTION}" = "" ] || [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "freespace" ]; then #if [ "${ST_ACTION}" = "" ] || [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "freespace" ]; then
if [ "${ST_ACTION}" = "freespace" ]; then if [ "${ST_ACTION}" = "freespace" ]; then
if [ "${ST_ACTION}" != "repl" ] && [ "${ST_ACTION}" != "services" ]; then for NTYPE in "${ntypesel[@]}"; do
for NTYPE in "${ntypesel[@]}"; do if [ "${ST_ACTION}" != "check" ]; then
if [ "${ST_ACTION}" != "check" ]; then echo -e "${idsST[Bold]}"; DIVIDER
echo -e "${idsST[Bold]}"; DIVIDER echo -e "${idsCL[Yellow]} ${NM_NODETYPES[$NTYPE]}-Node(s) Free Space Scan${idsCL[Default]}"
echo -e "${idsCL[Yellow]} ${NM_NODETYPES[$NTYPE]}-Node(s) Free Space Scan${idsCL[Default]}" DIVIDER; echo -e "${idsST[Reset]}"
DIVIDER; echo -e "${idsST[Reset]}" fi
var=${NTYPE}_HOSTS[@]
for nip in "${!var}"; do
if [[ $"{RNIP}" == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
else NCMD="ssh -o ConnectTimeout=3 root@${nip}"; LH=''
fi
if [ "${ST_ACTION}" != "check" ]; then
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NM_HOSTNAMES[${nip}]} [${nip}]${idsST[Reset]}${idsCL[LightCyan]} ${idsCL[LightYellow]}${LH}${idsCL[Default]}"
DIVIDER false green
fi fi
var=${NTYPE}_HOSTS[@]
for nip in "${!var}"; do
if [[ $"{RNIP}" == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
else NCMD="ssh -o ConnectTimeout=3 root@${nip}"; LH=''
fi
if [ "${ST_ACTION}" != "check" ]; then
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NM_HOSTNAMES[${nip}]} [${nip}]${idsST[Reset]}${idsCL[LightCyan]} ${idsCL[LightYellow]}${LH}${idsCL[Default]}"
DIVIDER false green
fi
[ "${ST_ACTION}" != "check" ] && [ "${2}" != "report" ] && echo -en " ${idsCL[LightCyan]}Getting drives from server ... ${idsCL[Default]}" [ "${ST_ACTION}" != "check" ] && [ "${2}" != "report" ] && echo -en " ${idsCL[LightCyan]}Getting drives from server ... ${idsCL[Default]}"
declare -A partitions declare -A partitions
DRIVEINFO=$(ssh -o ConnectTimeout=3 root@${nip} 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=$(ssh -o ConnectTimeout=3 root@${nip} 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}) DRIVEINFO=(${DRIVEINFO})
if [ "${2}" != "report" ]; then if [ "${2}" != "report" ]; then
echo -en "\e[1A" echo -en "\e[1A"
echo -e "\e[0K\r" echo -e "\e[0K\r"
fi fi
NUMDRIVES=$((${#DRIVEINFO[@]} / 3)) NUMDRIVES=$((${#DRIVEINFO[@]} / 3))
for ((i = 0 ; i <= $((${NUMDRIVES}-1)) ; i++)); do for ((i = 0 ; i <= $((${NUMDRIVES}-1)) ; i++)); do
ii=$((${i}*3)) ii=$((${i}*3))
pname=`echo "${DRIVEINFO[${ii}]}" | awk -F'/' ' { print $NF } '` >/dev/null 2>&1 pname=`echo "${DRIVEINFO[${ii}]}" | awk -F'/' ' { print $NF } '` >/dev/null 2>&1
pname=${pname#*vg-} pname=${pname#*vg-}
if [ ${DRIVEINFO[$((${ii}+1))]//M/} -gt 1024 ]; then if [ ${DRIVEINFO[$((${ii}+1))]//M/} -gt 1024 ]; then
freespace=${DRIVEINFO[$((${ii}+2))]//M/} freespace=${DRIVEINFO[$((${ii}+2))]//M/}
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
c=0; cw=20; spc='' c=0; cw=20; spc=''
spc1=${cw}-${#pname} spc1=${cw}-${#pname}
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
echo -en " ${pname}$spc: " echo -en " ${pname}$spc: "
fi
if [[ ${freespace} -gt 1024 ]]; then
fsgb=$(bc <<< "scale=2; ${freespace}/1024")
fsdsp="${fsgb} GB"
else
fsdsp="${freespace} MB"
fi
if [ "${freespace}" -le "1024" ]; then
fs_status='error'
fs_status_color='Red'
SENDNOTICE "Free Space Critical: '${NM_HOSTNAMES[${nip}]}[${nip}]'" "${partition} : ${fsdsp} free" 1
elif [ "${freespace}" -le "5120" ]; then
fs_status='warn'
fs_status_color='Yellow'
SENDNOTICE "Free Space Warning: '${NM_HOSTNAMES[${nip}]}[${nip}]'" "${partition} : ${fsdsp} free"
else
fs_status=''
fs_status_color='Green'
fi
[ "${ST_ACTION}" != "check" ] && echo -e "${idsCL[${fs_status_color}]}${fsdsp} ${idsCL[Default]}"
fi fi
done if [[ ${freespace} -gt 1024 ]]; then
fsgb=$(bc <<< "scale=2; ${freespace}/1024")
# for partition in "${partitions3[@]}"; do fsdsp="${fsgb} GB"
# if [ "${partition}" != "udev" ] && [ "${partition}" != "/dev/sda1" ]; then else
# pname=`echo "${partition}" | awk -F'/' ' { print $NF } '` >/dev/null 2>&1 fsdsp="${freespace} MB"
# pname=${pname#*vg-} fi
# if [ "${ST_ACTION}" != "check" ]; then if [ "${freespace}" -le "1024" ]; then
# c=0; cw=20; spc='' fs_status='error'
# spc1=${cw}-${#pname} fs_status_color='Red'
# until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done SENDNOTICE "Free Space Critical: '${NM_HOSTNAMES[${nip}]}[${nip}]'" "${partition} : ${fsdsp} free" 1
# echo -en " ${pname}$spc: " elif [ "${freespace}" -le "5120" ]; then
# fi fs_status='warn'
# fs_status_color='Yellow'
# # [[ "${partition}" == *"root"* ]] && prt="/" || prt=${partition} SENDNOTICE "Free Space Warning: '${NM_HOSTNAMES[${nip}]}[${nip}]'" "${partition} : ${fsdsp} free"
# # freespace=`${NCMD} df -hPBM ${prt} | awk '{print $4}' |tail -1|sed 's/M$//g'` >/dev/null 2>&1 else
# fs_status=''
# if [ "${freespace}" -le "1000" ]; then fs_status_color='Green'
# fs_status='error' fi
# fs_status_color='Red' [ "${ST_ACTION}" != "check" ] && echo -e "${idsCL[${fs_status_color}]}${fsdsp} ${idsCL[Default]}"
# SENDNOTICE "Free Space Critical: '${NM_HOSTNAMES[${nip}]}[${nip}]'" "${partition} : ${freespace} MB free" 1 fi
#
# elif [ "${freespace}" -le "5000" ]; then
# fs_status='warn'
# fs_status_color='Yellow'
# SENDNOTICE "Free Space Warning: '${NM_HOSTNAMES[${nip}]}[${nip}]'" "${partition} : ${freespace} MB 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")
# fsdsp="${fsgb} GB"
# else
# fsdsp="${freespace} MB"
# fi
# echo -e "${idsCL[${fs_status_color}]}${fsdsp} ${idsCL[Default]}"
#
# fi
# fi
# done
echo
done done
# 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: "
# 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
# fs_status='error'
# fs_status_color='Red'
# SENDNOTICE "Free Space Critical: '${NM_HOSTNAMES[${nip}]}[${nip}]'" "${partition} : ${freespace} MB free" 1
#
# elif [ "${freespace}" -le "5000" ]; then
# fs_status='warn'
# fs_status_color='Yellow'
# SENDNOTICE "Free Space Warning: '${NM_HOSTNAMES[${nip}]}[${nip}]'" "${partition} : ${freespace} MB 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")
# fsdsp="${fsgb} GB"
# else
# fsdsp="${freespace} MB"
# fi
# echo -e "${idsCL[${fs_status_color}]}${fsdsp} ${idsCL[Default]}"
#
# fi
# fi
# done
echo
done done
fi done
fi fi
######################## ########################
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then