Răsfoiți Sursa

added fn_info_logs

Daniel Gibbs 8 ani în urmă
părinte
comite
d4af776a9f

+ 1 - 49
lgsm/functions/alert_email.sh

@@ -83,61 +83,13 @@ fn_details_gameserver(){
 	} | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee -a "${emaillog}" > /dev/null 2>&1
 }
 
-fn_alert_email_template_logs(){
-	echo -e ""
-	echo -e "${servicename} Logs"
-	echo -e "================================="
-
-	if [ -n "${lgsmlog}" ]; then
-		echo -e "\nScript log\n==================="
-		if [ ! "$(ls -A ${lgsmlogdir})" ]; then
-			echo "${lgsmlogdir} (NO LOG FILES)"
-		elif [ ! -s "${lgsmlog}" ]; then
-			echo "${lgsmlog} (LOG FILE IS EMPTY)"
-		else
-			echo "${lgsmlog}"
-			tail -25 "${lgsmlog}"
-		fi
-		echo ""
-	fi
-
-	if [ -n "${consolelog}" ]; then
-		echo -e "\nConsole log\n===================="
-		if [ ! "$(ls -A ${consolelogdir})" ]; then
-			echo "${consolelogdir} (NO LOG FILES)"
-		elif [ ! -s "${consolelog}" ]; then
-			echo "${consolelog} (LOG FILE IS EMPTY)"
-		else
-			echo "${consolelog}"
-			tail -25 "${consolelog}" | awk '{ sub("\r$", ""); print }'
-		fi
-		echo ""
-	fi
-
-	if [ -n "${gamelogdir}" ]; then
-		echo -e "\nServer log\n==================="
-		if [ ! "$(ls -A ${gamelogdir})" ]; then
-			echo "${gamelogdir} (NO LOG FILES)"
-		else
-			echo "${gamelogdir}"
-			# dos2unix sed 's/\r//'
-			tail "${gamelogdir}"/* 2>/dev/null | grep -v "==>" | sed '/^$/d' | sed 's/\r//'| tail -25
-		fi
-		echo ""
-	fi
-}
-
 fn_print_dots "Sending Email alert: ${email}"
 sleep 0.5
 fn_script_log_info "Sending Email alert: ${email}"
 info_distro.sh
 info_config.sh
 info_glibc.sh
-
-check_ip.sh
-postdetails=1
 info_messages.sh
-emaillog="${emaillog}"
 if [ -f "${emaillog}" ]; then
 	rm "${emaillog}"
 fi
@@ -148,7 +100,7 @@ fi
 	fn_info_message_performance
 	fn_info_message_disk
 	fn_info_message_gameserver
-	fn_alert_email_template_logs
+	fn_info_logs
 } | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee -a "${emaillog}" > /dev/null 2>&1
 
 if [ -n "${emailfrom}" ]; then

+ 25 - 3
lgsm/functions/alert_mailgun.sh

@@ -10,7 +10,30 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_print_dots "Sending Email alert: Mailgun: ${email}"
 sleep 0.5
-mailgunsend=$(curl -s --user "api:${mailguntoken}" -F from="LinuxGSM <${mailgunemailfrom}>" -F to="LinuxGSM Admin <${mailgunemail}>" -F subject="${alertemoji} ${alertsubject} ${alertemoji}" --form-string html="<br><br><b>Message</b><br>${alertbody}<br><br><b>Game</b><br>${gamename}<br><br><b>Server name</b><br>${servername}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>Server IP</b><br><a href='https://www.gametracker.com/server_info/${ip}:${port}'>${ip}:${port}</a><br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a>" https://api.mailgun.net/v3/${mailgundomain}/messages)
+info_distro.sh
+info_config.sh
+info_glibc.sh
+info_messages.sh
+if [ -f "${emaillog}" ]; then
+	rm "${emaillog}"
+fi
+
+{
+	fn_info_message_head
+	fn_info_message_distro
+	fn_info_message_performance
+	fn_info_message_disk
+	fn_info_message_gameserver
+	fn_info_logs
+} | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee -a "${emaillog}" > /dev/null 2>&1
+
+mailgunsend=$(curl -s --user "api:${mailguntoken}" \
+-F from="LinuxGSM <${mailgunemailfrom}>" \
+-F to="LinuxGSM Admin <${mailgunemail}>" \
+-F subject="${alertemoji} ${alertsubject} ${alertemoji}" \
+-F o:tag='alert' \
+-F o:tag='LinuxGSM' \
+-F text="$(cat ${emaillog})" https://api.mailgun.net/v3/${mailgundomain}/messages)
 
 if [ -z "${mailgunsend}" ]; then
 	fn_print_fail_nl "Sending Email alert: Mailgun: ${email}"
@@ -18,5 +41,4 @@ if [ -z "${mailgunsend}" ]; then
 else
 	fn_print_ok_nl "Sending Email alert: Mailgun: ${email}"
 	fn_script_log_pass "Sending Email alert: Mailgun: ${email}"
-fi
-
+fi

+ 44 - 0
lgsm/functions/info_messages.sh

@@ -403,6 +403,50 @@ fn_info_message_statusbottom(){
 	echo -e ""
 }
 
+fn_info_logs(){
+	echo -e ""
+	echo -e "${servicename} Logs"
+	echo -e "================================="
+
+	if [ -n "${lgsmlog}" ]; then
+		echo -e "\nScript log\n==================="
+		if [ ! "$(ls -A ${lgsmlogdir})" ]; then
+			echo "${lgsmlogdir} (NO LOG FILES)"
+		elif [ ! -s "${lgsmlog}" ]; then
+			echo "${lgsmlog} (LOG FILE IS EMPTY)"
+		else
+			echo "${lgsmlog}"
+			tail -25 "${lgsmlog}"
+		fi
+		echo ""
+	fi
+
+	if [ -n "${consolelog}" ]; then
+		echo -e "\nConsole log\n===================="
+		if [ ! "$(ls -A ${consolelogdir})" ]; then
+			echo "${consolelogdir} (NO LOG FILES)"
+		elif [ ! -s "${consolelog}" ]; then
+			echo "${consolelog} (LOG FILE IS EMPTY)"
+		else
+			echo "${consolelog}"
+			tail -25 "${consolelog}" | awk '{ sub("\r$", ""); print }'
+		fi
+		echo ""
+	fi
+
+	if [ -n "${gamelogdir}" ]; then
+		echo -e "\nServer log\n==================="
+		if [ ! "$(ls -A ${gamelogdir})" ]; then
+			echo "${gamelogdir} (NO LOG FILES)"
+		else
+			echo "${gamelogdir}"
+			# dos2unix sed 's/\r//'
+			tail "${gamelogdir}"/* 2>/dev/null | grep -v "==>" | sed '/^$/d' | sed 's/\r//'| tail -25
+		fi
+		echo ""
+	fi
+}
+
 # Engine/Game Specific details
 
 fn_info_message_ark(){