Explorar el Código

alert messages being migrated to alert.sh

Daniel Gibbs hace 10 años
padre
commit
745dcc0a42

+ 47 - 1
lgsm/functions/alert.sh

@@ -6,10 +6,56 @@ lgsm_version="140516"
 
 
 # Description: Overall function for managing alerts.
 # Description: Overall function for managing alerts.
 
 
+fn_alert_test(){
+	fn_scriptlog "Sending test alert"
+	alertsubject="LGSM - Alert Check - ${servername}"
+	alertbody="LGSM test alert, how you read?"
+}
+
+fn_alert_restart(){
+	fn_scriptlog "Sending restart alert: ${executable} process not running"
+	alertsubject="LGSM - Restarted - ${servername}"
+	alertbody="${servicename} ${executable} process not running"
+}
+
+fn_alert_queryrestart(){
+	fn_scriptlog "Sending restart alert: ${gsquerycmd}"
+	alertsubject="LGSM - Restarted - ${servername}"
+	alertbody="Failed to Query: ${gsquerycmd}"
+}
+
+fn_alert_update(){
+	fn_scriptlog "Sending update alert"
+	alertsubject="LGSM - Updated - ${servername}"
+	alertbody="Recieved update: 154789"
+}
+
+if [ "${alert}" == "restart" ]; then
+	fn_alert_restart
+if [ "${alert}" == "queryrestart" ]; then
+	fn_alert_queryrestart
+elif [ "${alert}" == "update" ]; then
+	fn_alert_update
+elif [ "${alert}" == "test" ]; then
+	fn_alert_test
+fi
+
 if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then
 if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then
 	alert_email.sh
 	alert_email.sh
+elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
+	fn_print_fail_nl "Alerts not enabled"
+	fn_scriptlog "Email alerts not enabled"	
+elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
+	fn_print_fail_nl "Email no set"
+	fn_scriptlog "Email no set"		
 fi
 fi
 
 
-if [ "${pushbulletalert}" == "on" ]||[ -n "${pushbullettoken}" ]; then
+if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then
 	alert_pushbullet.sh
 	alert_pushbullet.sh
+elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
+	fn_print_fail_nl "Pushbullet alerts not enabled"
+	fn_scriptlog "Pushbullet alerts not enabled"
+elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
+	fn_print_fail_nl "Pushbullet token not set"
+	fn_scriptlog "Pushbullet token not set"
 fi
 fi

+ 2 - 1
lgsm/functions/command_monitor.sh

@@ -57,7 +57,8 @@ fn_monitor_teamspeak3(){
 		fn_print_fail_eol_nl
 		fn_print_fail_eol_nl
 		fn_scriptlog "Checking session: ${ts3error}: FAIL"
 		fn_scriptlog "Checking session: ${ts3error}: FAIL"
 		failurereason="${ts3error}"
 		failurereason="${ts3error}"
-		fn_monitor_email_alert
+		alert="restart"
+		alert.sh
 	fi
 	fi
 	fn_scriptlog "Monitor is starting ${servername}"
 	fn_scriptlog "Monitor is starting ${servername}"
 	sleep 1
 	sleep 1

+ 1 - 3
lgsm/functions/command_test_alert.sh

@@ -12,9 +12,7 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 check.sh
 check.sh
 info_config.sh
 info_config.sh
 if [ "${emailalert}" = "on" ]||[ "${pushbulletalert}" = "on" ]; then
 if [ "${emailalert}" = "on" ]||[ "${pushbulletalert}" = "on" ]; then
-	fn_scriptlog "Sending alert Check"
-	alertsubject="LGSM - Alert Check - ${servername}"
-	alertbody="LGSM testing alert, how you read?"
+	alert="test"
 	alert.sh
 	alert.sh
 else
 else
 	fn_print_fail_nl "alerts not enabled"
 	fn_print_fail_nl "alerts not enabled"