Update dsmon.sh

This commit is contained in:
2024-01-26 15:04:22 -06:00
parent b7c152e2e4
commit 54d4c08192

View File

@@ -390,11 +390,11 @@ RUNCMD_SUB(){
host=${2} host=${2}
tmpfile=/tmp/.dsmon.runcmd.${host// /-} tmpfile=/tmp/.dsmon.runcmd.${host// /-}
touch ${tmpfile}.running > /dev/null 2>&1 touch ${tmpfile}.running > /dev/null 2>&1
echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host} - Running command: ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22}${idsCL[Default]}${idsST[Reset]}" >> ${tmpfile}.running echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host}${idsCL[Default]}${idsST[Reset]}" >> ${tmpfile}.running
if ssh_output=$(ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${ip} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22}) ; then if ssh_output=$(ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${ip} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22}) ; then
echo -e "${ssh_output}" >> ${tmpfile}.running echo -e "${ssh_output}" >> ${tmpfile}.running
else else
echo -e "${idsST[Bold]}${idsCL[Red]} ${host} - Timeout${idsCL[Default]}${idsST[Reset]}" >> ${tmpfile}.running echo -e "${idsCL[Red]} ${host} - Timeout${idsCL[Default]}" >> ${tmpfile}.running
fi fi
mv ${tmpfile}.running ${tmpfile}.done > /dev/null 2>&1 mv ${tmpfile}.running ${tmpfile}.done > /dev/null 2>&1
} }
@@ -440,7 +440,7 @@ GETTSIP_NODE(){
GETCRONTABS(){ GETCRONTABS(){
start=`date +%s` start=`date +%s`
rtpsswd=${1}
declare -A host_ip declare -A host_ip
declare -A host_name declare -A host_name
@@ -453,23 +453,21 @@ GETCRONTABS(){
fi fi
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC") done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC")
if [ "${1}" == "" ]; then if [ "${rtpsswd}" == "" ]; then
read -p "Enter the password for the 'nm_crontab_user' account on MySQL-Manager: " rtpsswd read -p "Enter the password for the 'nm_crontab_user' account on MySQL-Manager: " rtpsswd
echo echo
else
rtpsswd=${1}
fi fi
# for hostid in "${!host_ip[@]}"; do for hostid in "${!host_ip[@]}"; do
# # echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - ${host_ip[$hostid]}${idsCL[Default]}${idsST[Reset]}" # echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - ${host_ip[$hostid]}${idsCL[Default]}${idsST[Reset]}"
# # checkhost=$(CHECK_HOST ${host_ip[$hostid]}) # checkhost=$(CHECK_HOST ${host_ip[$hostid]})
# # if [ "${checkhost}" != "false" ]; then # if [ "${checkhost}" != "false" ]; then
# # echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Gathering Crontabs ... ${idsCL[Default]}${idsST[Reset]}" # echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Gathering Crontabs ... ${idsCL[Default]}${idsST[Reset]}"
# ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${host_ip[$hostid]} dsmon get-crontab ${rtpsswd} & ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${host_ip[$hostid]} dsmon get-crontab ${rtpsswd} &
# # else # else
# # echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}" # echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}"
# # fi # fi
# done done
echo echo
end=`date +%s` end=`date +%s`