From f155b0567c4e3bbdb94cca42c6197e2bf7367a11 Mon Sep 17 00:00:00 2001 From: Nyo Date: Thu, 6 Oct 2016 23:06:59 +0200 Subject: [PATCH] .BANCHO. Add Datadog stats report --- helpers/configHelper.py | 9 +++++++++ pep.py | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/helpers/configHelper.py b/helpers/configHelper.py index 8a23a30..1205cba 100644 --- a/helpers/configHelper.py +++ b/helpers/configHelper.py @@ -56,6 +56,10 @@ class config: self.config.get("discord","boturl") self.config.get("discord","devgroup") + self.config.get("datadog", "enable") + self.config.get("datadog", "apikey") + self.config.get("datadog", "appkey") + self.config.get("irc","enable") self.config.get("irc","port") self.config.get("irc","hostname") @@ -104,6 +108,11 @@ class config: self.config.set("discord", "boturl", "") self.config.set("discord", "devgroup", "") + self.config.add_section("datadog") + self.config.set("datadog", "enable") + self.config.set("datadog", "apikey") + self.config.set("datadog", "appkey") + self.config.add_section("irc") self.config.set("irc", "enable", "1") self.config.set("irc", "port", "6667") diff --git a/pep.py b/pep.py index 20b9ebd..cdffcd0 100644 --- a/pep.py +++ b/pep.py @@ -13,6 +13,7 @@ from raven.contrib.tornado import AsyncSentryClient from common import generalUtils from common.constants import bcolors from common.db import dbConnector +from common.ddog import datadogClient from common.log import logUtils as log from common.ripple import userUtils from common.web import schiavo @@ -190,6 +191,21 @@ if __name__ == "__main__": except: consoleHelper.printColored("[!] Error while starting sentry client! Please check your config.ini and run the server again", bcolors.RED) + # Set up datadog + try: + if generalUtils.stringToBool(glob.conf.config["datadog"]["enable"]): + glob.dog = datadogClient.datadogClient( + glob.conf.config["datadog"]["apikey"], + glob.conf.config["datadog"]["appkey"], + [ + datadogClient.periodicCheck("online_users", lambda: len(glob.tokens.tokens)), + datadogClient.periodicCheck("multiplayer_matches", lambda: len(glob.matches.matches)), + ]) + else: + consoleHelper.printColored("[!] Warning! Datadog stats tracking is disabled!", bcolors.YELLOW) + except: + consoleHelper.printColored("[!] Error while starting Datadog client! Please check your config.ini and run the server again", bcolors.RED) + # Cloudflare memes glob.cloudflare = generalUtils.stringToBool(glob.conf.config["server"]["cloudflare"])