def panel_phone_credit_left(phone): panel = new_graph('Credits left') add_metric(panel, 'phones', phone + '.credit', [2], kind='services') set_decimals(panel, 2) set_yaxis_units(panel, "currencyEUR") return panel
def panel_phone_credit_use(phone): panel = new_graph('Credits use') add_metric(panel, 'phones', phone + '.credit', [2], scale=-1, nnder=True, kind='services') set_decimals(panel, 2) set_yaxis_units(panel, "currencyEUR") return panel
def panel_sensor_group(host, title, group, unit, width=None): panel = new_graph(title, width=width) add_metric(panel, host, 'sensors.%s.*.*' % (group)) set_yaxis_units(panel, unit) return panel
def panel_diskspace_percent(host, width=None): title = 'Disk % free' panel = new_graph(title, width=width) add_metric(panel, host, "diskspace.*.byte_percentfree", [-2]) set_yaxis_units(panel, "percent") return panel
def panel_diskspace_bytes(host, width=None): title = 'Disk bytes available' panel = new_graph(title, width=width) add_metric(panel, host, "diskspace.*.byte_avail", [-2]) set_yaxis_units(panel, "bytes") return panel
def panel_length_average(host, base, width=None): title = "Average Line Length" panel = new_graph(title, width=width) add_metric(panel, host, '%s.total.length.average' % (base), 'Bytes') set_yaxis_units(panel, "bytes") return panel
def panel_network_bytes(host, title='Network bytes', width=None): panel = new_graph(title, width=width) add_metric(panel, host, 'network.*.rx_byte', [-2, -1]) add_metric(panel, host, 'network.*.tx_byte', [-2, -1]) set_yaxis_units(panel, "Bps") return panel
def panel_network_packets(host, width=None): title = 'Network packets' panel = new_graph(title, width=width) add_metric(panel, host, 'network.*.rx_packets', [-2, -1]) add_metric(panel, host, 'network.*.tx_packets', [-2, -1]) set_yaxis_units(panel, "pps") return panel
def panel_website_timing_total(host, metric_base, width=None): title = "Total request timings" panel = new_graph(title, width=width) add_metric(panel, host, '%s.total.duration.*' % (metric_base), [-1]) connect_missing_points(panel) set_point_mode(panel) set_yaxis_units(panel, "ms") return panel
def panel_library_next_due_date(library): panel = new_graph('Next due date') add_metric(panel, 'libraries', library + '.lent_items.next_due_date_days', [2], kind='services') set_yaxis_units(panel, "d") return panel
def panel_website_timing_per_status(host, metric_base, status, alias, width=None): title = 'Status %s (%s)' % (status, alias) panel = new_graph(title, width=width) for p in TIMINGS: add_metric(panel, host, '%s.status.%s.duration.%s' % (metric_base, status, p[0]), p[1]) connect_missing_points(panel) set_point_mode(panel) set_yaxis_units(panel, "ms") return panel
def panel_website_timing_per_method(host, metric_base, width=None): title = "q50 request timings per HTTP method" panel = new_graph(title, width=width) for method in METHODS: add_metric(panel, host, '%s.method.%s.duration.q50' % (metric_base, method), [-3]) connect_missing_points(panel) set_point_mode(panel) set_yaxis_units(panel, "ms") return panel
def panel_apache_connections(host, width=None): title = "Connections" panel = new_graph(title, width=width) add_metric(panel, host, 'apache.localhost.ConnsTotal', 'Total') add_metric(panel, host, 'apache.localhost.ConnsAsyncClosing', 'Async Closing') add_metric(panel, host, 'apache.localhost.ConnsAsyncKeepAlive', 'Async Keep-Alive') add_metric(panel, host, 'apache.localhost.ConnsAsyncWriting', 'Async Writing') set_yaxis_units(panel, right="Bps") switch_to_right_axis(panel, "Bytes") return panel
def panel_memory(host, metrics=DEFAULT_METRICS, width=None, title=None): if not isinstance(metrics, list): metrics = [metrics] if title is None: if metrics == DEFAULT_METRICS: title = 'Memory' elif metrics == ['used']: title = 'Used w/o Buffers and Cache' else: title = ','.join(metrics) panel = new_graph(title, width=width) if 'used' in metrics: add_metric(panel, host, ['memory.MemTotal', '#B', '#C', '#D'], 'Used w/o Buffers and Cache', sum='diff') add_metric(panel, host, 'memory.Buffers', visible=('Buffers' in metrics)) add_metric(panel, host, 'memory.Cached', visible=('Cached' in metrics)) add_metric(panel, host, 'memory.MemFree', 'Free', visible=('MemFree' in metrics)) metrics = copy.copy(metrics) for metric in ['used', 'Buffers', 'Cached', 'MemFree']: if metric in metrics: metrics.remove(metric) for metric in metrics: if metric == 'MemFree': label = 'Free' else: label = metric add_metric(panel, host, 'memory.%s' % metric, label) set_stacked_mode(panel) set_yaxis_units(panel, "bytes") set_colors(panel, COLORS) return panel
def panel_website_timing_per_method_detailed(host, metric_base, method, width=None): title = 'Method %s' % (method) panel = new_graph(title, width=width) for p in TIMINGS: add_metric(panel, host, '%s.method.%s.duration.%s' % (metric_base, method, p[0]), p[1]) connect_missing_points(panel) set_point_mode(panel) set_yaxis_units(panel, "ms") return panel
def panel_cpu(host, title=None, kinds=KINDS, width=None): if not isinstance(kinds, list): kinds = [kinds] if title is None: title = 'CPU' if kinds != ['*'] and kinds != KINDS: title += ' [' + (','.join(kinds)) + ']' panel = new_graph(title, width=width) for kind in kinds: add_metric(panel, host, 'cpu.total.%s' % kind) set_yaxis_units(panel, 'percent') set_stacked_mode(panel) set_colors(panel, COLORS) return panel
def panel_iostat_throughput(host, width=None): title = "Disk throughput" panel = new_graph(title, width=width) add_metric( panel, host, "iostat.*.read_byte_per_second", { 'kind': 'sub', 'match': "^.*\\.([^.]*)\\.([^._]*)_[^.]*$", 'replacement': "\\1 \\2" }) add_metric( panel, host, "iostat.*.write_byte_per_second", { 'kind': 'sub', 'match': "^.*\\.([^.]*)\\.([^._]*)_[^.]*$", 'replacement': "\\1 \\2" }) set_yaxis_units(panel, "Bps") return panel
def panel_apache_throughput(host, width=None): title = "Accesses" panel = new_graph(title, width=width) add_metric(panel, host, 'apache.localhost.TotalAccesses', 'Accesses', scale=True, nnder=True) # 17.06666 = 1024/60 add_metric(panel, host, 'apache.localhost.TotalkBytes', 'Bytes', scale=(1024. / 60), nnder=True) set_yaxis_units(panel, right="Bps") switch_to_right_axis(panel, "Bytes") return panel
def panel_website_timing_per_status_group(host, metric_base, width=None): title = "q50 request timings per status group" panel = new_graph(title, width=width) add_metric(panel, host, '%s.status.1xx.duration.q50' % (metric_base), '1xx - Informational') add_metric(panel, host, '%s.status.2xx.duration.q50' % (metric_base), '2xx - Success') add_metric(panel, host, '%s.status.3xx.duration.q50' % (metric_base), '3xx - Redirection') add_metric(panel, host, '%s.status.4xx.duration.q50' % (metric_base), '4xx - Client error') add_metric(panel, host, '%s.status.5xx.duration.q50' % (metric_base), '5xx - Server error') add_metric(panel, host, '%s.status.unparsable.duration.q50' % (metric_base), 'Unparsable') connect_missing_points(panel) set_point_mode(panel) set_yaxis_units(panel, "ms") return panel
def panel_phone_days_until_deactivation(phone): panel = new_graph('Days left until Deactivation') add_metric(panel, 'phones', phone + '.deactivation_days', [2], kind='services') set_yaxis_units(panel, "d") return panel