Nagios – Monitoring OTRS Queues

If in our environment we have OTRS as a management system and Nagios or Centreon as a monitoring system, we will be able to integrate them and do real wonders, In this first document we will see something very simple: How to monitor the queues we have in OTRS from Nagios or Centreon. And we will continue in the future with other types of integrations!

 

What we will need for this is very simple, a small script in PHP that we will download from Exchange Nagios in our plugins folder (/usr/lib/nagios/plugins) of our machine with Nagios or Centreon and make it executable. Obviously, we have to have already created the queues in OTRS, and both the OTRS and Nagios/Centreon must be functional!

 

On our OTRS server, edit the MySQL configuration file (/etc/mysql/my.cnf) and we will verify that we have the following parameters in this section:

[SourceCode][Mysqld]
max_allowed_packet = 20M
query_cache_size = 32M
innodb_log_file_size = 256M[/SourceCode]

 

We must modify the permissions in MySQL, for this we give you permissions, Be careful, I do it with the 'root' user, that we might as well have a dedicated user. Something like:

[SourceCode]mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
select host from mysql.user where user = 'root';
GRANT SELECT ON otrs.* TO 'root'@'192.168.1.102';
FLUSH PRIVILEGES;
Quit[/SourceCode]

 

And after restarting the services we can start making queries with the root user from the Centreon or Nagios machine!

[SourceCode]/etc/init.mysql restart[/SourceCode]

 

And back to our Nagios, If we want to try it, We open a shell and go to the plugin directory, there we will have downloaded the 'check_otrs.php', we tried to run it!

With the following command we will be able to visualize the status of the tickets in a queue, Filtering by State and Queue, in addition to notifying us of a Warning or a Critical depending on the number of Tickets in a Queue:

[SourceCode]./check_otrs.php -H DIRECCION_IP_OTRS -u root -p CONTRASEÑA_ROOT_MYSQL -d BASE_DATOS -t STATUS -q COLA -w WARNING -c CRITICAL[/SourceCode]

 

 

Therefore, if we go to our Centreon, we will first have to register the Command we are going to use, Let's go “Configuration” > “Commands” > “Add” And we left it kind of like that:

  • Command Name: We usually call it as the script, check_otrs.php.
  • Command Type: Select 'Check'.
  • Command Line: We indicate what you should execute when this Command is called, We are based on the previous example I gave, which we will complete with arguments:

[SourceCode]$USER1$/check_otrs.php -H $HOSTADDRESS$ -u $ARG 1$ -p $ARG 2$ -d $ARG 3$ -t $ARG 4$ -q $ARG 5$ -w $ARG 6$ -c $ARG 7$[/SourceCode]

  • Argument Descriptions: We must complete the arguments, so that when we use this Command from a Service we relate what we must complete! The first argument will be the MySQL user, the second will be your password, the third will be the OTRS database, the fourth will be the Type or Status of the Ticket, and the fifth argument will be the OTRS Queue.

We record with “Save”,

 

We can now create the Queues we want to monitor, for this we will create a Service by Queue, since “Configuration” > “Services” > “Add…” (or we better clone an existing one) and add to the OTRS Host every check. We give a name to the service that we will associate with the queue we monitor, We usually associate the generic service template with you, we instruct you to use the Command we just created in the previous step (check_otrs.php), and we complete what he asks us, that will be passed on as arguments when executing this check.

We record with “Save”, we export the configuration and reload Nagios/Centreon.

 

 

And nothing! If we return to the view of “Monitoring” we will see all the OTRS Queues that we already have monitored! Very easy, No?? I hope you find it useful, Thank you all for sharing!!

 

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!