Merge pull request #7 from saravanan30erd/sort_items

Sort the service items based on the errors
Errors will be listed on top of each list for the sake of clarity when browsing the dashboard.
This commit is contained in:
adriaaah 2019-08-15 10:19:59 +02:00 committed by GitHub
commit 7ea70a07f5

View file

@ -7,6 +7,8 @@ import json
import os import os
import sys import sys
import datetime import datetime
from collections import OrderedDict
from operator import itemgetter
urls = ('/', 'index', urls = ('/', 'index',
'/help', 'help' '/help', 'help'
@ -26,8 +28,6 @@ output = []
def getMonit(): def getMonit():
output = [] output = []
server = {}
checks = {}
xmlQuery = "/_status?format=xml" xmlQuery = "/_status?format=xml"
with open('{0}/conf/servers.json'.format(os.path.expanduser('.'))) as f: with open('{0}/conf/servers.json'.format(os.path.expanduser('.'))) as f:
@ -42,14 +42,17 @@ def getMonit():
services = allstat['service'] services = allstat['service']
status = {} status = {}
checks = {} server = {}
checks = OrderedDict()
for service in services: for service in services:
name = service['name'] name = service['name']
status[name] = int(service['status']) status[name] = int(service['status'])
checks[service['name']] = status[name] checks[name] = status[name]
server = dict(name=site, url=s['url'], result=checks) sorted_checks = OrderedDict()
sorted_checks = OrderedDict(sorted(checks.iteritems(), key=itemgetter(1), reverse=True))
server = dict(name=site, url=s['url'], result=sorted_checks)
output.append(server) output.append(server)