Browse Source

Updated monitor for ts3server

pull/292/head
Daniel Gibbs 10 years ago
parent
commit
6e3ba0e758
  1. 67
      functions/fn_monitor

67
functions/fn_monitor

@ -2,7 +2,7 @@
# LGSM fn_monitor function # LGSM fn_monitor function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk # Website: http://danielgibbs.co.uk
# Version: 080214 # Version: 080215
# Description: Monitors server by checking for running proccesses # Description: Monitors server by checking for running proccesses
# then passes to fn_monitor_query. # then passes to fn_monitor_query.
@ -10,40 +10,47 @@
local modulename="Monitor" local modulename="Monitor"
fn_monitor_teamspeak3(){ fn_monitor_teamspeak3(){
fn_rootcheck fn_check_root
fn_syscheck fn_check_systemdir
fn_logmanager fn_logs
fn_printfail "Monitor is checking ${servicename}: ${servername}" fn_printdots "${servername}"
fn_scriptlog "Monitor is checking ${servername}" fn_scriptlog "${servername}"
sleep 0.5
fn_runcheck
fn_printwarn "Monitor detected ${servername} had stopped!\n"
fn_scriptlog "Monitor detected ${servername} had stopped!"
sleep 1 sleep 1
fn_status if [ ! -f "${lockselfname}" ]; then
if [ "${ts3status}" = "Server seems to have died" ]; then fn_printinfo "Disabled: No lock file found"
fn_printinfo "${servername} Server seems to have died" fn_scriptlog "Disabled: No lock file found"
fn_scriptlog "${servername} Server seems to have died" sleep 1
failurereason="Server seems to have died" echo -en "\n"
elif [ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then echo "To enable monitor run ./${selfname} start"
fn_printinfo "${servername} No server running (ts3server.pid is missing)" exit
fn_scriptlog "${servername} No server running (ts3server.pid is missing)"
failurereason="No server running (ts3server.pid is missing)"
else
fn_printinfo "${servername} Unknown error"
fn_scriptlog "${servername} Unknown error"
failurereason="Unknown error"
fi fi
sleep 0.5 fn_printdots "Checking session: CHECKING"
echo -en "\n" fn_scriptlog "Checking session: CHECKING"
if [ "${emailnotification}" = "on" ]; then sleep 1
subject="${servicename} Monitor - Restarting ${servername}" fn_check_ts3status
actiontaken="restarted ${servername}" if [ "${ts3status}" = "Server is running" ]; then
fn_emailnotification fn_printok "Checking session: OK"
fn_scriptlog "Checking session: OK"
sleep 1
sleep 0.5
echo -en "\n"
exit
else
fn_printfail "Checking session: FAIL"
fn_scriptlog "Checking session: FAIL"
sleep 1
fn_printfail "Checking session: FAIL: ${ts3status}"
fn_scriptlog "Checking session: FAIL: ${ts3status}"
failurereason="${ts3status}"
if [ "${emailnotification}" = "on" ]; then
subject="${servicename} Monitor - Restarting ${servername}"
actiontaken="restarted ${servername}"
fn_emailnotification
fi
fi fi
sleep 0.5 sleep 0.5
echo -en "\n" echo -en "\n"
fn_restartserver fn_restart
} }
fn_monitor_tmux(){ fn_monitor_tmux(){

Loading…
Cancel
Save