{# use recursion to get summary stats at all levels #}
{# NOTE: recursion is not needed if not using tag grouping or if the template is designed for a specific tag set #}
{% macro print_summary_stats(data, label=[]) -%}
{% set group_name = ' + '.join(label) if label else 'ALL' %}
Average uptime for {{ group_name }} : {{ data._stats.gs_pct_avg|round(4) if data._stats.gs_pct_avg >= 0 else 'n/a' }}
{% for tag in data.keys() %}
{% if tag[0] != '_' %}
{{ print_summary_stats(data[tag], label=(label + [tag])) }}
{% endif %}
{% endfor %}
{%- endmacro %}
{{ print_summary_stats(checks_data) }}
Check Name | Uptime % | Downtime |
---|---|---|
average uptime {{ group_name }} |
{{ data._stats.gs_pct_avg|round(4) }} | |
{{ check.name }} |
{{ check.uptime.pct|round(4) }} | {{ check.uptime.totaldown|seconds_to_dhms }} |