Browse Source

pushover now working

pull/1601/head
Daniel Gibbs 8 years ago
parent
commit
a916f66585
  1. 17
      lgsm/functions/alert.sh
  2. 35
      lgsm/functions/alert_pushover.sh

17
lgsm/functions/alert.sh

@ -9,40 +9,45 @@ local commandaction="Alert"
fn_alert_test(){
fn_script_log_info "Sending test alert"
alertsubject="Alert - ${servicename} - Test"
alertemoji="🚨"
alertsubject="Alert - ${servicename}: Test"
alertemoji="🚧"
alertsound="1"
alerturl="https://gameservermanagers.com"
alertbody="Testing LinuxGSM Alert. No action to be taken."
}
fn_alert_restart(){
fn_script_log_info "Sending alert: Restarted: ${executable} not running"
alertsubject="Alert - ${servicename} - Restarted"
alertsubject="Alert - ${servicename}: Restarted"
alertemoji="🚨"
alertsound="2"
alerturl="https://gameservermanagers.com"
alertbody="${servicename} ${executable} not running"
}
fn_alert_restart_query(){
fn_script_log_info "Sending alert: Restarted: ${gsquerycmd}"
alertsubject="Alert - ${servicename} - Restarted"
alertsubject="Alert - ${servicename}: Restarted"
alertemoji="🚨"
alertsound="2"
alerturl="https://gameservermanagers.com"
alertbody="gsquery.py failed to query: ${gsquerycmd}"
}
fn_alert_update(){
fn_script_log_info "Sending alert: Updated"
alertsubject="Alert - ${servicename} - Updated"
alertsubject="Alert - ${servicename}: Updated"
alertemoji="🎮"
alertsound="1"
alerturl="https://gameservermanagers.com"
alertbody="${gamename} received update"
}
fn_alert_permissions(){
fn_script_log_info "Sending alert: Permissions error"
alertsubject="Alert - ${servicename} - Permissions error"
alertsubject="Alert - ${servicename}: Permissions error"
alertemoji="❗"
alertsound="2"
alerturl="https://gameservermanagers.com"
alertbody="${servicename} has permissions issues"
}

35
lgsm/functions/alert_pushover.sh

@ -8,15 +8,28 @@ local commandname="ALERT"
local commandaction="Alert"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
json=$(cat <<EOF
{
"token": "${pushovertoken}",
"user": "",
"device": "all",
"title": "Backup finished - SQL1",
"message": "TEST"
}
EOF
)
fn_print_dots "Sending Pushover alert"
sleep 0.5
curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.pushover.net/1/messages.json"
# Different alerts are given different priorities and notification sounds
if [ "${alertsound}" == "1" ];then
alertsound=""
alertpriority="0"
elif [ "${alertsound}" == "2" ];then
# restarted
alertsound="siren"
alertpriority="1"
else
alertsound=""
alertpriority="0"
fi
pushoversend=$(${curlpath} -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alertsubject} ${alertemoji}" -F message=" <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.pushover.net/1/messages.json")
if [ -n "${pushoversend}" ]; then
fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
fn_script_log_fatal "Sending Pushover alert: ${pushoversend}"
else
fn_print_ok_nl "Sending Pushover alert"
fn_script_log_pass "Sent Pushover alert"
fi
Loading…
Cancel
Save