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

Add nextcloud domains to uptime as well

parent c7704419
No related branches found
No related tags found
No related merge requests found
......@@ -92,10 +92,20 @@ class ActionModule(ActionBase):
options = self.config.options('Domains')
if self.config.has_section('Paths'):
paths = self.config.options('Paths')
else:
paths = {}
if self.config.has_section('Matches'):
matches = self.config.options('Matches')
else:
matches = {}
display.vv('Process hosts')
for host in self.vars.get('ansible_play_hosts'):
display.vv('- ' + host)
self._host(host, options)
self._host(host, options, paths, matches)
result['msg'] = 'Completed successfully!'
return result
......@@ -201,17 +211,17 @@ class ActionModule(ActionBase):
return False
def _buildUrl(self, item, field):
def _buildUrl(self, item, field, path):
authPrefix = ''
auth = item.get('apache_auth')
if auth and auth.get('type') == 'Basic':
authPrefix = auth.get('user') + ':' + auth.get('password') + '@'
url = item.get('protocol', 'https') + '://' + authPrefix + item.get(field)
uptime = item.get('uptime')
if uptime:
if uptime and 'path' in uptime:
path = uptime.get('path')
if path:
url += '/' + path
if path and path != '':
url += '/' + path
return url
......@@ -262,7 +272,7 @@ class ActionModule(ActionBase):
return check
def _host(self, host, options):
def _host(self, host, options, paths, matches):
host_vars = self.vars['hostvars'][host]
for option in options:
display.vv(' - ' + option)
......@@ -270,10 +280,18 @@ class ActionModule(ActionBase):
if items:
parts = self.config.get('Domains', option).split('.')
field = parts.pop()
self._part(host_vars, items, 0, parts, field)
def _part(self, host_vars, items, level, parts, field):
if option in paths:
path = self.config.get('Paths', option)
else:
path = ''
if option in matches:
match = self.config.get('Matches', option)
else:
match = ''
self._part(host_vars, items, 0, parts, field, path, match)
def _part(self, host_vars, items, level, parts, field, path, match):
if len(parts) > level:
next = parts[level]
level += 1
......@@ -281,17 +299,21 @@ class ActionModule(ActionBase):
for item in items:
nextitems = item.get(next)
if nextitems:
self._part(host_vars, nextitems, level, parts, field)
self._part(host_vars, nextitems, level, parts, field, path, match)
else:
for item in items:
value = item.get(field)
if value:
display.vv(' ' + value)
self._processItem(host_vars, item, field)
if match != '':
if not item.has_key('pollerParams'):
item['pollerParams'] = {}
item['pollerParams']['match'] = '/' + match + '/'
self._processItem(host_vars, item, field, path)
def _processItem(self, host_vars, item, field):
url = self._buildUrl(item, field)
def _processItem(self, host_vars, item, field, path):
url = self._buildUrl(item, field, path)
check = self._buildCheck(host_vars, item, url)
tracker_source = check.get('tracker_source', '')
tracker_project_include = check.get('tracker_project_include', '')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment