mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 00:06:07 -07:00
Move check for server down to check_active_sessions
This commit is contained in:
parent
1c4df69e61
commit
c3ea35806e
3 changed files with 15 additions and 23 deletions
|
@ -287,8 +287,6 @@ def initialize_scheduler():
|
||||||
hours=12, minutes=0, seconds=0)
|
hours=12, minutes=0, seconds=0)
|
||||||
schedule_job(activity_pinger.check_recently_added, 'Check for recently added items',
|
schedule_job(activity_pinger.check_recently_added, 'Check for recently added items',
|
||||||
hours=0, minutes=0, seconds=seconds)
|
hours=0, minutes=0, seconds=seconds)
|
||||||
schedule_job(activity_pinger.check_server_response, 'Check for server response',
|
|
||||||
hours=0, minutes=0, seconds=seconds)
|
|
||||||
|
|
||||||
# If we're not using websockets then fall back to polling
|
# If we're not using websockets then fall back to polling
|
||||||
if not CONFIG.MONITORING_USE_WEBSOCKET or POLLING_FAILOVER:
|
if not CONFIG.MONITORING_USE_WEBSOCKET or POLLING_FAILOVER:
|
||||||
|
|
|
@ -163,6 +163,19 @@ def check_active_sessions(ws_request=False):
|
||||||
monitor_process.write_session(session)
|
monitor_process.write_session(session)
|
||||||
else:
|
else:
|
||||||
logger.debug(u"PlexPy Monitor :: Unable to read session list.")
|
logger.debug(u"PlexPy Monitor :: Unable to read session list.")
|
||||||
|
response = pms_connect.get_server_response()
|
||||||
|
global ping_count
|
||||||
|
|
||||||
|
if not response:
|
||||||
|
ping_count += 1
|
||||||
|
logger.warn(u"PlexPy Monitor :: Unable to get a response from the server, ping attempt %s." % str(ping_count))
|
||||||
|
|
||||||
|
if ping_count == 3:
|
||||||
|
# Fire off notifications
|
||||||
|
threading.Thread(target=notification_handler.notify_timeline,
|
||||||
|
kwargs=dict(notify_action='down')).start()
|
||||||
|
else:
|
||||||
|
ping_count = 0
|
||||||
|
|
||||||
|
|
||||||
def check_recently_added():
|
def check_recently_added():
|
||||||
|
@ -220,22 +233,3 @@ def check_recently_added():
|
||||||
# Fire off notifications
|
# Fire off notifications
|
||||||
threading.Thread(target=notification_handler.notify_timeline,
|
threading.Thread(target=notification_handler.notify_timeline,
|
||||||
kwargs=dict(timeline_data=item, notify_action='created')).start()
|
kwargs=dict(timeline_data=item, notify_action='created')).start()
|
||||||
|
|
||||||
|
|
||||||
def check_server_response():
|
|
||||||
|
|
||||||
with monitor_lock:
|
|
||||||
pms_connect = pmsconnect.PmsConnect()
|
|
||||||
response = pms_connect.get_server_response()
|
|
||||||
global ping_count
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
ping_count += 1
|
|
||||||
logger.warn(u"PlexPy Monitor :: Unable to get a response from the server, ping attempt %s." % str(ping_count))
|
|
||||||
|
|
||||||
if ping_count == 3:
|
|
||||||
# Fire off notifications
|
|
||||||
threading.Thread(target=notification_handler.notify_timeline,
|
|
||||||
kwargs=dict(notify_action='down')).start()
|
|
||||||
else:
|
|
||||||
ping_count = 0
|
|
|
@ -179,7 +179,7 @@ def notify_timeline(timeline_data=None, notify_action=None):
|
||||||
body=notify_strings[1])
|
body=notify_strings[1])
|
||||||
# Set the notification state in the db
|
# Set the notification state in the db
|
||||||
set_notify_state(session=timeline_data, state=notify_action, agent_info=agent)
|
set_notify_state(session=timeline_data, state=notify_action, agent_info=agent)
|
||||||
elif notify_action == 'down':
|
elif not timeline_data and notify_action:
|
||||||
for agent in notifiers.available_notification_agents():
|
for agent in notifiers.available_notification_agents():
|
||||||
if agent['on_down'] and notify_action == 'down':
|
if agent['on_down'] and notify_action == 'down':
|
||||||
# Build and send notification
|
# Build and send notification
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue