In this section we will create a very simple check plugin to demonstrate OP5 Monitor's plugin interface. We will use basic tools, such as writing it in the Bourne shell (the original Unix shell language). The resulting plugin may not be very useful, but going through this process will teach you the necessary steps for creating your own monitoring plugins.
This tutorial requires that you have shell access to the server running OP5 Monitor as well as some basic Unix shell knowledge. If you are coming from the Windows world, take heart: you can now install PowerShell starting with version 7 of Red Hat Enterprise Linux (RHEL) and CentOS, on which OP5 Monitor runs. Follow along as best you can, and it will be worth your while.
Creating the plugin
- Open a SSH session to the host running OP5 Monitor;
Move to the custom plugins directory, create the file "helloworld", and make it executable:
Open the plugin with your favorite text editor and add the following code to the empty file.
For Windows admins that are not familiar: the opening line is called a 'shebang' line because of the hash ('sharp') and exclamation point ('bang'). It tells the command shell which application will run this script. It serves the job of a suffix in DOS but allows argument values and other useful features:
- Save and exit your text editor;
The shell script is now a usable check plugin. You can test it by executing it in the terminal and verifying that it exits with the return code "1" (warning state).
For Windows admins: '$?' is a shell variable that returns the last exit code. You can use this inside scripts as well, so that you can test for success or other states without writing more scripts.
Using the plugin in OP5 Monitor
Configuring the plugin as a check command
Go to the configuration page and enter the "Commands" section;
Add a new command with the following parameters:
It should look like this in the configuration dialog:
- Click "Submit" and save the configuration.
Now you may use your check command with a service as described in Adding a service.