Ejemplo n.º 1
0
 def GET(self):
     arch_count = db.select("ENV", what="ARCH, COUNT(UUID) AS HOSTS", group="ARCH")
     arch_data = dict()
     for t in arch_count:
         arch_data[t["ARCH"]] = {"HOSTS": t["HOSTS"]}
     if helpers.is_json_request():
         return helpers.serialize(arch_data)
     else:
         # generate plot
         x_ticklabels = arch_data.keys()
         y_values = [arch_data[a]["HOSTS"] for a in x_ticklabels]
         arch_plot = helpers.barchart(
             title="Hosts per arch",
             x_label="Arch",
             y_label="Number of Hosts",
             x_ticklabels=x_ticklabels,
             y_values=y_values,
         )
         return render.arch(arch_data, arch_plot)
Ejemplo n.º 2
0
 def GET(self):
     keyword_count = db.query('SELECT KEYWORD,\
             COUNT(DISTINCT IPKEY) AS PACKAGES,\
             COUNT(DISTINCT UUID) AS HOSTS\
             FROM GLOBAL_KEYWORDS NATURAL JOIN KEYWORDS\
             NATURAL JOIN INSTALLED_PACKAGES GROUP BY KEYWORD')
     keyword_data = dict()
     for t in keyword_count:
         keyword_data[t['KEYWORD']] = {'HOSTS':t['HOSTS'], 'PACKAGES':t['PACKAGES']}
     if helpers.is_json_request():
         return helpers.serialize(keyword_data)
     else:
         # generate plot
         x_ticklabels = keyword_data.keys()
         y_values = [ keyword_data[k]['PACKAGES'] for k in x_ticklabels ]
         keyword_plot = helpers.barchart(title = 'Installed packages per keyword',
                 x_label = 'Keyword', y_label = 'Number of Packages',
                 x_ticklabels = x_ticklabels, y_values = y_values)
         return render.keyword(keyword_data, keyword_plot)