Of all of the tools I’ve been evaluating recently for server performance monitoring cacti has to be one of my favorites (mind you I loathe actual cacti, far too many spines have embedded themselves in my flesh…). Cacti is a RRDTool based graphing solution for server performance monitoring. This level of insight crucial for sysadmins once you get above a few servers or when you have that nagging performance problem that “occasionally” happens. It’s always nice to see what’s happening, but it’s even better to see the historical data so that you can use it to help give insight future needs. As well it is extremely flexible when it comes to custom metric monitoring. One of these days I’ll post up an install and configuration guide for Percona’s Cacti scripts but then again it did take me nearly a year to finish this post…
Installing Cacti 0.8.8a
Just as a general note before we begin the install process, yes I’m aware you could have used iptables instead of system-config-firewall and in fact it would be probably be better to use iptables. But everyone needs to remember how lazy I am when it comes to systems that should not be directly web-accessible (even though in about 2 weeks you’ll hear that people want access to it from the outside). Also I assume that you are working from a base installation of CentOS and know at least generally what you’re doing (for instance, if you have MySQL installed, you shouldn’t go about the process of installing mysql-server, starting it and doing the secure install).
$ yum install php mysql-server php-mysql php-snmp php-gd php-ldap rrdtool net-snmp-utils $ yum install system-config-firewall $ service httpd start $ chkconfig --levels 235 httpd on $ system-config-firewall
Then go to Customize > WWW (HTTP) > Close > OK > Yes
$ curl -O http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz $ tar -zxvf cacti-0.8.8a.tar.gz $ service mysqld start $ /usr/bin/mysql_secure_installation $ chkconfig --levels 235 mysqld on $ mysqladmin -u root -p create cacti $ mysql -u root -p cacti GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY '[your_password_here]'; mysql> FLUSH PRIVILEGES; mysql> exit $ adduser cacti $ passwd cacti $ mv cacti-0.8.8a /home/cacti/public_html $ chown -R cacti:cacti /home/cacti/public_html $ su - cacti $ cd public_html $ vi include/config.php
Now update the config file to have the correct username and password to MySQL. As well you will need to uncomment $url_path and update it. The following are the lines you’re looking for:
$database_username = "cacti"; $database_password = "[your_password_here]"; $url_path = "/~cacti/";
Now we need to update cron.
$ crontab -e
Add the following to your crontab:
*/5 * * * * php /home/cacti/public_html/poller.php > /dev/null 2>&1
Now time to update the apache settings to allow cacti.
$ vi /etc/httpd/conf.d/userdir.conf
Add the following to the file.
# # UserDir is disabled by default since it can confirm the presence # of a username on the system (depending on home directory # permissions). So we will deny it by default and only allow it # for cacti. # UserDir disabled UserDir enabled cacti # # To enable requests to /~user/ to serve the user's public_html # directory, remove the "UserDir disabled" line above, and uncomment # the following line instead: # UserDir public_html Options Indexes Includes FollowSymLinks AllowOverride All Allow from all Order deny,allow
Finally all you need to do is restart httpd.
$ service httpd restart
Navigate browser to http://%5Bip of the server you installed it on]/~cacti
Then click Next > New Install > Next > Finish
Default user login: admin // admin
Also please, please… PLEASE change the default admin password.