add errors count in env

This commit is contained in:
saravanan30erd 2020-03-08 18:02:53 +04:00
parent b9c5991194
commit 7ec1a038cc
2 changed files with 37 additions and 41 deletions

View file

@ -47,7 +47,7 @@ def arrange_services(services):
name1, _, name2 = name.partition('-') name1, _, name2 = name.partition('-')
if name2 == '': if name2 == '':
name2 = name1 name2 = name1
name1 = 'All' name1 = 'others'
if name1 not in list(checks.keys()): if name1 not in list(checks.keys()):
checks[name1] = OrderedDict() checks[name1] = OrderedDict()
checks[name1][name2] = int(service['status']) checks[name1][name2] = int(service['status'])
@ -84,7 +84,6 @@ def getMonit():
server = dict(name=site, url=s['url'], server = dict(name=site, url=s['url'],
result=s_checks, s_rate=count) result=s_checks, s_rate=count)
output.append(server) output.append(server)
output.append({'url': u'https://monit.xxx.xxx', 'result': {'All': OrderedDict([(u'staging', 32), (u'monitoring1', 0)])}, 's_rate': {'green': 70.0, 'red': 30.0}, 'name': u'Test Environment'})
print(datetime.datetime.now()) print(datetime.datetime.now())
return(output) return(output)

View file

@ -1,5 +1,6 @@
$def with (output, now) $def with (output, now)
<!-- Functions -->
$def row_error(check): $def row_error(check):
<tr> <tr>
<td><a href="$output[server]['url']/$env-$check" <td><a href="$output[server]['url']/$env-$check"
@ -14,6 +15,22 @@ $def row_ok(check):
<td><img src="static/img/ok.png"></td> <td><img src="static/img/ok.png"></td>
</tr> </tr>
$def table_contents(color, text, services):
<thead class="inner-rows">
<tr><th class="th-custom ${color}" colspan="2">
<a style="color: white">$text</a>
</th></tr>
</thead>
<tbody class="toggle-id">
$for check in services.keys():
$ isError = services.get(check)
$if isError != 0:
$:row_error(check)
$else:
$:row_ok(check)
</tbody>
<!-- Main Content -->
<body onload="draw($output[0]['s_rate']);"> <body onload="draw($output[0]['s_rate']);">
$ errors = 0 $ errors = 0
$ color = "green" $ color = "green"
@ -54,35 +71,14 @@ $def row_ok(check):
$if isError != 0: $if isError != 0:
$ errors=errors+1 $ errors=errors+1
$if errors > 0: $if errors > 0:
$ color = "red" $code:
<thead class="inner-rows"> color = "red"
<tr><th class="th-custom ${color}" colspan="2"> txt = "{}: {} error(s)".format(env, errors)
<a style="color: white">$env</a> $:table_contents(color, txt, services)
</th></tr>
</thead>
<tbody class="toggle-id">
$for check in services.keys():
$ isError = services.get(check)
$if isError != 0:
$:row_error(check)
$else: $else:
$:row_ok(check) $code:
</tbody> color = "green"
$else: $:table_contents(color, env, services)
$ color = "green"
<thead class="inner-rows">
<tr><th class="th-custom ${color}" colspan="2">
<a style="color: white">$env</a>
</th></tr>
</thead>
<tbody class="toggle-id">
$for check in services.keys():
$ isError = services.get(check)
$if isError != 0:
$:row_error(check)
$else:
$:row_ok(check)
</tbody>
</table> </table>
</div> </div>
$else: $else:
@ -99,18 +95,19 @@ $def row_ok(check):
</th></tr> </th></tr>
</thead> </thead>
$for env, services in output[server]['result'].items(): $for env, services in output[server]['result'].items():
<thead class="server-link"> $ errors = 0
<tr><th colspan="2">
<a href="$output[server]['url']" target="_blank">$env</a>
</th></tr>
</thead>
$for check in services.keys(): $for check in services.keys():
$ isError = services.get(check) $ isError = services.get(check)
$if isError != 0: $if isError != 0:
$:row_error(check) $ errors=errors+1
$if errors > 0:
$code:
color = "red"
txt = "{}: {} error(s)".format(env, errors)
$:table_contents(color, txt, services)
$else: $else:
$:row_ok(check) $ color = "green"
$:table_contents(color, env, services)
</table> </table>
</div> </div>
</div> </div>