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

Foreword


In our organization, a wonderful (my opinion, maybe erroneous) product is used as the mail server - Communigate Pro (CGP). In the old days, server operation was monitored using regular Communigate + logwatch tools for monitoring the operating system. Now Zabbix has been added to these tools.. We monitor all the main aspects of the operating system using the Zabbix agent, and statistics from CGP using SNMP requests. These methods cover almost all the necessary system parameters. But there are some characteristics that simply cannot be tracked. In particular, such characteristics as the number of messages in the queue to a specific domain and / or to a specific host are very important to us. The CGP admin interface has the ability to monitor these queues, but I would like all the information to be monitored in one place. So, how is this done with us.

Utility for viewing queue status


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

GETMESSAGEQUEUEINFO moduleName QUEUE queueName


The function receives two arguments as an input - the name of the module and the name of the queue.
  • The name of the module. There are several modules in CGP, but we are specifically interested in the SMTP module.
  • The name of the queue. Matches the domain or host name.


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

  • The total number of messages in this queue
  • Total message size
  • the time until which the resending of messages is delayed;
  • brief information about the last error in this queue (if any);
  • queue state (waiting, delivery, etc.).


For a friendly use of this function, I had to write a small utility . It is written in Perl. I wanted it on my favorite Python, but there is no official Python library for CGP, and my own is still being finalized. For the utility will need Perl module CLI.pm , which can be found in the documentation for the API CGP . The main features of the utility are presented in a 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 preparations for CentOS5 and CentOS6.

All preparation comes down to the following:
  1. We place the utility in / usr / local / bin (you can "cut off" the extension) and give the user the rights to the zabbix agent (by default - zabbix) 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, create a user (for example, cgpmon) with the rights “Can Monitor” -> “Can View Queued Messages”.
  4. We check the connection from under the zabbix user.


Configure 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 short, this entry means that when a monitoring system is requested using the key cgp.queue.total [other.domain.org], 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, it will receive the number of messages per domain indicated in square brackets.
2. Restart the agent.

Monitoring Server Setup

Suppose we are interested in the status of queues for three domains:
  • foo.example.org
  • bar.example.org
  • tor.example.org


1. Create a separate template on the monitoring server (for example, Template CGP Queues).
2. Add data elements 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. We roll templates on the server.
4. Disable unnecessary queues. For example, it makes no sense to monitor the SMTP queue on a domain located on the same server, because it is always empty.
5. We expose triggers.
6. Turn on observation.

Sources


Communigate Pro CLI and API
Documentation Pearl Bar Interface for CGP
More about UserParameter in Zabbix
Source Code for check_cgp_queue Utility

Also popular now: