Context

This article is about the creation of a Centreon plugin. This plugin will be able to check the health of a web service. A SOAP check is already available natively provided by Centreon but this script doesn’t support any authentication such as client certificates or basic authentication.

Centreon-Server-soap check CelsiusToFahrenheit

Features

  • Monitor the service answer time
  • Supports web service answer validity by request
  • Monitor the web service availability
  • Supports server-side certificates
  • Supports client-side authentication certificates
  • Supports basic authentication using a user and password
  • Supports thresholds timing for warning and critical answer time

Prerequisites CentOS 6.X (Centreon ISO)

Some packages are needed for the futur check_soap plugin:

yum install https://centos6.iuscommunity.org/ius-release.rpm
yum install python35u python35u-pip python35u-setuptools
python3.5 -m pip install requests

This plugin is using Python3 for some SSL certificates support.

Check_soap plugin

You can find the check_soap plugin here, on github.

This file needs to be placed on your Centreon server in this folder:

/usr/lib/nagios/plugins/

After creating the check_soap file, don’t forget to set it as an executable file:

chmod +x /usr/lib/nagios/plugins/check_soap

You can check your script by launching it:

cd /usr/lib/nagios/plugins/
./check_soap -h

The script should echo something like this:

usage: check_soap.py [-h] --url URL --data DATA [--success SUCCESS]
[--srv-cert SRV_CERT] [--client-cert CLIENT_CERT]
[--client-cert-key CLIENT_CERT_KEY]
[--basic-auth-user BASIC_AUTH_USER]
[--basic-auth-password BASIC_AUTH_PASSWORD] --warning
WARNING --critical CRITICAL

[~] check_soap Centreon plugin

optional arguments:
-h, --help show this help message and exit
--url URL url of the soap service
--data DATA xml data to post to the soap service
--success SUCCESS string to match in the service answer for a valide
query
--srv-cert SRV_CERT path to a CA_BUNDLE file or directory with
certificates of trusted CAs
--client-cert CLIENT_CERT
local cert for client side certificate
--client-cert-key CLIENT_CERT_KEY
specify a local cert key for client side certificate
--basic-auth-user BASIC_AUTH_USER
specify a basic authentication user
--basic-auth-password BASIC_AUTH_PASSWORD
specify a basic authentication password
--warning WARNING exec time in [ms] for warning threshold
--critical CRITICAL exec time in [ms] for critical threshold

 

Centreon configuration

You’re now ready to create a new Centreon command using the check_soap python script. To pass some variable to the python script such as the web service url or simply the data to post you can use Centreon’s macro because they may be optionals (on the oposite side, Centreon’s arguments are all required).

command

Here is the command to type in the « Command line » field:

$USER1$/check_soap --basic-auth-user='$_SERVICEBASICUSER$' --basic-auth-password='$_SERVICEBASICPASSWORD$' --url '$_SERVICEURL$' --data '$_SERVICEDATA$' --success '$_SERVICESUCCESS$' --srv-cert '$_SERVICEPATHCERTSVR$' --client-cert '$_SERVICEPATHCERTCLIENT$' --client-cert-key '$_SERVICEPATHKEY$' --warning '$_SERVICEWARNING$' --critical '$_SERVICECRITICAL$'

When the new command is ready, feel free to create some new Centreon’s services.
The check command field should now be using the new created command « check_soap ». After selecting the right command, all the macros may appear under the command name. Fill the macros with the correct value for testing your web service.

Save the service, update the poller and you’re now ready to monitor some web services !

Result

The web service is now monitored correctly, displaying some informations about latency and answer validity:
service

0 réponses

Laisser un commentaire

Participez-vous à la discussion?
N'hésitez pas à contribuer!

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.