Skip to content
Snippets Groups Projects
Commit 46516ae0 authored by jurgenhaas's avatar jurgenhaas
Browse files

Include Mattermost into Uptime

parent 920162b1
Branches
No related tags found
No related merge requests found
......@@ -203,10 +203,22 @@ class ActionModule(ActionBase):
}
def _buildCheck(self, item, url):
def _addHostSettings(self, host_vars, section, check):
settings = host_vars.get(section)
if settings:
for key in settings:
item = section + '_' + key
check[item] = settings[key]
if not item in self.pollerParams:
self.pollerParams.append(item)
return check
def _buildCheck(self, host_vars, item, url):
check = self._defaultCheck()
check['url'] = url
check['type'] = item.get('protocol', 'https')
check = self._addHostSettings(host_vars, 'mattermost', check)
uptime = item.get('uptime')
if uptime:
for key in self._defaultCheck():
......@@ -236,10 +248,10 @@ class ActionModule(ActionBase):
if items:
parts = self.config.get('Domains', option).split('.')
field = parts.pop()
self._part(items, 0, parts, field)
self._part(host_vars, items, 0, parts, field)
def _part(self, items, level, parts, field):
def _part(self, host_vars, items, level, parts, field):
if len(parts) > level:
next = parts[level]
level += 1
......@@ -247,18 +259,18 @@ class ActionModule(ActionBase):
for item in items:
nextitems = item.get(next)
if nextitems:
self._part(nextitems, level, parts, field)
self._part(host_vars, nextitems, level, parts, field)
else:
for item in items:
value = item.get(field)
if value:
display.vv(' ' + value)
self._processItem(item, field)
self._processItem(host_vars, item, field)
def _processItem(self, item, field):
def _processItem(self, host_vars, item, field):
url = self._buildUrl(item, field)
check = self._buildCheck(item, url)
check = self._buildCheck(host_vars, item, url)
existing = self._findExistingCheck(url, check['type'])
if existing:
if check['enabled']:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment