---
title: Cacti
date: 2011-04-07 08:51:55
permalink: https://lesterchan.net/blog/2011/04/07/cacti/
author: Lester Chan
categories:
  - Site
tags:
  - Apache
  - Cacti
  - CentOS
  - graph
  - load
  - memcached
  - mysql
  - PHP
  - requests
  - rrdtool
  - server
  - template
  - VPS
  - WHM
  - Yum
---

Spend the weekends trying to get [Cacti](http://www.cacti.net/) up and running on this VPS. Apparently since this VPS is using [WHM](http://www.cpanel.net/) on CentOS, there are some packages like Apache, PHP, MYSQL, Perl, Ruby installed directly but not indicated as installed via [Yum](http://yum.baseurl.org/) and hence it is failing dependency check when trying to install [rrdtool](http://www.mrtg.org/rrdtool/).

**What is Cacti**

> 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, 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 installation templating s up to complex networks with hundreds of devices.

**What is RRDtool**

> RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. RRDtool can be easily integrated in shell scripts, perl, python, ruby, lua or tcl applications.

Spent almost the whole day trying to get that installed but to no avail. Found this tutorial, [Install RRDTool on Red Hat Enterprise Linux](http://www.cyberciti.biz/faq/howto-install-rrdtool-on-rhel-linux/), followed it and I managed to get rrdtool up and running.

Next was the easy step which is to [download Cacti](http://www.cacti.net/download_cacti.php) and upload it to this server. PHP and MYSQL is needed to run Cacti and hence you need to create a MYSQL database and account for Cacti.

Once that is done, remember to import the existing database data/structure in **cacti.sql** into the database, if not you will get segfault errors when accessing your Cacti.

You will also need to create a cron job that runs once every 5 minutes to populate contents for Cacti, refer to [Install and Configure Cacti](http://www.cacti.net/downloads/docs/html/unix_configure_cacti.html).

Now what you need are templates/graphs to monitor your Apache, MYSQL, Memcached and even your server. For Apache and MYSQL you can use [mysql-cacti-templates](http://code.google.com/p/mysql-cacti-templates/), even for Memcached, you can use that, but personally I am using [memcached Cacti Template](http://dealnews.com/developers/cacti/memcached.html).

Remember that each scripts you download requires configuration in the script itself.

- For memcached, you need to enter your memcached IP and Port.
- For Apache, you need to have SSH account setup and [mod\_status](http://httpd.apache.org/docs/2.0/mod/mod_status.html) compiled and ExtendedStatus set to On. By default, mod\_status is compiled in all WHM installations.
- For MYSQL, you need to enter your MYSQL credentials.

Everything is up and running, now it is the time to create a custom graph if you want, you can take a look at [Making Your Scripts Work With Cacti](http://www.cacti.net/downloads/docs/html/making_scripts_work_with_cacti.html).

I created a custom script to pull the number of usersonline on my site via my WordPress [WP-UserOnline](http://wordpress.org/extend/plugins/wp-useronline/) plugin and populate it in Cacti.

If you are using iPhone/iPad, there is also an app for it called [iCacti](http://icacti.webin.hu/) (Universal App) which cost US$3.99. I bought it instantly when I discovered that there is an app for Cacti. Works well with https/http auth and normal login.

![Blog - UsersOnline (Custom)](https://farm6.static.flickr.com/5069/5596236205_2c0068418f_o.png)

![Server - Load Average](https://farm6.static.flickr.com/5304/5596236599_30a32de522_o.png)

![Apache - Requests](https://farm6.static.flickr.com/5308/5596819258_1b1a2f2376_o.png)

![MYSQL - Command Counters](https://farm6.static.flickr.com/5188/5596819084_b631a768fa_o.png)

![Memcached - Requests Per Second](https://farm6.static.flickr.com/5262/5596236403_c40b7aefa6_o.png)