Thruk::Backend::Manager - Manager of backend connections
Manager of backend connections
create new manager
returns connection pool
returns hash of peers
returns list of peers
returns list of authoritive peers (used to fetch can_submit_commands / groups)
returns pools lmd_peer
calculate sections
disable_hidden_backends()
returns list of hidden backends
get_peers([$all])
returns all configured peers (except config-only)
get_peers_by_tags($tags)
returns all configured peers with given tags, ex: [ 'tag1', '!tag2' ]
get_local_peers()
returns all configured peers which use a local unix socket to connect
get_peer_by_key()
returns peer by key
get_peer_by_name()
returns peer by name
get_http_peers([$with_fallbacks])
returns all configured peers which have a http connection type
peer_key()
returns all peer keys
sections()
returns all sections
disable_backend(<key>)
disable backend by key
enable_backend(<key>)
ensable backend by key
disable_backends(<keys_hash>)
disabled backend by key hash
enable_backends(<keys>, [<exclusive>])
enables all backends. list is additive unless exclusive is used.
enable_default_backends()
enables all default backends
get_default_backends()
returns all default backends
get_scheduling_queue
returns the scheduling queue
get_performance_stats
wrapper around get_performance_stats
get_hosts
wrapper around get_hosts
get_services
wrapper around get_services
get_host_stats_by_servicequery
calculate host statistics from services query
get_all_child_hosts
returns list of all recursive child hosts
get_hosts
wrapper around get_hosts
get_contactgroups_by_contact
returns a list of contactgroups by contact
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
returns a list of servicegroups but get list from services in order to respect permissions
reconnect
runs reconnect on all peers
expand_command
expand a command line with host/service data
logcache_stats($c)
return logcache statistics
logcache_existing_caches($c)
return peer ids of existing log caches
get_logs(@args)
retrieve logfiles
renew_logcache($c, [$noforks])
update the logcache, returns 1 on success or undef otherwise
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($c)
update the logcache (internal sub)
close_logcache_connections($c)
close all logcache connections
lmd_stats($c)
return lmd statistics
_get_macros
returns a hash of 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($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
returns replaced string
_get_obfuscated_string
replace sensitive data with ***
_set_host_macros
set host macros
_set_service_macros
sets service macros
_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($function, [$args])
select backends we want to run functions on
_get_result($peers, $function, $args)
run function on several peers and collect result.
_get_result_lmd($peers, $function, $arguments)
returns result for given function using lmd
_get_result_serial($peers, $function, $arguments)
returns result for given function
_get_result_parallel($peers, $function, $arguments)
returns result for given function and args using the worker pool
remove_duplicates($data)
removes duplicate entries from a array of hashes
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()
redirects sub calls to our backends
DESTROY()
destroy this
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($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($data, $limit)
returns data limited by limit
_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 defaults for some results
_set_result_group_stats()
set defaults for some results
fill_get_can_submit_commands_cache($c)
fills cached used by get_can_submit_commands
get_can_submit_commands
wrapper around get_can_submit_commands
fill_get_contactgroups_by_contact_cache($c)
fills cached used by get_contactgroups_by_contact
rpc($backend, $function, $args)
returns remote call result
page_data(...)
wrapper for Thruk::Utils::page_data
fork_http_peer($peer, $httpsrc)
create http backend based on livestatus backend which has multiple sources including http ones
caching_query($cache_file, $function, $args, $convert_in, $store_separate)
returns db query results and caches them by peer key until backend got restarted