Thruk::Utils::CLI - Utilities Collection for CLI Tool
Utilities Collection for CLI scripting with Thruk. Allows you to access internal structures and change config information.
new([ $options ])
$options = {
verbose => 0-4, # be more verbose
}
create CLI tool object
get_c()
return Thruk::Context context object
The Backend Connection Pool can be uses for own querys against all connected backends in Thruk.
get_db()
Return connection pool as a Thruk::Backend::Manager object.
These methods will only be available if you have the config tool plugin enabled and if you set core config items to access the core objects config.
get_object_db()
Return config database as a Monitoring::Config object.
store_objects()
Store changed objects. Changes will be stashed into Thruks internal object cache and can then be saved, reviewed or discarded.
request_url($c, $url, [$cookies], [$method], [$postdata], [$headers], [$insecure])
returns requested url as string. In list context returns ($code, $result)
load_module($module)
load given module and returns true on success
$self->from_local($c, $options)
main entry point for cli commands from the terminal
from_fcgi($c, $string)
main entry point for cli commands over http(s).
get_submodule_help($module, [$data])
returns help extracted from pod for given module
read_stdin_password()
read password from stdin
pid_exists($pid, [$cmd pattern])
check if pid exists and cmd matches the pattern, returns true if pid is valid
check_lock($file, [$key], [$pid])
check lock file, returns:
- (undef, undef) if lock was set successfully
- ($pid, $starttime) if a valid lock exists already
check_lock_unlock($file, [$key])
removes lock from file.
there are some cli scripting examples in the examples subfolder of the source package.