OP5 Monitor

Custom plugins

Overview

OP5 Monitor has an open architecture. You can extend the standard functionality by adding custom plugins from the Naemon community or developed by your own organisation.

The sections below explain how to create and install custom plugins. ITRS does not provide any support for custom plugins.

Macros

Custom plugins in OP5 Monitor rely on the use of Naemon macros. For more information, see Macros in Manage commands.

Create a custom plugin

The following procedure explains how to write a simple shell script to run as a plugin. You can use it as a basis for creating more complex custom plugins of your own.

To create a custom plugin:

  1. Log on to the OP5 Monitor server, using SSH.
  2. Add your custom plugin to directory /opt/plugins/custom and make it executable. In the following example, we are adding a new file called check_local_helloworld:
  3. cd /opt/plugins/custom 
    touch check_local_helloworld
    chmod 755 check_local_helloworld
  4. You can now edit your plugin file to add some checking logic. In the following example, we add code to print a value:
  5. #!/bin/sh 
    echo 'WARNING: Hello, world!'
    exit 1
    
  6. You can now execute the file to test it:
  7. $ ./check_local_helloworld
    WARNING: Hello, world! 
    $ echo $?
    1									

Success: You have created your custom plugin. The next step is to install it in OP5 Monitor.

Install custom plugins on a standard OP5 Monitor server

You install a custom plugin by creating a new command for it and adding the command to a service configuration.

To install a custom plugin:

  1. In the OP5 Monitor interface, click Manage > Configure > Commands.
  2. Enter the details of the new command. For the plugin created in Create a custom plugin, the parameters are as follows:
  3. command_name: check_local_helloworld 
    command_line: $USER1$/custom/check_local_helloworld

    For guidance on creating commands, see Create and update commands in Manage commands.

  4. Add the command to a service configuration. For guidance, see Configure a service in Manage hosts and services. You can now see it in the service list views:

Example custom plugin

The following example creates a plugin to print the OP5 Monitor storage path:

Copy
Example Bash script
#!/bin/bash
# Create a function to print the storage path
storagepath() {
  grep ^storagepath /etc/op5-backup/main.conf |tail -1 |sed 's/^[^"]*"//g' | sed 's/"$//g'
}

# Put the storage path in an environmental variable
STORAGEPATH=`storagepath`
# Test if the storagepath exists and is a directory
if [[ ! -d "$STORAGEPATH" ]]; then
  # Print a warning message for the web gui
  echo "op5-backup is not properly configured for local operation"
  # Exit with status Warning (exit code 1)
  exit 1
fi

# If the script reaches this point then the test passed
# Print an OK message
echo $STORAGEPATH exists
# Exit with status OK
exit 0

 

For more information on custom plugins, see Naemon - Plugin API documentation.