Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions datadog_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import datadog
import yaml

config_file = "datadog_callback.yml"

class CallbackModule(object):
def __init__(self):
# Read config and set up API client
api_key, url = self._load_conf(os.path.join(os.path.dirname(__file__), "datadog_callback.yml"))
datadog.initialize(api_key=api_key, api_host=url)
if not os.path.isfile(os.path.join(os.path.dirname(__file__),config_file)):
self.disabled = True
print 'Datadog callback disabled.\nMake sure you have "{0}" configuration file.'.format(config_file)

self._playbook_name = None
self._start_time = time.time()
Expand Down Expand Up @@ -144,6 +144,10 @@ def runner_on_unreachable(self, host, res):
)

def playbook_on_start(self):
# Read config and set up API client
api_key, url = self._load_conf(os.path.join(os.path.dirname(__file__), config_file))
datadog.initialize(api_key=api_key, api_host=url)

# Retrieve the playbook name from its filename
self._playbook_name, _ = os.path.splitext(
os.path.basename(self.playbook.filename))
Expand Down