OP5 Monitor ["OP5 Monitor"]["OP5 Monitor > Other"]
["Technical Reference"]

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:

Install custom plugins on a Slim Poller

Custom Docker image

Creating a custom Docker image on top of the image provided for the OP5 Monitor Slim Poller is the recommended way to install custom plugins on the Slim Poller. It is a flexible approach which enables plugin dependencies to be installed as well.

To create a custom Docker image, you need to define a new Dockerfile. This new image must be based on the naemon-core image. After you define the base image in the Dockerfile, you can install the plugin and dependencies as required.

The example Dockerfile below installs plugin check_puppetdb.

Copy

Example Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
FROM op5com/slim-poller_naemon-core# Run as root while installingUSER rootARG PLUGIN_PATH=/opt/plugins/customWORKDIR /tmp# Make sure the custom plugins path existsRUN mkdir -p $PLUGIN_PATH# Install dependenciesRUN yum install -y ruby rubygems rubygem-json# install gitRUN yum install -y git# Checkout the sourcecode from gitRUN git clone https://github.com/xorpaul/check_puppetdb.gitRUN cp ./check_puppetdb/check_puppetdb.rb $PLUGIN_PATH#clean upRUN rm -rf ./check_puppetdb/# Change back to correct monitor userUSER $MON_UID

 

You can find more information on Dockerfiles at docs.docker.com.

Build image

After you define your new custom Docker image, build the image using the following command:

docker build -f <path/to/dockerfile>	

Depending on how you deploy the Slim Poller, you might need to upload or push the image to your environment, or you can upload it to hub.docker.com.

Change deployment files

After you make the new image available in your environment, change your deployment files to use this new image instead of the naemon-core image. For more information on Slim Poller deployment files, see Deployment examples in Scale up your monitoring environment.

Updates

After each new release of the Slim Poller, you must rebuild your custom image to ensure you have the newest changes. You can use the following commands to do this manually.

docker pull op5com/slim-poller_naemon-core
docker build . --no-cache			

Example custom plugin

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

Copy
Example Bash script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash# Create a function to print the storage pathstoragepath() {  grep ^storagepath /etc/op5-backup/main.conf |tail -1 |sed 's/^[^"]*"//g' | sed 's/"$//g'}# Put the storage path in an environmental variableSTORAGEPATH=`storagepath`# Test if the storagepath exists and is a directoryif [[ ! -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 1fi# If the script reaches this point then the test passed# Print an OK messageecho $STORAGEPATH exists# Exit with status OKexit 0

 

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



­