Beispiel #1
0
 def event_summary(status):
     total = 0
     info = 0
     warn = 0
     majr = 0
     crit = 0
     agentevents = WebData.web_code_event_totals(status)
     for i in agentevents:
         sev = int(i['severity'])
         sev_tot = int(i['total'])
         if sev == 1:
             crit = sev_tot
         elif sev == 2:
             majr = sev_tot
         elif sev == 3:
             warn = sev_tot
         elif sev == 4:
             info = sev_tot
     total = info + warn + majr + crit
     status_text = ""
     change_status = abs(int(status) - 1)
     change_status_text = ""
     if change_status == 0:
         status_text = "Open Events"
         change_status_text = "Closed Events"
     else:
         status_text = "Closed Events"
         change_status_text = "Open Events"
     html = """<table style="width:100%;text-align:center"><tr>
     <td style="text-align:left; padding-left:10px">""" + status_text + """</td>
     <td><svg width="10" height="10"><rect width="10" height="10" style="fill:#CCCCCC" /></svg>&nbsp; """ + str(
         total
     ) + """&nbsp;  Total</td>
     <td><svg width="10" height="10"><rect width="10" height="10" style="fill:#29ABE0" /></svg>&nbsp;  """ + str(
         info
     ) + """&nbsp;  Information</td>
     <td><svg width="10" height="10"><rect width="10" height="10" style="fill:#FFC107" /></svg>&nbsp;  """ + str(
         warn
     ) + """&nbsp;  Warning</td>
     <td><svg width="10" height="10"><rect width="10" height="10" style="fill:#F47C3C" /></svg>&nbsp;  """ + str(
         majr
     ) + """&nbsp;  Major</td>
     <td><svg width="10" height="10"><rect width="10" height="10" style="fill:#D9534F" /></svg>&nbsp;  """ + str(
         crit
     ) + """&nbsp;  Critical</td>
     <td style="text-align:right;padding-right:12px"><input type="button" onclick="window.location.href='/events/?status=""" + str(
         change_status
     ) + """'" class="action-button" value='""" + change_status_text + """' /></td>
     </tr></table>"""
     return html
Beispiel #2
0
 def index_block_2():
     info = 0
     warn = 0
     majr = 0
     crit = 0
     agentevents = WebData.web_code_event_totals(1)
     for i in agentevents:
         sev = int(i['severity'])
         sev_tot = int(i['total'])
         if sev == 1:
             crit = sev_tot
         elif sev == 2:
             majr = sev_tot
         elif sev == 3:
             warn = sev_tot
         elif sev == 4:
             info = sev_tot
     total = info + warn + majr + crit
     if total == 0: total = 1
     info_perc = (info / total) * 100
     warn_perc = (warn / total) * 100
     majr_perc = (majr / total) * 100
     crit_perc = (crit / total) * 100
     info_points = str(info_perc) + ' ' + str(100 - info_perc)
     warn_points = str(warn_perc) + ' ' + str(100 - warn_perc)
     majr_points = str(majr_perc) + ' ' + str(100 - majr_perc)
     crit_points = str(crit_perc) + ' ' + str(100 - crit_perc)
     html = """<table style="width:100%;height:105px"><tr><td style="width:50%;text-align:center">
     <svg width="95" height="95" viewBox="0 0 42 42" class="donut">
     <circle class="donut-ring" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#93C54B" stroke-width="5"></circle>
     <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#29ABE0" stroke-width="5" stroke-dasharray='""" + info_points + """' stroke-dashoffset="25"></circle>
     <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#ffc107" stroke-width="5" stroke-dasharray='""" + warn_points + """' stroke-dashoffset='""" + str(
         100 - info_perc + 25) + """'></circle>
     <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#F47C3C" stroke-width="5" stroke-dasharray='""" + majr_points + """' stroke-dashoffset='""" + str(
             100 - info_perc - warn_perc + 25) + """'></circle>
     <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#d9534f" stroke-width="5" stroke-dasharray='""" + crit_points + """' stroke-dashoffset='""" + str(
                 100 - info_perc - warn_perc - majr_perc +
                 25) + """'></circle>
     </svg></td><td style="width:50%;vertical-align:top;padding-top:16px">
     <svg width="10" height="10"><rect width="10" height="10" style="fill:#29ABE0" /></svg> """ + str(
                     info) + """ Information<br />
     <svg width="10" height="10"><rect width="10" height="10" style="fill:#ffc107" /></svg> """ + str(
                         warn) + """ Warning<br />
     <svg width="10" height="10"><rect width="10" height="10" style="fill:#F47C3C" /></svg> """ + str(
                             majr) + """ Major<br />
     <svg width="10" height="10"><rect width="10" height="10" style="fill:#d9534f" /></svg> """ + str(
                                 crit) + """ Critical
     </td></tr></table>"""
     return html