Index.
04-Dec-2011: Initial release. 18-Jan-2012: Added nginx configuration.
Introduction.
From the website: Cacti is a complete network graphing solution designed to harness the power of RRDTool‘s data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.
To use cacti you need a Apache or Nginx maintenance web server, SNMP must be installed and running, and you need a MySQL server.
Installation.
First, install the needed packages:
[root@homsrv ~]# pacman -S cacti php-snmp resolving dependencies... looking for inter-conflicts... Targets (4): ttf-dejavu-2.33-1 rrdtool-1.4.5-4 cacti-0.8.7h-1 php-snmp-5.3.8-5 Total Download Size: 4.98 MB Total Installed Size: 25.77 MB Proceed with installation? [Y/n] :: Retrieving packages from extra... ttf-dejavu-2.33-1-any 2.6M 1015.8K/s 00:00:03 [######################] 100% rrdtool-1.4.5-4-i686 549.5K 767.4K/s 00:00:01 [######################] 100% php-snmp-5.3.8-5-i686 7.2K 122.4K/s 00:00:00 [######################] 100% :: Retrieving packages from community... cacti-0.8.7h-1-any 1841.7K 986.9K/s 00:00:02 [######################] 100% (4/4) checking package integrity [######################] 100% (4/4) checking for file conflicts [######################] 100% (1/4) installing ttf-dejavu [######################] 100% (2/4) installing rrdtool [######################] 100% Optional dependencies for rrdtool tcl: to use corresponding binding python2: to use corresponding binding ruby: to use corresponding binding lua: to use corresponding binding (3/4) installing cacti [######################] 100% (4/4) installing php-snmp [######################] 100% [root@homsrv ~]#
Configuration.
The cacti web interface has it’s own root directory in the web server root, so we give it it’s own virtual server name and DNS entries. In /srv/names/int/db6.fcef.8fa1.1002 add:
$ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.e.7.f.c.e.f.8.f.a.1.1.0.0.2.ip6.arpa. 2.0.2 PTR cacti.wpl.ym.
Then in /srv/names/int/db.wpl.ym add:
cacti A 10.126.160.253 AAAA 2001:1af8:fecf:7ea0::202
Use rndc freeze before making the changes in these files and use rndc thaw after making these changes and don’t forget to increase the serial numbers in these two files.
Next we must add a virtual web server. If you use Apache then edit /etc/httpd/conf/extra/httpd-vhosts.conf and add the server like this:
# # cacti.wpl.ym <VirtualHost [2001:1af8:fecf:7ea0::202]:80 0.0.0.0:80> ServerAdmin admin@wpl.uk DocumentRoot /srv/http/cacti ServerName cacti.wpl.ym ErrorLog /var/log/httpd/cacti_error_log CustomLog /var/log/httpd/cacti_access_log combined <Directory /srv/http/cacti> AllowOverride All </Directory> </VirtualHost>
Now restart the web server:
[root@homsrv ~]# rc.d restart httpd :: Restarting Apache Web Server [DONE] [root@homsrv ~]#
If you use nginx add a virtual server to /etc/nginx/conf/nginx.conf:
server {
listen 10.126.160.253:80;
listen [2001:1af8:fecf:7ea0::202]:80;
server_name cacti.wpl.ym;
error_log logs/cacti_error_log;
access_log logs/cacti_access_log main;
root /srv/http/cacti;
index index.php;
location ~ \.php$ {
fastcgi_pass php;
include fastcgi.conf;
}
}
Reload the nginx server:
[root@homsrv ~]# rc.d reload nginx :: Checking configuration [DONE] :: Reloading Nginx Configuration [DONE] [root@homsrv ~]#
The next commands are directly taken from the Cacti ArchWiki:
[root@homsrv ~]# mysqladmin -u root -p create cacti
Enter password:
[root@homsrv ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.5.18 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cactiuser';
Query OK, 0 rows affected (0.10 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
[root@homsrv ~]# cd /srv/http/cacti && mv cacti.sql cacti.sql.org && \
sed s/TYPE=/ENGINE=/g cacti.sql.org > cacti.sql
[root@homsrv cacti]#
Edit /srv/http/cacti/include/config.php and set the correct database_username and database_password. I have the memory setting in /etc/php/php.ini set to maximum 128 MB, this seems to be too low for the first start of the Cacti web server. You can increase that value but if you have a low memory server you can also solve this problem by installing the database structure from the command line. And finally clean up the rest of the web environment.
[root@homsrv cacti]# cat cacti.sql | mysql -u cacti -pcactiuser cacti
[root@homsrv cacti]# cd
[root@homsrv ~]# chown -R http:http /srv/http/cacti/{rra,log}
[root@homsrv ~]# rm /srv/http/cacti/.htaccess
[root@homsrv ~]# chmod +x /srv/http/cacti/{cmd,poller}.php \
/srv/http/cacti/lib/ping.php
[root@homsrv ~]#
Now browse to http://cacti.wpl.ym/ to setup the rest of Cacti. The first time the admin password is admin, you are forced to change that. If all went well you should not have seen any problems during the web installation. Now only the poller needs to be added to cron:
[root@homsrv ~]# crontab -e [root@homsrv ~]#
The following line must be added to the crontab so that the poller runs as user http every five minutes:
*/5 * * * * /usr/bin/sudo -u http /usr/bin/php /srv/http/cacti/poller.php > /dev/null 2>&1
That’s it. Configure the hosts and the graphs, see the official documentation about how you should do that.
Download.
All the config files are in the global archive:
