Update dsmon.sh

This commit is contained in:
2023-07-05 00:04:25 -05:00
parent 2a92e4b92b
commit 2811773fbb

View File

@@ -304,7 +304,13 @@ GETCRONTABS(){
[ ! -d ${DS_CRONTAB_FOLDER} ] && mkdir ${DS_CRONTAB_FOLDER} && chmod -Rf 0777 ${DS_CRONTAB_FOLDER}
while read hostid hostname hostip hostlimits; do
if [ "$hostid" != "id" ]; then
host_ip[${hostid}]=$(echo $hostip | cut -d ";" -f1)
host_name[${hostid}]=$hostname
fi
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -P 3306 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC")
if [ "${1}" == "" ]; then
read -p "Enter the password for the 'nm_crontab_user' account on MySQL-Manager: " rtpsswd
echo
@@ -312,37 +318,22 @@ GETCRONTABS(){
rtpsswd=${1}
fi
while read hostid hostname hostip hostlimits; do
# if [ "$hostid" != "id" ]; then
# host_ip[${hostid}]=$(echo $hostip | cut -d ";" -f1)
# host_name[${hostid}]=$hostname
# fi
checkhost=$(CHECK_HOST ${hostip})
for hostid in "${!host_ip[@]}"; do
checkhost=$(CHECK_HOST ${host_ip[$hostid]})
if [ "${checkhost}" != "false" ]; then
echo -en "${idsST[Bold]}${idsCL[LightCyan]} ${hostname} - Gathering Crontabs ... ${idsCL[Default]}${idsST[Reset]}"
ssh -tq root@${hostip} dsmon get-crontab ${rtpsswd}
echo -en "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Gathering Crontabs ... ${idsCL[Default]}${idsST[Reset]}"
ssh -tq root@${host_ip[$hostid]} dsmon get-crontab ${rtpsswd}
else
echo -e "${idsST[Bold]}${idsCL[Red]} ${hostname} - Timeout${idsCL[Default]}${idsST[Reset]}"
echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}"
fi
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -P 3306 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC")
# for hostid in "${!host_ip[@]}"; do
# checkhost=$(CHECK_HOST ${host_ip[$hostid]})
# if [ "${checkhost}" != "false" ]; then
# echo -en "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Gathering Crontabs ... ${idsCL[Default]}${idsST[Reset]}"
# ssh -tq root@${host_ip[$hostid]} dsmon get-crontab ${rtpsswd}
# else
# echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}"
# fi
# done
done
echo
end=`date +%s`
runtime=$((end-start))
echo "Script Runtime: ${runtime}"
echo
dsmon
}
GETCRONTAB(){
if [ "${1}" != "" ]; then