def get_all_events(what, filters): headers = "" for f in filters: try: headers += f.event_headers() except: pass query = "GET %s\n%s" % (what, headers) try: debug = config.debug_mkeventd_queries except: debug = False if debug \ and html.output_format == "html" and 'W' in html.display_options: html.write( '<div class="livestatus message" onmouseover="this.style.display=\'none\';">' '<tt>%s</tt></div>\n' % (query.replace('\n', '<br>\n'))) response = mkeventd.query(query) # First line of the response is the list of column names. headers = response[0] rows = [] for r in response[1:]: rows.append(dict(zip(headers, r))) return rows
def get_all_events(what, filters, limit): headers = "" for f in filters: try: headers += f.event_headers() except: pass if limit: headers += "Limit: %d\n" % limit query = "GET %s\n%s" % (what, headers) try: debug = config.debug_mkeventd_queries except: debug = False if debug \ and html.output_format == "html" and 'W' in html.display_options: html.write('<div class="livestatus message" onmouseover="this.style.display=\'none\';">' '<tt>%s</tt></div>\n' % (query.replace('\n', '<br>\n'))) response = mkeventd.query(query) # First line of the response is the list of column names. headers = response[0] rows = [] for r in response[1:]: rows.append(dict(zip(headers, r))) return rows
def render_mkeventd_performance(): def write_line(left, right): html.write("<tr><td class=left>%s:</td>" "<td class=right><strong>%s</strong></td></tr>" % (left, right)) html.write('<table class="content_center mkeventd_performance">\n') raw_data = mkeventd.query("GET status") data = dict(zip(raw_data[0], raw_data[1])) for what, col, format in [ (_("Received messages"), "message", "%.2f/s"), (_("Rule hits"), "rule_hit", "%.2f/s"), (_("Rule tries"), "rule_trie", "%.2f/s"), (_("Created events"), "event", "%.2f/s"), ]: write_line(what, format % data["status_average_%s_rate" % col]) try: write_line( _("Rule hit ratio"), "%.2f%%" % (data["status_average_rule_hit_rate"] / data["status_average_rule_trie_rate"] * 100), ) except: # division by zero pass write_line(_("Processing time per message"), "%.2f ms" % (data["status_average_processing_time"] * 1000)) html.write("</table>\n")
def render_mkeventd_performance(): def write_line(left, right): html.write("<tr><td class=left>%s:</td>" "<td class=right><strong>%s</strong></td></tr>" % (left, right)) html.write("<table class=\"content_center mkeventd_performance\">\n") raw_data = mkeventd.query("GET status") data = dict(zip(raw_data[0], raw_data[1])) for what, col, format in \ [ (_("Received messages"), "message", "%.2f/s"), (_("Rule hits"), "rule_hit", "%.2f/s"), (_("Rule tries"), "rule_trie", "%.2f/s"), (_("Created events"), "event", "%.2f/s"), ]: write_line(what, format % data["status_average_%s_rate" % col]) try: write_line( _("Rule hit ratio"), "%.2f%%" % (data["status_average_rule_hit_rate"] / data["status_average_rule_trie_rate"] * 100)) except: # division by zero pass write_line(_("Processing time per message"), "%.2f ms" % (data["status_average_processing_time"] * 1000)) html.write("</table>\n")
def render_mkeventd_performance(): def write_line(left, right): html.write("<tr><td class=left>%s:</td>" "<td class=right><strong>%s</strong></td></tr>" % (left, right)) try: raw_data = mkeventd.query("GET status") except: html.write(_("Event Console is not running.")) return html.write("<table class=\"content_center mkeventd_performance\">\n") data = dict(zip(raw_data[0], raw_data[1])) columns = [ (_("Received messages"), "message", "%.2f/s"), (_("Rule hits"), "rule_hit", "%.2f/s"), (_("Rule tries"), "rule_trie", "%.2f/s"), (_("Created events"), "event", "%.2f/s"), (_("Client connects"), "connect", "%.2f/s"), ] for what, col, format in columns: write_line(what, format % data["status_average_%s_rate" % col]) # Hit rate try: write_line( _("Rule hit ratio"), "%.2f %%" % (data["status_average_rule_hit_rate"] / data["status_average_rule_trie_rate"] * 100)) except: # division by zero write_line(_("Rule hit ratio"), _("-.-- %")) pass # Time columns time_columns = [ (_("Processing time per message"), "processing"), (_("Time per client request"), "request"), (_("Replication synchronization"), "sync"), ] for title, name in time_columns: value = data.get("status_average_%s_time" % name) if value: write_line(title, "%.2f ms" % (value * 1000)) else: write_line(title, _("-.-- ms")) html.write("</table>\n")
def render_mkeventd_performance(): def write_line(left, right): html.write("<tr><td class=left>%s:</td>" "<td class=right><strong>%s</strong></td></tr>" % (left, right)) try: raw_data = mkeventd.query("GET status") except: html.write(_("Event Console is not running.")) return html.write("<table class=\"content_center mkeventd_performance\">\n") data = dict(zip(raw_data[0], raw_data[1])) columns = [ (_("Received messages"), "message", "%.2f/s"), (_("Rule hits"), "rule_hit", "%.2f/s"), (_("Rule tries"), "rule_trie", "%.2f/s"), (_("Created events"), "event", "%.2f/s"), (_("Client connects"), "connect", "%.2f/s"), ] for what, col, format in columns: write_line(what, format % data["status_average_%s_rate" % col]) # Hit rate try: write_line(_("Rule hit ratio"), "%.2f %%" % ( data["status_average_rule_hit_rate"] / data["status_average_rule_trie_rate"] * 100)) except: # division by zero write_line(_("Rule hit ratio"), _("-.-- %")) pass # Time columns time_columns = [ (_("Processing time per message"), "processing"), (_("Time per client request"), "request"), (_("Replication synchronization"), "sync"), ] for title, name in time_columns: value = data.get("status_average_%s_time" % name) if value: write_line(title, "%.2f ms" % (value * 1000)) else: write_line(title, _("-.-- ms")) html.write("</table>\n")
def command_executor_mkeventd(command, site): response = mkeventd.query("COMMAND %s" % command)