NAME

Monitoring::Config - Thruks Object Database

DESCRIPTION

Provides access to core objects like hosts, services etc...

METHODS

new

new({
    core_conf           => path to core config
    obj_file            => path to core config file
    obj_dir             => path to core config path
    obj_resource_file   => paths to resource.cfg file
    obj_readonly        => readonly pattern
    obj_exclude         => exclude pattern
    git_base_dir        => git history base folder
    localdir            => local path used for remote configs
    relative            => allow relative paths
})

return new objects database

init

init($config, [ $stats ])

initialize configs

discard_changes

discard_changes()

Forget all changes made so far and not yet saved to disk

commit

commit([$c])

Commit changes to disk. Returns 1 on success.

$c is only needed when syncing with remote sites.

get_errors

get_errors()

return all errors

print_errors([$fh])

Print all errors to stdout or supplied filehandle

get_files

get_files()

Get all files. Returns list of Monitoring::Config::File objects.

get_file_by_path

get_file_by_path($path)

Get file by path. Returns Monitoring::Config::File object or undef.

get_changed_files

get_changed_files()

Get all changed files. Returns list of Monitoring::Config::File objects.

get_objects

$list = get_objects()

Get all objects. Returns list of Monitoring::Config::Object objects.

get_objects_by_type

$list = get_objects_by_type($type, [ $filter ], [ $origin])

Returns list of Monitoring::Config::Object objects for a type.

filter is verified against the name if its a scalar value. Otherwise it has to be like

$filter = {
   attribute => value
};

origin is used for commands and can be 'check', 'eventhandler' or 'notification'

get_objects_by_name

get_objects_by_name($type, $name, [ $templates_only , [ $name2 ]])

Get objects by name. Returns list of Monitoring::Config::Object objects.

get_objects_by_path

get_objects_by_path($path)

Get all objects by path. Returns Monitoring::Config::Object objects or undef.

get_templates_by_type

get_templates_by_type($type)

Get templates by type. Returns list of Monitoring::Config::Object objects.

get_template_by_name

get_template_by_name($type, $name)

Get template object by name. Returns list of Monitoring::Config::Object objects.

get_object_by_location

get_object_by_location($path, $linenr)

Get single object by path and line number. Returns Monitoring::Config::Object objects or undef.

get_object_by_id

get_object_by_id($id)

Get object by id. Returns Monitoring::Config::Object object or undef.

get_services_for_host

get_services_for_host($hostobj)

Get services by host. Returns a hashref with ids of references:

{ host => {}, group => {} }

get_services_by_name

get_services_by_name($host_name, $service_description)

Returns list of services for given host and service names

get_hosts_for_service

get_hosts_for_service($svcobj)

Get hosts for service. Returns a list of hosts using this service.

update

update()

update objects config

check_files_changed

check_files_changed([ $reload ])

update objects config

update_object

update_object($obj, $newdata, [ $comments, [ $rebuild ]])

update objects config

delete_object

delete_object($obj, [ $rebuild ])

update objects config

move_object

move_object($obj, $newfile, [ $rebuild ])

move object to different file

file_add

file_add($file, [ $rebuild ])

add new file to config

file_delete

file_delete($file, [ $rebuild ])

remove a file from the config

file_undelete

file_undelete($file, [ $rebuild ])

undelete a file marked for removal

rebuild_index

rebuild_index()

rebuild object index

rename_dependencies

rename_dependencies($obj, $oldname, $newname)

rename dependencies

clone_refs

clone_refs($orig, $obj, $cloned_name, $newname, [$clone_refs],  [$test_mode])

clone all incoming references of object. In test mode nothing will be changed and just the list of clonables will be returned. If clone_refs is set, only those ids will be cloned.

gather_references

gather_references($obj)

return incoming and outgoing references

get_references

get_references($obj, [ $name ])

return all references for this object

get_default_keys

   get_default_keys($type, [ $options ])

$options = {
    no_alias => 0,   # skip alias definitions and only return real config attributes
    sort     => 0,   # sort by default attribute order
}

return the default config keys for a type of object

get_files_for_folder

get_files_for_folder($dir, [ $regex ])

return all files below this folder (matching the regex)

get_files_root

get_files_root()

return root folder for config files

is_host_in_hostgroup

is_host_in_hostgroup()

return list of hostgroups if this host is member of the group

is_remote

is_remote()

return true if this backend has a remote connection

remote_file_sync

remote_file_sync()

syncronize files from remote

remote_config_check

remote_config_check()

do config check on remote site

remote_config_reload

remote_config_reload()

do a config reload on remote site

remote_file_save

remote_file_save()

save files to remote site

remote_get_plugins

remote_get_plugins()

return plugins from remote site

remote_get_pluginhelp

remote_get_pluginhelp()

return plugin help from remote site

remote_get_pluginpreview

remote_get_pluginpreview()

return plugin preview from remote site

read_rc_file

read_rc_file()

read naglint rc file and create sort function

set_save_config

updates file save config

get_plugins

return list of plugins

get_plugin_help

return plugin help

get_plugin_preview

return plugin preview