Print the Number of Messages in the Queue

Beginning with V8.12 sendmail, the -bP command-line switch can be used to print the number of messages in the queue or queues. This command-line switch relies on shared memory to gather its information, so it works only if sendmail is compiled with shared memory support. The SM_CONF_SHM compile-time macro determines whether shared memory support was included (see SM_CONF_SHM on page 142). If shared memory support is not included, use of this command-line switch will cause the following error to be printed:

Data unavailable without shared memory support

If shared memory support is compiled in, but there is a problem with it (possibly at the system level), the following error will print:

Data unavailable: shared memory not updated

Note that you will also get this error if the queue has not been processed at least once to initialize the data.

In addition to enabling shared memory using the SM_CONF_SHM m4 Build macro, you must also define a key to be used with that shared memory with the SharedMemoryKey option. To set this option in your configuration file, you could add a line such as the following to your mc configuration file:

define(`confSHARED_MEMORY_KEY',`13521')

If all goes well, the -bP command-line switch will produce output such as this:

/var/spool/mqueues/q.1/df: entries=34
/var/spool/mqueues/q.2/df: entries=51
               Total requests: 85

Here, 85 is the number of envelopes currently awaiting delivery in sendmail’s queues. But note that some shared ...

Get sendmail, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.