Merge "Updated monitoring_with_your_custom_plugin.rst"
This commit is contained in:
commit
c3c5ca4e53
@ -6,39 +6,19 @@ Monitoring with your custom plugin
|
|||||||
|
|
||||||
Surveil is compatible with Nagios plugins. It is trivial to write a custom plugin to monitor your applcation. In this guide, we will create a new plugin and configure a new Host that uses it in Surveil.
|
Surveil is compatible with Nagios plugins. It is trivial to write a custom plugin to monitor your applcation. In this guide, we will create a new plugin and configure a new Host that uses it in Surveil.
|
||||||
|
|
||||||
1. Test the check_example plugin
|
0. Install the plugin
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
The first step to create a plugin is to successfully test the check_example plugin. This plugin
|
Surveil support Nagios plugins. For more information about Nagios plugins, please refer to the `Nagios plugin API documentation <http://nagios.sourceforge.net/docs/3_0/pluginapi.html>`_ for more information.
|
||||||
will serve as a base file to create your own plugin.
|
|
||||||
|
|
||||||
Create virtual environment and install requirements: ::
|
There are many plugins available on the web. For example, the `nagios-plugins <https://github.com/nagios-plugins/nagios-plugins>`_ project contains many plugins written in C and the `monitoring-tools <https://github.com/savoirfairelinux/monitoring-tools>`_ project contains many plugins written in Python.
|
||||||
|
|
||||||
virtualenv env
|
Surveil loads plugins from ``/usr/lib/monitoring/plugins/``. In this example, we will be installing a simple fake plugin written in Bash: ::
|
||||||
source env/bin/activate
|
|
||||||
cd tools/docker/alignak_container/plugins/check-example
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
Install the check_example plugin: ::
|
echo -e '#!/bin/bash\necho "DISK $1 OK - free space: / 3326 MB (56%); | /=2643MB;5948;5958;0;5968"' | sudo tee /usr/lib/monitoring/plugins/custom/check_example
|
||||||
|
chmod +x /usr/lib/monitoring/plugins/custom/check_example
|
||||||
|
|
||||||
python setup.py develop
|
1. Create a host using this plugin
|
||||||
|
|
||||||
Run the plugin: ::
|
|
||||||
|
|
||||||
check_example
|
|
||||||
|
|
||||||
The output should look like this: ::
|
|
||||||
|
|
||||||
DISK OK - free space: / 3326 MB (56%); | /=2643MB;5948;5958;0;5968
|
|
||||||
|
|
||||||
2. Modify the plugin
|
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
The next step is to modify the plugin to meet your needs. In order to do this,
|
|
||||||
please refer to the `Nagios plugin API documentation <http://nagios.sourceforge.net/docs/3_0/pluginapi.html>`_.
|
|
||||||
|
|
||||||
|
|
||||||
3. Create a host using this plugin
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Now that you are done developing your plugin, it is time to use it in Surveil.
|
Now that you are done developing your plugin, it is time to use it in Surveil.
|
||||||
@ -48,14 +28,14 @@ Creating a command
|
|||||||
|
|
||||||
Before you can use your plugin in a host/service configuration, you need to create an Alignak command: ::
|
Before you can use your plugin in a host/service configuration, you need to create an Alignak command: ::
|
||||||
|
|
||||||
surveil config-command-create --command_name check_example --command_line "check_example"
|
surveil config-command-create --command_name check_example --command_line '$CUSTOMPLUGINSDIR$/check_example $HOSTADDRESS$'
|
||||||
|
|
||||||
Creating a host
|
Creating a host
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Create a host with the following command: ::
|
Create a host with the following command: ::
|
||||||
|
|
||||||
surveil config-host-create --host_name check_example_host --address savoirfairelinux.com
|
surveil config-host-create --host_name check_example_host --address savoirfairelinux.com --use generic-host
|
||||||
|
|
||||||
Creating a Service
|
Creating a Service
|
||||||
------------------
|
------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user