Cacti

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 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. CITATION

Cacti Installation
A sample installation below cam from Linux/Debian Server

You can start the installation by following procedures:

apt-get install apache2
apt-get install mysql-server
apt-get install php5
apt-get install php5-common
apt-get install php5-cgi
apt-get install php5-cli
apt-get install php5-mysql
apt-get install snmp
apt-get install rrdtool

Create MySQL Database for Cacti:

mysql -p
mysql> CREATE DATABASE cacti CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> GRANT ALL PRIVILEGES ON cacti.* TO cacti_user@localhost IDENTIFIED BY somepassword;
mysql> flush privileges;

Download and Install Cacti

cd /tmp
wget http://www.cacti.net/downloads/cacti-0.8.7b.tar.gz
tar zxvf cacti-0.8.7b.tar.gz
mv cacti-0.8.7b /home/cacti

Create a symlink under /var/www for cacti

cd /var/www
ln -s /home/cacti cacti

Configure Apache

cd /etc/apache2/sites-available
 
nano cacti
# IT SHOULD HAVE THE FOLLOWING
NameVirtualHost *

      ServerAdmin admin@thesysad.com
      ServerName cacti.thesysad.com
      DocumentRoot /var/www/cacti/
      
            Options FollowSymLinks
            AllowOverride None
      
      ErrorLog /var/log/apache2/error.log
  
      # Possible values include: debug, info, notice, warn, error, crit,
      # alert, emerg.
      LogLevel warn
      CustomLog /var/log/apache2/access.log combined
      ServerSignature On

Under the cacti root directory Edit include/config.php and specify the MySQL user, password and database for cacti configuration

# IT SHOULD HAVE THE FOLLOWING
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti_user";
$database_password = "somepassword";
$database_port = "3306";

Edit the root directory owner

chown cacti:www-data -R /home/cacti

Restart Apache then you will be able to access the cacti via browser

http://cacti.thesysad.com

Cacti Monitoring Linux Machines With NRPE
Cacti can retrieve information from Linux hosts that are running the NRPE daemon (a.k.a. agent) by defining “Data Input Methods” that trigger some perl scripts

Sample Script Details:

name:             check_load_average.pl
cacti invocation: /usr/bin/perl /opt/nrpe-perl-scripts/check_load_average.pl 
purpose:          This script retrieves the CPU load average of a Linux machine running the NRPE daemon.
                  The average is calculated as: (first_number + second_number + third_number) / 3
example:          ./check_load_average.pl 172.20.10.218
name:             check_useddiskspace.pl
cacti invocation: /usr/bin/perl /opt/nrpe-perl-scripts/check_useddiskspace.pl  
purpose:          This script retrieves the PERCENTAGE disk space used on the specified host and drive
example:          ./check_useddiskspace.pl /dev/sda1 172.20.10.218
name:             check_free_swap.pl
cacti invocation: /usr/bin/perl /opt/nrpe-perl-scripts/check_free_swap.pl 
purpose:          Retrieves the percentage of free swap memory of the given host
example:          ./check_free_swap.pl 172.20.10.218
name:             check_free_memory.pl
cacti invocation: /usr/bin/perl /opt/nrpe-perl-scripts/check_free_memory.pl 
purpose:          Retrieves the percentage of free memory of the given host
example:          ./check_free_memory.pl 172.20.10.218

name:             check_procs.pl
cacti invocation: /usr/bin/perl /opt/nrpe-perl-scripts/check_procs.pl 
purpose:          Retrieves the total number of the processes that runs in a given host
example:          ./check_procs.pl 172.20.10.218
name:             check_processes.pl
cacti invocation: /usr/bin/perl /opt/nrpe-perl-scripts/check_users.pl 
purpose:          Retrieves the total number of the logged users in a given host
example:          ./check_users.pl 172.20.10.218

Cacti Monitoring Windows Servers with NSClient
Cacti can retrieve information from Windows hosts that are running the NSClient agent by defining “Data Input Methods” that trigger with some perl scripts.

Script location
In order to invoke these scripts it is required to have the full absolute path to them. You can have them on the following location:

/opt/nsclient-perl-scripts

Script details

name:             check_cpuload.pl
cacti invocation: /usr/bin/perl /opt/nsclient-perl-scripts/check_cpuload.pl 
purpose:          retrieves the latest 5 minutes CPU load average
Example:          ./check_cpuload.pl 172.20.10.218
name:             check_perfmon.pl
cacti invocation: /usr/bin/perl /opt/nsclient-perl-scripts/check_perfmon.pl  
purpose:          retrieves the latest 5 minutes CPU load average
Example:          ./check_prefmon.pl 172.20.10.218
name:             check_uptime.pl
cacti invocation: /usr/bin/perl /opt/nsclient-perl-scripts/check_uptime.pl 
purpose:          prints out the uptime of a windows machine in DAYS (using 2 decimals)
Example:          ./check_uptime.pl 172.20.10.218
name:             check_useddiskspace.pl
cacti invocation: /usr/bin/perl /opt/nsclient-perl-scripts/check_useddiskspace.pl  
purpose:          retrieves the PERCENTAGE disk space used on the specified host and drive
Example:          ./check_useddiskspace.pl c 172.20.10.218

name:             check_mysql.pl
cacti invocation: /usr/bin/perl /opt/nsclient-perl-scripts/check_mysql.pl  
purpose:          retrieves values of database server status of variables for MySQL based from doc http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
Example:          ./check_mysql.pl 172.20.10.218 Qcache_free_memory
NOTE:     This script is passing the query thru check_mysqld.pl script