Update nodemgmt-scripts.sh

This commit is contained in:
2023-04-23 12:43:34 -05:00
parent b88798d009
commit 86054bc98e

View File

@@ -2465,6 +2465,46 @@ DOWNLIST(){
echo ""
}
UPDATEPUSHOVERINFO(){
echo
if [ "${PUSHOVER_APP_TOKEN}" != "" ]; then
echo -en "${idsCL[LightCyan]}Use current Pushover Info:\nApp Token: [${idsCL[White]}${PUSHOVER_APP_TOKEN}${idsCL[LightCyan]}\nUser Token: [${idsCL[White]}${PUSHOVER_USER_TOKEN}${idsCL[LightCyan]}] (Y/n)? ${idsCL[Default]}"
read -n 1 choice
case "$choice" in
[Nn]) PUSHOVER_APP_TOKEN="";PUSHOVER_USER_TOKEN="";;esac
fi
if [ "${PUSHOVER_APP_TOKEN}" == "" ]; then
echo; echo -e -n "${idsCL[LightCyan]}Pushover App Token: ${idsCL[Default]}"
read -e PUSHOVER_APP_TOKEN
echo; echo -e -n "${idsCL[LightCyan]}(optional) Pushover User Token: ${idsCL[Default]}"
read -e PUSHOVER_USER_TOKEN
fi
declare -A host_ip
declare -A host_name
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 mysqldb.scity.us -P 3306 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0")
for hostid in "${!host_ip[@]}"; do
checkhost=$(CHECK_HOST ${host_ip[$hostid]})
if [ "${checkhost}" != "false" ]; then
echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Running commands${idsCL[Default]}${idsST[Reset]}"
ssh root@${host_ip[$hostid]} "/bin/sed -i '/PUSHOVER_/d' /opt/idssys/nodemgmt/settings.conf"
[ "${PUSHOVER_APP_TOKEN}" != "" ] && ssh root@${host_ip[$hostid]} 'echo "PUSHOVER_APP_TOKEN=\"${PUSHOVER_APP_TOKEN}\"" >> ${MMFOLDER}/settings.conf' || ssh root@${host_ip[$hostid]} 'echo "# PUSHOVER_APP_TOKEN=\"\"" >> ${MMFOLDER}/settings.conf'
[ "${PUSHOVER_USER_TOKEN}" != "" ] && ssh root@${host_ip[$hostid]} 'echo "PUSHOVER_USER_TOKEN=\"${PUSHOVER_USER_TOKEN}\"" >> ${MMFOLDER}/settings.conf' || ssh root@${host_ip[$hostid]} 'echo "# PUSHOVER_USER_TOKEN=\"\"" >> ${MMFOLDER}/settings.conf'
else
echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}"
fi
done
}
GUI(){
DISP_HEADER true false
@@ -2598,6 +2638,7 @@ if [ ${action-x} ]; then
keepalive-config) KEEPALIVE-CONFIG;;
vc-ssl) VCENTER-SSL ${2};;
run) RUN_COMMAND ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15};;
update-pushover) UPDATEPUSHOVERINFO;;
gui) GUI;;
*)
echo -e "Usage: ${idsCL[LightCyan]}nodemgmt${idsCL[Default]} {"