NAME

Thruk::Utils::Render - Report Rendering Utilities Collection

DESCRIPTION

Report Rendering Utilities Collection. All subs will be available in report templates. Templates are Template::Toolkit templates and are responsible for the report layout, the mail content and the required parameters for a report.

METHODS

sort_by_key

sort_by_key()

return sorted list of hashes

current_page

current_page()

return and increase page number

calculate_availability

calculate_availability()

calculate availability from stash data

get_service_filter

get_service_filter($service_param)

convert services into a s_filter usable by Avail.pm

expand_service_slas

expand_service_slas($service_param)

expand services sla levels

outages

outages($logs, $start, $end, $hst, $svc)

print outages from log entries

set_unavailable_states

set_unavailable_states($states)

set list of states which count as unavailable

get_report_timeperiod

get_report_timeperiod()

return report timeperiod in human readable form

get_events

get_events()

set events by pattern from eventlog

get_url_with_retries

get_url_with_retries($retries, $delay)

calls get_url but retries on errors

get_url

get_url()

save content from url

count_event_totals

count_event_totals()

count host / service totals from events

get_availability_percents

get_availability_percents($hst, $svc)

return list of availability percent as json list

get_month_name

get_month_name(date, monthNamesList)

return human readable month name

get_week_name

get_week_name(date)

return human readable week name

get_day_name

get_day_name(date)

return human readable day name

get_graph_source

get_graph_source(c, host, service)

return index of first graph for given host (or service) provided by the _GRAPH_SOURCE custom variable or 1 as default fallback.

get_pnp_image

get_pnp_image(hst, svc, start, end, width, height, source)

return base64 encoded pnp image if possible. An empty string will be returned if no PNP graph can be exported.

dump

dump(...)

dump variables to stderr

html_all_inclusive

html_all_inclusive($c, $url, $page, [$include_js])

make html page include all remove css, js and images

page_splice

page_splice($data, $size_per_page, $max_pages)

cut data in chunks of $size_per_page size. $max_pages is the maximum number of pages or -1 for all.

round_decimals

round_decimals($float, $decimals, [$round_method])

Round number to given decimals. method can be 'floor' or 'round'.

- round will do a standard mathematical round

replace_css_and_images

replace_css_and_images($text, $url, $report_base_url)

Replace css and images in given text

set_action_image_data_urls

set_action_image_data_urls($c, $urls)

replaces hash of urls with data urls

_absolutize_url

returns a absolute url

expects
$VAR1 = origin url
$VAR2 = target link

EXAMPLES

See the shipped reports for some examples. Shipped reports are in the 'plugins/plugins-available/reports2/templates/reports' folder.