Update dsmon.sh

This commit is contained in:
2023-01-02 09:25:15 -06:00
parent ef3da3f3dd
commit c3689a5847

View File

@@ -84,7 +84,7 @@ CHECK(){
declare -A host_ip declare -A host_ip
declare -A host_name declare -A host_name
declare -A host_limits declare -A host_limits
declare -A hostnames declare -A host_ids
declare -a hostnames_sort declare -a hostnames_sort
while read hostid hostname hostip hostlimits; do while read hostid hostname hostip hostlimits; do
@@ -94,23 +94,21 @@ CHECK(){
host_ip[${hostid}]=$hostip host_ip[${hostid}]=$hostip
host_name[${hostid}]=$hostname host_name[${hostid}]=$hostname
host_limits[${hostid}]=$hostlimits host_limits[${hostid}]=$hostlimits
hostnames[$hostname]=$hostid; hostnames_sort+=("$hostname") host_ids[$hostname]=$hostid
hostnames_sort+=("$hostname")
fi fi
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h mysqldb.scity.us -P 3306 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts") done <<< $(MYSQL_PWD="sysmoninsert" mysql -h mysqldb.scity.us -P 3306 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts")
IFS=$'\n' hostnames_sort=($(sort <<<"${hostnames_sort[*]}")) IFS=$'\n' hostnames_sort=($(sort <<<"${hostnames_sort[*]}"))
unset IFS unset IFS
for x in "${!hostnames[@]}"; do printf "[%s]=%s\n" "$x" "${hostnames[$x]}" ; done
echo
for x in "${!hostnames_sort[@]}"; do printf "[%s]=%s\n" "$x" "${hostnames_sort[$x]}" ; done
#for hostid in "${!host_ip[@]}"; do #for hostid in "${!host_ip[@]}"; do
# echo -e "${idsST[Bold]}"; DIVIDER for hostname in "${hostnames_sort[@]}"; do
# echo -e "${idsCL[LightCyan]} ${host_name[$hostid]} - Drive Space Check${idsCL[Default]}" hostid=${host_ids[$hostname]}
# DIVIDER; echo -e "${idsST[Reset]}" echo -e "${idsST[Bold]}"; DIVIDER
# echo -e "${idsCL[LightCyan]} ${host_name[$hostid]} - Drive Space Check${idsCL[Default]}"
DIVIDER; echo -e "${idsST[Reset]}"
# checkhost=$(CHECK_HOST ${host_ip[$hostid]}) # checkhost=$(CHECK_HOST ${host_ip[$hostid]})
# if [ "${checkhost}" != "false" ]; then # if [ "${checkhost}" != "false" ]; then
# DRIVEINFO=$(ssh root@${host_ip[$hostid]} df -BM | grep -vE '^Filesystem|tmpfs|cdrom|@|ram|loop|udev|veeamimage|nvme|localhost|sda|sdb|shm|mmcblk|overlay|-volume|Music|media-data|Software' | awk '{ print $1 " " $2 " " $4 }') # DRIVEINFO=$(ssh root@${host_ip[$hostid]} df -BM | grep -vE '^Filesystem|tmpfs|cdrom|@|ram|loop|udev|veeamimage|nvme|localhost|sda|sdb|shm|mmcblk|overlay|-volume|Music|media-data|Software' | awk '{ print $1 " " $2 " " $4 }')
@@ -151,8 +149,8 @@ CHECK(){
# else # else
# echo -e "${idsCL[Yellow]} ${host_name[$hostid]} is down${idsCL[Default]}" # echo -e "${idsCL[Yellow]} ${host_name[$hostid]} is down${idsCL[Default]}"
# fi # fi
#
# done done
} }
SETUPSSH(){ SETUPSSH(){