cacti logoThis is the first part of a post about setting up and patching the threshold plugin so it can trigger passive checks into Nagios.

The patch is in the download section here.

First of all, install Cacti. As for now the latest version is 0.8.6j.
Then install the Plugin Architecture for Cacti (some docs here). OK, the website is a crap and not really working either with Firefox or Safari… You can use the menu on the right to reach the downloads.

You just have to untar the file and copy recursively all files in it (according to the same version as Cacti) into Cacti, overwriting existing files.

You can then apply my Ldap patch.
You can also change the config file and define you database name and user. Don’t forget to set the « URL path to cacti » which is introduced by the plugins arch. See config file later in the post.

Then download the Thold (Threshold) plugin and untar it in your « cacti/plugins » directory. Don’t use the version 0.3.5.1 which is online as it apply to a future revision of Cacti and Plugin Architecture. You have to download the version 0.3.4 here.
Then apply the patch.

You can also add more plugins, like Tools Settings , Host Info or Links. If you do so, don’t forget to enable it for each users in the user management page of Cacti.

Then, enable plugins in the config file. Edit file in cacti/include/config.php :

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "user";
$database_password = "pass";
$database_port = "3306";

$plugins = array();
$plugins[] = 'thold';
$plugins[] = 'update';
$plugins[] = 'hostinfo';
$plugins[] = 'settings';
$plugins[] = 'tools';
$plugins[] = 'dataquery';
$plugins[] = 'links';
$plugins[] = 'weathermap';

/* Do not edit this line */
$config = array();

/*
This is full URL Path to the Cacti installation
For example, if your cacti was accessible by http://server/cacti/ you would user '/cacti/'
as the url path.  For just http://server/ use '/'
*/

$config['url_path'] = '/cacti/';

Of course, you already have a working version of Nagios :)

Once applied, the Nagios patch will give you 2 more things :
- a new config option in the Settings -> Alerting/Thold to enable Nagios or not. Just enable it or not and add the script (shell, perl, python) which will be executed.
Cacti Setup Thold

For example, my script is like :

# cat /opt/monitor/scripts/cacti-to-nagios.sh
#!/bin/sh
# this script copy the data in argument to the Nagios external command file

NAGIOS_FILE="/opt/monitor/nagios/var/rw/nagios.cmd"

echo $1 >> ${NAGIOS_FILE}
exit 0

- a new parameter for each threshold you define
Cacti Graph Thold
Here you have to give the name of the Host defined in Nagios, and the name of the Service (with Passive check enabled) in Nagios.
For example, here is the part of my Nagios config :

define service{
use                             generic-service         ; Name of service template to use
host_name                       antlia
service_description             ANTLIA_INODES
is_volatile                     0
check_period                    24x7
max_check_attempts              1
normal_check_interval           5
retry_check_interval            1
contact_groups                  admins
notification_options            w,u,c,r
notification_interval           960
notification_period             24x7
active_checks_enabled           0
check_command                   check_dummy
}

Be carefull of access rights, execution rights and most of all, PHP Safe_Mode or exec_dir.

And there you go !
Maybe next release will allow to change the output line, so it is not bound to Nagios and can be run against any monitoring/alerting software.
Maybe I will also add something so Cacti can send SMS directly : we are using opensource smsd with a SMS modem on a serial port. For now it is Nagios wich is using it. The only gain is that Nagios can do some sort of escalation and schedule, so we only get the SMS during the non working hours. We’ll see :)