NAME

Thruk::Backend::Manager - Manager of backend connections

DESCRIPTION

Manager of backend connections

METHODS

new

create new manager

pool

returns connection pool

peers

returns hash of peers

peer_order

returns list of peers

authoritive_peer_keys

returns list of authoritive peers (used to fetch can_submit_commands / groups)

lmd_peer

returns pools lmd_peer

update_sections

calculate sections

disable_hidden_backends

disable_hidden_backends()

returns list of hidden backends

get_peers

get_peers([$all])

returns all configured peers (except config-only)

get_local_peers

get_local_peers()

returns all configured peers which use a local unix socket to connect

get_peer_by_key

get_peer_by_key()

returns peer by key

get_peer_by_name

get_peer_by_name()

returns peer by name

get_http_peers

get_http_peers([$with_fallbacks])

returns all configured peers which have a http connection type

peer_key

peer_key()

returns all peer keys

sections

sections()

returns all sections

disable_backend

disable_backend(<key>)

disable backend by key

enable_backend

enable_backend(<key>)

ensable backend by key

disable_backends

disable_backends(<keys_hash>)

disabled backend by key hash

enable_backends

enable_backends(<keys>, [<exclusive>])

enables all backends. list is additive unless exclusive is used.

enable_default_backends

enable_default_backends()

enables all default backends

get_default_backends

get_default_backends()

returns all default backends

get_scheduling_queue

get_scheduling_queue

returns the scheduling queue

get_performance_stats

get_performance_stats

wrapper around get_performance_stats

get_hosts

get_hosts

wrapper around get_hosts

get_services

get_services

wrapper around get_services

get_host_stats_by_servicequery

get_host_stats_by_servicequery

calculate host statistics from services query

get_all_child_hosts

get_all_child_hosts

returns list of all recursive child hosts

get_host_stats_by_backend

get_hosts

wrapper around get_hosts

get_contactgroups_by_contact

get_contactgroups_by_contact

returns a list of contactgroups by contact

get_hostgroup_names_from_hosts

get_hostgroup_names_from_hosts

returns a list of hostgroups but get list from hosts in order to respect permissions

get_servicegroup_names_from_services

get_servicegroup_names_from_services

returns a list of servicegroups but get list from services in order to respect permissions

reconnect

reconnect

runs reconnect on all peers

expand_command

expand_command

expand a command line with host/service data

logcache_stats

logcache_stats($c)

return logcache statistics

logcache_existing_caches

logcache_existing_caches($c)

return peer ids of existing log caches

get_logs

get_logs(@args)

retrieve logfiles

renew_logcache

renew_logcache($c, [$noforks])

update the logcache, returns 1 on success or undef otherwise

get_comments_by_pattern

get_comments_by_pattern($c, $host, $svc, $pattern)

retrieve backend and ID of host or service comment(s) that match the given pattern

_renew_logcache

_renew_logcache($c)

update the logcache (internal sub)

close_logcache_connections

close_logcache_connections($c)

close all logcache connections

lmd_stats

lmd_stats($c)

return lmd statistics

_get_macros

_get_macros

returns a hash of macros

replace_macros

replace_macros($string, $args, [$macros])

replace macros in given string.

returns ($result, $rc)

$args should be: { host => host object (or service object) service => service object skip_user => 0/1 # skips user macros args => list of arguments }

get_macros

get_macros($args)

returns a hash of macros

$args should be: { host => host object (or service object) service => service object skip_user => 0/1 # skips user macros filter_user => 0/1 # filters user macros args => list of arguments }

_get_replaced_string

_get_replaced_string

returns replaced string

_get_obfuscated_string

_get_obfuscated_string

replace sensitive data with ***

_set_host_macros

_set_host_macros

set host macros

_set_service_macros

_set_service_macros

sets service macros

_do_on_peers

_do_on_peers($function, $args, [ $force_serial ], [ $backends ], [ $raw_result ])

returns a result for a function called for all peers

$function is the name of the function called on our peers
$args is a hash:
{
  backend => []     # array of backends where this sub should be called
}

select_backends

select_backends($function, [$args])

select backends we want to run functions on

_get_result

_get_result($peers, $function, $args)

run function on several peers and collect result.

_get_result_lmd

_get_result_lmd($peers, $function, $arguments)

returns result for given function using lmd

_get_result_serial

_get_result_serial($peers, $function, $arguments)

returns result for given function

_get_result_parallel

_get_result_parallel($peers, $function, $arguments)

returns result for given function and args using the worker pool

remove_duplicates

remove_duplicates($data)

removes duplicate entries from a array of hashes

reset_failed_backends

reset_failed_backends([ $c ])

Reset failed backends cache. Retries are useless unless reseting this cache because failed backends won't be asked twice per request.

AUTOLOAD

AUTOLOAD()

redirects sub calls to our backends

DESTROY

DESTROY()

destroy this

sort_result

sort_result($data, $sortby)

sort a array of hashes by hash keys

sortby can be a scalar

$sortby = 'name'

sortby can be an array

$sortby = [ 'name', 'description' ]

sortby can be an hash

$sortby = { 'DESC' => [ 'name', 'description' ] }

_sort_nr

_sort_nr($data, $sortby)

sort a array of array by array nr

sortby must be an array

[<nr>, <direction>]

ex.:

[5, 'asc']
[5, 'asc', 13, 'desc']

_limit

_limit($data, $limit)

returns data limited by limit

_set_user_macros

_set_user_macros($args, $macros)

Sets the USER1-256 macros from a resource file. Shinken supports all kind of macros in resource file, so just replace everything from the resource file.

$args should be: { peer_key => peer key for the host filter => 0/1 # only add allowed macros file => location of resource file args => list of arguments }

_set_result_defaults

_set_result_defaults()

set defaults for some results

_set_result_group_stats

_set_result_group_stats()

set defaults for some results

fill_get_can_submit_commands_cache

fill_get_can_submit_commands_cache($c)

fills cached used by get_can_submit_commands

get_can_submit_commands

get_can_submit_commands

wrapper around get_can_submit_commands

fill_get_contactgroups_by_contact_cache

fill_get_contactgroups_by_contact_cache($c)

fills cached used by get_contactgroups_by_contact

rpc

rpc($backend, $function, $args)

returns remote call result

page_data

page_data(...)

wrapper for Thruk::Utils::page_data

fork_http_peer

fork_http_peer($peer, $httpsrc)

create http backend based on livestatus backend which has multiple sources including http ones

caching_query

caching_query($cache_file, $function, $args, $convert_in, $store_separate)

returns db query results and caches them by peer key until backend got restarted