Graphing your systems mail queue using cacti

I recently noticed that the mail queue on a busy mail server i maintain was becoming disturbingly long at times.

Graphing a mail queue can be done with a little script and some cacti mojo.

Firstly, create a script that outputs the length of the queue which will be understood by cacti. The output needs to look something like

mailq:17
Ive chosen to write a script in python called check_mailq which you can find here.

Within cacti, go to the Console and add a 'Data Input Method' with the following attributes.

Name: Get mailq
Input Type: Script/Command
Input String: [path to your mailq script]
Ive used the following path for my Input String
/usr/local/cacti/bin/check_mailq
Within the 'Data Input Method' the 'Input Fields' stays empty though you need to create an 'Output Field' with the following attributes.
Field [Output]: mailq
Friendly Name: mailq
Update RRD File: [checked]
Save the 'Data Input Method' and then create a 'Data Template' using the following attributes
Data Templates
Name: mailq

Data Source
Name: |host_description| - mailq
Data Input Method: mailq
Data Source Item: mailq
Data Source Type: GAUGE
Output Field: mailq - mailq
Save the 'Data Template' and create a 'Data Source'.
Select Data Template: mailq
Host: [select your host]
Save the 'Data Source' and create a graph with 'Graph Management'
Selected Graph Template: None
Host: [select your host]
Title: [insert your hostname] - mailq
Click create then click add within the 'Graph Items' section
Data Source: [your hostname] - mailq (mailq)
Color: 00FF00
Graph Item Type: AREA
Text Format: queued emails
Click create, wait 10 minutes and a graph of your mail queue should appear within the Graphs section of cacti.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
ten - eight =
Solve this math question and enter the solution with digits. E.g. for "two plus four = ?" enter "6".