Welcome to docs.opsview.com
Opsview Plugins
It is possible to extend the functionality of Opsview via plugins. There are various hooks in the code which allows calling of external functions. There are two forms of plugins: scripts and perl classes.
Scripts
Where the current functionality is provided via scripts, external scripts can be called to run other tasks. For install, at the process_configs stage, after the Nagios configuration has been loaded, any other scripts in /usr/local/nagios/opsview-plugins/process_configs/* will be executed.
These are the current hooks:
- nagconfgen
- process_configs - run at the point of Nagios reloading
- postinstall - run when a postinstall occurs, which could be via a package install or a send2slaves
- specific Catalyst controllers
Some hooks could run on a slave system. The perl/ and lib/ directories will be available, but the database objects will not.
To write these scripts, drop them into /usr/local/nagios/opsview-plugins/{hook}. They must be executable by the nagios user.
The order of running is not guaranteed.
Perl classes
There is only one hook at the moment, at nagconfgen time.
This works by having a perl module named Opsview::Plugin::{name}. This module must reside in /usr/local/nagios/lib/Opsview/Plugin/.
For the nagconfgen hook, there needs to be a method defined called create_configuration_end. This will be passed a hash ref with the following keys:
- monitoringserver - is the current monitoringserver defined
- configuration_file_path - full path to the configuration for the current monitoringserver
The order of running these methods is not guaranteed.
Hooks
nagconfgen: create_configuration
Use to create configuration for your separate application. Write configuration into configuration_file_path - anything with *.cfg will be automatically picked up for transfer.
Run on:
- master, once for each monitoringserver
Method:
- Put package into Opsview::Plugin::{name}
- Have a class method called create_configuration_end. The 1st parameter will be a $opts hash with:
- monitoringserver ⇒ $monitoringserver object
- configuration_file_path ⇒ $config_file_path to write to. Suffix with plugins/{name}
- host_to_node ⇒ $hash, where the key is the host id and the value is the node associated. This will be undefined for the master
Catalyst tabs: Host
Use to create a new tab in the host edit pages
Method:
- In package Opsview::Plugin::{name}, create a method called “display_host_tab” which returns the name of the tab
- Drop the tab into /usr/local/opsview-web/root/admin/host/tab-{tabname}
Cronjobs
Used to run cronjobs
Method:
- In package Opsview::Plugin::{name}, create a method called “run_cronjobs_daily” or “run_cronjobs_4hourly”. These will get invoked accordingly
Note: $self is not the Opsview class, just a dummy class, so don't expect any useful parameters here.
If you want to rotate logs use this instead….
Logrotate
Used to rotate logfiles
Method:
- Drop the logrotate file into /usr/local/nagios/opsview-plugins/logrotate/{name}. This will get invoked on a nightly basis on all opsview servers
install_slave: install_slave
Used to create do first run installs.
Run on:
- slave
Method:
- Executable added into installer/postinstall-plugin
- Will get called at end of postinstall, $1=slave if slave run
process_configs: process_configuration
Used to promote configurations. Note that there is no plugin to validation yet.
Run on:
- monitoring server (master or slave) at promote stage
Method:
- Executable added into bin/process_configs-plugin
- Will get called at end of process_configs when promotion requested
Trace: » opsviewplugins