Files
dsmon/defaults.inc
2025-07-27 21:51:40 -05:00

52 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
VERS=2.5.10-07272025
DS_FOLDER=/opt/idssys/dsmon
DS_CRONTAB_FOLDER=/opt/idssys/nodemgmt/crontabs
DS_COPYCERTS_FOLDER=/opt/idssys/nodemgmt/copycerts.sh
noheader=" gettsip-node get-crontabs get-crontab update report updatenodes runcmd runcheck "
[ "$(ip route | awk '/default/ { print $5 }')" == "link" ] && RNIP=$(ip addr show $(ip route | awk '/1 dev eth0/ { print $5; exit }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) ||
RNIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
if [ "${RNIP}" == "10.10.10.50" ]; then
mysqlcmd="mysql"
else
mysqlcmd="mariadb --skip-ssl"
fi
if [[ "${RNIP}" == "10.6.1."* ]]; then
if [ -d /opt/idssys/nodemgmt ]; then
nmip=${NM_NODEMANAGER}
mysql_conn="-h ${NM_SINGLESRVR_IP[MYSQL]}"
else
mysql_conn="-h 10.6.1.5"
fi
elif [ "${TAILSCALE}" == "true" ]; then
nmip=${NM_NODEMANAGER_TS}
mysql_conn="-h 100.100.5.6"
elif [ "${NM_NODEMANAGER}" != "" ]; then
nmip=${NM_NODEMANAGER}
mysql_conn="-h ${NM_SINGLESRVR_IP[MYSQL]} -P 3307"
else
nmip=10.10.10.60
mysql_conn=10.10.1.50
mysql_conn="-h 10.10.1.50 -P 3307"
fi
SENDNOTICE(){
[ -n ${NM_HOSTNAMES[${RNIP}]} ] && shost=${NM_HOSTNAMES[${RNIP}]} || shost=$(hostname -f)
[ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}
[${shost}] $(date)" "${1}" ${3} &
[ "${EMAIL_NOTICE}" != "" ] && echo -e "${2}\n\n$(date)" | mail -s "${1}" ${EMAIL_NOTICE}
}