

Background

In my previous employer's environment we used Barracuda Spam Firewalls to 
handle in and outbound mail delivery. Wanting to keep an eye on the in and
outbound queues to make sure we are not seeing any delays with delivery I went
looking for ways to monitor the queues and alert when they are above certain
thresholds. Barracuda exposes the queue lengths in a number of ways (CGI/API, 
web interface and SNMP) and since we wanted this automated and we already use
Nagios I chose to use SNMP. I tried some of the other SNMP plugins to try to 
use those, but after a bit of struggling without success I decided to write 
my own in PHP (mainly because that is what is easiest for me). 

I no longer work there and no longer hae access to Barracudas, but since there
are at least some people still using the plugin I am still updating it as
needed.  I added a changelog below to help track these changes

Version		Date		Description of changes
-------		-------	---------------------------------
3.1		20-Aug-10	Added error checking to snmp so that an error
				will be returned on failure instead of OK with
				no output
3.0		10-Aug-10	Updated to reflect changes in cuda 
				firmware V4.  Added ability to set
				fw version for unit and change from
				bound to deferred queue in addition
				to the average email latency check
2.0		16-Mar-10	Updated to work with PHP5, the old version
				didn't seem to want to work and I had to update
				the first line (shebang) because it wouldn't
				work correctly despite the lack of any visible
				issues
1.0		19-Oct-07	Initial version released


Usage

Place the check_cuda file in the nagios libexec folder along with all your other check plugins.  Don't forget to
set permissions and ownership as appropriate for your installation. 
Version 3 was tested under PHP5 and should work with either 4 or 5 by simply using check_cuda.
Be sure to edit the check_cuda script and set the value of $cuda_firmware (line 10) to either 3 or 4 depending on the
firmware version of the Barracdua Spam and Virus firewalls you will be using the plugin to check.



Usage: check_cuda <host-ip> <community-string> <queue> <warning-threshold> <critical-threshold>

Queue can be either in, out or bounce for firmware version 3 firewalls; for version 4 firewalls the values are
in, out, deferred or latency

Warning and Critical values should be positive integers

Prerequisites

This plugin requires php and php_snmp support
Nagios Configuration
Commands

Define commands as shown below:

define command {
command_name Check Barracuda Inbound Mail Queue
command_line $USER1$/check_cuda $HOSTADDRESS$ public in 500 1000
}

define command {
command_name Check Barracuda Outbound Mail Queue
command_line $USER1$/check_cuda $HOSTADDRESS$ public out 500 1000
}

Obviously you will need to change the SNMP community string from public to match your community string. If you wish you could also add a check command to track the bounce queue. You may also want to use different warning and critical threshold than I did (500 and 1000 respectively). These numbers may not be right for your situation.
Contact Groups

Add a service group like the one below (customizing for your site of course):

# contactgroups Cuda Admins
define contactgroup {
contactgroup_name Cuda_Admins
alias Cuda_Admins
members joe,sally,fred
}
Service Templates

define service {
name Check Barracuda Mail Queue Template
use generic-service
contact_groups Cuda_Admins
register 0
}
Services

Add the service as needed to your hosts, sample shown below:

define service {
service_description Check Barracuda Inbound Mail Queue
use Check Barracuda Mail Queue Template
host_name yourcuda
check_command Check Barracuda Inbound Mail Queue
}

define service {
service_description Check Barracuda Outbound Mail Queue
use Check Barracuda Mail Queue Template
host_name yourcuda
check_command Check Barracuda Outbound Mail Queue
}
