Commit 13c0e571 authored by David Trattnig's avatar David Trattnig
Browse files

More monitoring parameters.

parent 952abc33
......@@ -36,7 +36,7 @@ mailsubject_prefix="[Aura Engine]"
[api]
# STEERING
api_steering_status = "http://localhost:8000/api/v1/playout"
api_steering_status = "http://localhost:8000/api/v1/"
# The URL to get the Calendar via Steering
api_steering_calendar="http://localhost:8000/api/v1/playout"
# The URL to get show details via Steering
......
......@@ -36,7 +36,7 @@ mailsubject_prefix="[Aura Engine]"
[api]
# STEERING
api_steering_status = "http://localhost:8000/api/v1/playout"
api_steering_status = "http://localhost:8000/api/v1/"
# The URL to get the Calendar via Steering
api_steering_calendar="http://localhost:8000/api/v1/playout"
# The URL to get show details via Steering
......
......@@ -36,7 +36,7 @@ mailsubject_prefix="[Aura Engine]"
[api]
# STEERING
api_steering_status = "http://localhost:8000/api/v1/playout"
api_steering_status = "http://localhost:8000/api/v1/"
# The URL to get the Calendar via Steering
api_steering_calendar="http://localhost:8000/api/v1/playout"
# The URL to get show details via Steering
......
......@@ -114,19 +114,34 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
return self.message
# ------------------------------------------------------------------------------------------ #
def uptime(self, command=""): # no command will come
return self.command("uptime", "")
"""
Retrieves how long the engine is running already.
"""
return self.command("", "uptime")
# ------------------------------------------------------------------------------------------ #
def auraengine(self, command, *args):
def version(self, command=""): # no command will come
"""
Retrieves the Liquidsoap version.
"""
return self.command("", "version")
def engine(self, command, *args):
"""
Retrieves the state of all input and outputs.
"""
if command == "state":
return self.auraengine_state()
return self.engine_state()
return "LiquidSoapPlayerClient does not understand auraengine." + command + str(args)
return "LiquidSoapPlayerClient does not understand engine." + command + str(args)
# ------------------------------------------------------------------------------------------ #
def auraengine_state(self):
def engine_state(self):
"""
Retrieves the state of all input and outputs.
"""
self.command('auraengine', 'state')
return self.message
......
......@@ -84,7 +84,7 @@ class SoundSystem():
# f.close()
self.auramailer = AuraMailer(self.config)
self.is_liquidsoap_up_and_running()
self.is_active()
# Initialize Default Channels
self.active_channel = {
......@@ -867,8 +867,11 @@ class SoundSystem():
self.logger.critical("SEND ADMIN MAIL AT THIS POINT")
raise e
# ------------------------------------------------------------------------------------------ #
def is_liquidsoap_up_and_running(self):
def is_active(self):
"""
Checks if Liquidsoap is running
"""
try:
self.uptime()
self.is_liquidsoap_running = True
......@@ -878,14 +881,22 @@ class SoundSystem():
except Exception as e:
self.logger.error("Cannot check if Liquidsoap is running. Reason: " + str(e))
self.is_liquidsoap_running = False
return self.is_liquidsoap_running
# ------------------------------------------------------------------------------------------ #
def auraengine_state(self):
state = self.__send_lqc_command__(self.client, "auraengine", "state")
def engine_state(self):
"""
Retrieves the state of all inputs and outputs.
"""
state = self.__send_lqc_command__(self.client, "engine", "state")
return state
# ------------------------------------------------------------------------------------------ #
def liquidsoap_help(self):
"""
Retrieves the Liquidsoap help.
"""
data = self.__send_lqc_command__(self.client, "help", "")
if not data:
self.logger.warning("Could not get Liquidsoap's help")
......@@ -893,19 +904,19 @@ class SoundSystem():
self.logger.debug("Got Liquidsoap's help")
return data
# ------------------------------------------------------------------------------------------ #
def version(self):
"""
get version
Get the version of Liquidsoap.
"""
data = self.__send_lqc_command__(self.client, "version", "")
self.logger.debug("Got Liquidsoap's version")
return data
# ------------------------------------------------------------------------------------------ #
def uptime(self):
"""
get uptime
Retrieves the uptime of Liquidsoap.
"""
data = self.__send_lqc_command__(self.client, "uptime", "")
self.logger.debug("Got Liquidsoap's uptime")
......
......@@ -19,6 +19,7 @@
import urllib
import logging
import json
import os.path
from os import path
......@@ -43,19 +44,27 @@ class Monitoring:
self.soundsystem = soundsystem
self.status = dict()
self.status["soundsystem"] = dict()
self.status["api"] = dict()
def update_status(self):
"""
Requests the current status of all components
"""
self.status["soundsystem"]["mixer"] = self.soundsystem.get_mixer_status()
self.soundsystem.enable_transaction(self.soundsystem.client)
self.status["soundsystem"]["version"] = self.soundsystem.version()
self.status["soundsystem"]["active"] = self.soundsystem.is_active()
self.status["soundsystem"]["uptime"] = self.soundsystem.uptime()
self.status["soundsystem"]["io"] = self.get_io_state()
self.status["soundsystem"]["mixer"] = self.soundsystem.get_mixer_status()
#self.status["soundsystem"]["recorder"] = self.soundsystem.get_recorder_status()
self.status["redis_ready"] = self.validate_redis_connection()
self.status["api_steering_ready"] = self.validate_url_connection(self.config.get("api_steering_status"))
self.status["api_tank_ready"] = self.validate_url_connection(self.config.get("api_tank_status"))
self.status["audio_store"] = self.validate_directory(self.config.get("audiofolder"))
self.soundsystem.disable_transaction(self.soundsystem.client)
self.status["api"]["steering_ready"] = self.validate_url_connection(self.config.get("api_steering_status"))
self.status["api"]["tank_ready"] = self.validate_url_connection(self.config.get("api_tank_status"))
self.status["redis_ready"] = self.validate_redis_connection()
self.status["audio_store"] = self.validate_directory(self.config.get("audiofolder"))
# Set overall status
if self.has_valid_status():
......@@ -64,6 +73,22 @@ class Monitoring:
self.status["engine_status"] = "INVALID"
def get_io_state(self):
"""
Retrieves all input and outputs provided by the engine.
"""
ios = self.soundsystem.engine_state()
# ios = ios.replace("\\", "")
try:
# ios = ios.replace(": },", "''},")
ios = ios.replace('"connected":', '"connected": ""')
ios = json.loads(ios, strict=False)
return ios
except Exception as e:
self.logger.warn("Got invalid JSON from soundsystem - " + str(e))
return "[ERROR]"
def get_status(self):
"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment