📜 ⬆️ ⬇️

Zabbix + Communigate Pro: we monitor the message queue on the selected domains and hosts

Foreword


In our organization, a wonderful (my opinion, perhaps erroneous) product - Communigate Pro (CGP) is used as the mail server. In the old days, servers were monitored using standard Communigate + logwatch tools to monitor the operating system. Now Zabbix has been added to these tools. We monitor all major aspects of the operating system with the help of Zabbix agent, and statistics with CGP with SNMP requests. These methods cover almost all the necessary parameters of the system. But there are some characteristics that just won't be able to track. In particular, such characteristics as the number of messages in the queue in a specific domain and / or on a specific host are very important for us. In the CGP administrator interface, it is possible to monitor these queues, but I would like all information to be monitored in one place. So, how is this done with us.

Utility to view the status of the queue


CGP has a well-documented API + library for working with this API in Perl and Java. And among the wealth of functionality there is a function that allows you to check the number of messages in the queue of a Communigate module to a certain host or domain.

GETMESSAGEQUEUEINFO moduleName QUEUE queueName 


The function takes two arguments as input: the module name and the queue name.

')
In response, the function returns information about the queue, which includes:



For the friendly use of this function, I had to write a small utility . It is written in Perl. I wanted to on my favorite Python, but there is no official Python library for CGP, and my own is still being finalized. The utility will require a pearl barley module CLI.pm , which can be found in the CGP API documentation. The main features of the utility are presented in the help to it.

 check_queue [-h hostname] [-p port] -u username -w password [-m module] -q queue [-t | -s [-f]] check_queue -h|--help -h hostname - address of DNS name of the server (Default: localhost) -p port - port for connection (Default: 106) -u username - account on CGatePro with grant 'Can View Queued Messages' -w password - user password -q queue - queue name to check -m module - name of CGP module (Default: SMTP) -t - if use this option then program return just total number of messages in queue -s - if use this options then program return just total size of messages in bytes -f - this option is used just with -s option, if it's set then size will be more readable. --help - print this help --debug - show debug lines 


Examples of its use:

 #     torwald@torwald-station:~$ ./check_cgp_queue.pl -h myserver.domain.org -u monitor -w password -q another.domain.org Total: 41 Size: 65374728 Delay: 05-05-2014 06:04:28 State: waiting #     torwald@torwald-station:~$ ./check_cgp_queue.pl -h myserver.domain.org -u monitor -w password -q another.domain.org -t 41 


We connect monitoring


Preliminary preparation

I will describe the training for CentOS5 and CentOS6.

All preparation is reduced to the following:
  1. We place the utility in / usr / local / bin (you can “cut off” the extension) and give the zabbix agent user rights (zabbix by default) to run this utility.
  2. We place the CLI.pm module where it will be “visible” to the Perl interpreter, launched on behalf of zabbix. I have this / usr / local / lib / perl5.
  3. In the CGP admin interface, we create a user (for example, cgpmon) with “Can Monitor” -> “Can View Queued Messages” rights.
  4. We check connection from under the user of zabbix.


Setting up a monitoring agent

1. Add the following settings to the agent configuration file.

 # /etc/zabbix_agentd.conf #      UserParameter=cgp.queue.total[*],/usr/local/bin/check_cgp_queue -u cgpmon -w password -q $1 -t #    UserParameter=cgp.queue.size[*],/usr/local/bin/check_cgp_queue -u cgpmon -w password -q $1 -s 


More information about the syntax of working with this parameter and the "asterisk", in particular, can be found in the documentation .

In brief, this entry means that when a monitoring system is requested using the cgp.queue.total [other.domain.org] key, the monitoring system agent will execute the command:

 /usr/local/bin/check_cgp_queue -u cgpmon -w password -q other.domain.org -t 


Or, in other words, will receive the number of messages on the domain specified in square brackets.
2. Restart the agent.

Setting up a monitoring server

Suppose we are interested in the state of queues in three domains:


1. Create a separate template on the monitoring server (for example, Template CGP Queues).
2. Add there data items with the following keys:

 #     cgp.queue.total[foo.example.org] cgp.queue.total[bar.example.org] cgp.queue.total[tor.example.org] #   cgp.queue.size[foo.example.org] cgp.queue.size[bar.example.org] cgp.queue.size[tor.example.org] 


3. Roll the templates on the server.
4. Turn off unnecessary queues. For example, it makes no sense to monitor the SMTP queue for a domain located on the same server, since it is always empty.
5. Expose triggers.
6. Turn on observation.

Sources


Documentation for the Communigate Pro CLI and API
Pearl Barrier Interface to CGP
More on UserParameter in Zabbix
The source code for the check_cgp_queue utility

Source: https://habr.com/ru/post/221795/


All Articles