You are hereBlogs / sean's blog / Setting up cacti

Setting up cacti


By sean - Posted on 18 December 2009

Introduction

Cacti is a great tool for graphing system/network activity, especially for Cisco devices.

The following are a few tips on getting a Cacti server (on Ubuntu 8.10 / Cacti 0.8.7b in this example) up and running quickly.

Installation

Install cacti and relevant tools:

apt-get install snmp cacti curl

Browser to http://HOST/cacti, login as admin/admin and change the password

Apply patch for autocomplete problems, see http://forums.cacti.net/about24765-0-asc-15.html

  check connectivity: curl -L http://forums.cacti.net/download.php?id=14681
  Save current file: ci -l host.php   (or copy host.php host.php.$$)
  Apply patch: curl -L http://forums.cacti.net/download.php?id=14681|patch -p1 -N

Settings

For Cisco switch devices, use the settings: generic SNMP-enabled host, down detection: ping+snmp.
Then a list of interfaces to graphed are presented automatically.

Change the default snmp community: Console > Settings > SNMP Community, and perhaps set the default SNMP version.

For Cisco, add the interface/alias description to graphs, go to Console > graph template > Interface - Traffic (bits/sec, 95th Percentile).
Change the title from |host_description| - Traffic
  to: |host_description| (|query_ifDescr|) - Traffic -|query_ifName|-|query_ifIP|   
  or: |host_description| |query_ifName| - Traffic (|query_ifDescr|) |query_ifAlias|

 

If monitoring systems with pure ICMP ping, there is a problem with icmp packets only being able to be generated by the root user. One solution on trusted cacti systems where only admins have login access:

chmod +sx /usr/share/cacti/site/lib/ping.php
run poller.php as root and not www-data in cron.

 

Reading

Templates & Plugins

http://www.debianhelp.co.uk/cactitemplates.htm
http://docs.cacti.net/templates

http://cactiusers.org/

Books /doc

The official doc
http://www.cacti.net/documentation.php

Cacti 0.8 Network Monitoring
https://www.packtpub.com/cacti-0-8-network-monitoring/book

Its an introductory user manual that is useful, if a bit thin. While covering the typical usage it does not go into detail for typical scenatiors, recommand any templates

Testing

 If a device is not being graphed, browse it with snmp to see what items are available:

snmpwalk -c MYCOMMUNITY -v1 10.0.0.1 system
    snmpwalk -c MYCOMMUNITY -v1 10.0.0.1       (for the complete tree)

Useful commands

tail /var/log/cacti/cacti.log
ls -altr /var/log/
vi /etc/cacti/debian.php  (check passwords)
mv /etc/cron.d/cacti /etc/cron.d/.cacti    (disable cacti polling)
vi /etc/cron.d/cacti      (change the default polling interval from 5min)

Backups

On Ubuntu the graphs are kept in /var/lib/cacti, sources/scripts in /usr/share/cacti, some config in /etc/cacti and data in mysql.

Mysql could be backedup with something like:
database="cacati";
mysqldump $database --quick --single-transaction --routines --triggers --compress=TRUE --comments > /var/backups/mysql.dumps/$database.sql.dump

Then use a tool like backuppc to backup the relevant directories.

Command line Interface - CLI

While cacti is a GUI tool there is some cli support for adding entries.

 cd /usr/share/cacti/cli/
 add_device.php --list-host-templates     (we note that the template nr. 10 interests us)
 php add_device.php --template=10 --community='MyCoimmunity'  --avail='snmp' --version=1 --ip=MyTargetDevice --description='My device to be monitored'
 php add_graphs.php --list-hosts    (we note that the host nr. 31 interests us)
 php add_graphs.php --host-id=31 --list-graph-templates   (we note that graph template nr. 44 interests us)
 php add_graphs.php --host-id=31 --graph-template-id=44 --graph-type=cg
 To add interface graphs its quite a bit more complictaed, see
  http://www.cacti.net/downloads/docs/html/cli_add_graphs.html

Other cli tools not yet tested: rebuild_poller_cache.php poller_reindex_hosts.php poller_graphs_reapply_names.php copy_user.php add_tree.php  add_perms.php