From 2c0fbdff6d0aacef7d4a8d34285db21d487a1554 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 10 Mar 2022 22:14:03 -0600 Subject: [PATCH] Update install-dsmon.sh --- install-dsmon.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/install-dsmon.sh b/install-dsmon.sh index 05fd3c2..ed6c1cd 100755 --- a/install-dsmon.sh +++ b/install-dsmon.sh @@ -43,13 +43,22 @@ read SET_SERVERMONID echo "" if [ "${SET_SERVERMONID}" = "new" ]; then - echo -e -n "${idsCL[LightCyan]}Server Name: ${idsCL[Default]}" + hostname=`hostname` + echo -e -n "${idsCL[LightCyan]}Server Name (Default=${hostname}): ${idsCL[Default]}" read ADD_SERVERNAME echo "" + + if [ "${ADD_SERVERNAME}" = "" ]; then + ADD_SERVERNAME=${hostname} + fi + QRY="USE servermonitor; INSERT INTO hosts (\`host\`) VALUES ('${ADD_SERVERNAME}');" mysql -h mysqldb.scity.us -P 6033 --user=sysmoninsert --password=sysmoninsert -e "${QRY}" QRY="USE servermonitor; SELECT id FROM hosts WHERE host='${ADD_SERVERNAME}';" SET_SERVERMONID=`mysql -h mysqldb.scity.us -P 6033 --user=sysmoninsert --password=sysmoninsert -e "${QRY}"` + SET_SERVERMONID=${SET_SERVERMONID//id + /} + echo -e "${idsCL[LightGreen]}Server successfully added, it was given ID# ${SET_SERVERMONID}${idsCL[Default]}" echo ""