Hostripples Featured

How to Install Cacti: A perfect tool to Monitor Network Bandwidth

  1. How to Install Cacti Network Monitoring App?

Introduction

To monitor servers and services we can use Nagios which provide enterprise-class monitoring. It’s one of the standard tools, but to monitor bandwidth utilization over the network, Cacti is a complete network graphing solution that useful for the network administrators to monitor their network bandwidth. It is very easy to use and have the following features:

  1. Graphs
  2. Data Sources
  3. Data Collection
  4. Graph Display
  5. User Management

Server-side requirements to install Cacti

The Cacti required the following packages to be installed on your Linux operating system.

  1. HTTP/Apache: A Web server to display network graphs created by PHP and RRDTool.
  2. MySQL/MariaDB: A Database server.
  3. PHP: To run or support the script module to create graphs using RRDTool.
  4. PHP-SNMP: A PHP extension for SNMP to access data.
  5. NET-SNMP: A SNMP (Simple Network Management Protocol) is used to manage networks.
  6. RRDTool: A database tool to manage and retrieve time series data like CPU load, Network Bandwidth, etc.

Installation:

  1. First install apache/httpd if its not installed on the server using YUM.

yum install httpd httpd-devel

  1. Next, install mysql / MariaDB

yum install mysql mysql-server

  1. Now install PHP

yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-mysql

  1. Install PHP-SNMP with NET-SNMP

yum install php-snmp net-snmp-utils p net-snmp-libs php-pear-Net-SMTP

  1. Now install RRDTool

yum install rrdtool

Once you are done with all the above software requirements for Cacti installation, let’s proceed with the following commands one by one.

Before that correct snmpd.conf as follows

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf_old

vi /etc/snmp/snmpd.conf and add following in it

com2sec local localhost public

group MyRWGroup v1 local

group MyRWGroup v2c local

group MyRWGroup usm local

group MyROGroup v1 mynetwork

group MyROGroup v2c mynetwork

group MyROGroup usm mynetwork

view all included .1 80

access MyROGroup “” any noauth exact all none none

access MyRWGroup “” any noauth exact all all none

syslocation Linux (RH3_UP2), Home Linux Router.

syscontact Admin (admin@jasmax.in)

Then restart following services.

/etc/init.d/httpd start

/etc/init.d/mysqld start

/etc/init.d/snmpd start

Configuring Apache, MySQL and SNMP Services to start on boot.

/sbin/chkconfig –levels 345 httpd on

/sbin/chkconfig –levels 345 mysqld on

/sbin/chkconfig –levels 345 snmpd on

Further, To install cacti needs to enable EPEL Repository using following way.

How to enable it on CentOS 6 32-64 Bit

## RHEL/CentOS 6 32-Bit ##

# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

# rpm -ivh epel-release-6-8.noarch.rpm

## RHEL/CentOS 6 64-Bit ##

# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# rpm -ivh epel-release-6-8.noarch.rpm

How to enable it on CentOS 5 32-64 Bit

## RHEL/CentOS 5 32-Bit ##

# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

# rpm -ivh epel-release-5-4.noarch.rpm

## RHEL/CentOS 5 64-Bit ##

# wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

# rpm -ivh epel-release-5-4.noarch.rpm

Once you’ve enabled repository, type the following command to install Cacti application.

# yum install cacti

Next: Set MySQL Password

# mysqladmin -u root password YOUR-PASSWORD-HERE

Now, Create MySQL Cacti Database

# mysql -u root -p

mysql> create database cacti;

mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY ‘your-password-here’;

mysql> FLUSH privileges;

mysql> quit;

Install Cacti Tables to MySQL

mysql -u cacti -p cacti < /var/www/cacti/cacti.sql

Configure MySQL settings for Cacti

vi /var/www/cacti/include/config.php

Make the following changes and save the file. Make sure you set password correctly.

/* make sure these values reflect your actual database/host/user/password */

$database_type = “mysql”;

$database_default = “cacti”;

$database_hostname = “localhost”;

$database_username = “cacti”;

$database_password = “your-password-here”;

$database_port = “3306”;

$database_ssl = false;

Setting up the crontab for poller.php

# crontab -e

*/5 * * * * /usr/bin/php /var/www/cacti/poller.php >> /var/log/cacti 2>&1

Configure cacti.conf as below:

vi /etc/httpd/conf.d/cacti.conf

remove exixting and add following

Alias /cacti /var/www/cacti/

<Directory /var/www/cacti/>

DirectoryIndex index.php

Options -Indexes

AllowOverride all

order deny,allow

allow from all

AddType application/x-httpd-php .php

php_flag magic_quotes_gpc on

php_flag track_vars on

</Directory>

Restart Apache to take effect on the changes:

# /etc/init.d/httpd restart

Navigate your browser to http://serverIP/cacti and following the instructions

Login to your new Cacti installation from http://serverIP/cacti/ with default user (admin) and the default password (admin).

That’s all with cacti installation

  1. Now how to add a new server in a cacti configuration.
  2. log in to cacti as an admin user
  3. Go to Console -> Devices and choose Add from the top right corner
  4. Enter a name in description and address / FQDN in Hostname
  5. Choose host template as ‘Generic SNMP Enabled host or Linux Generic’
  6. Click create

On the same page after clicking creates under the ‘Associated Graph Templates’ section add the following templates:

ucd/net – CPU Usage

ucd/net – Memoery Usage

Unix – Load average

Unix – Logged in users

Unix – ping latency

Unix – procesess

and then click the Save button

Next,

  1. Click on the ‘Create Graphs for this host’ link at top-right from page resulting after ‘save’.

Choose all graph templates by clicking at top-most check-box on the right side

Choose interesting interfaces by clicking on corresponding check-boxes from the below table In ‘Select a graph type:’ drop-down at bottom right choose ‘In/Out Bytes with Total Bandwidth’ Click Create

Again click Create on the next page, Go to Console Graph Trees

Click on Add at the top right corner, Type name for the tree, preferably the same as a name written in description while adding device.

Click create

Now click on Console -> ‘Graph management’. Select Host in the host drop-down menu so that only graphs related to chosen host appear.

Select all graphs for this new host using the check-box at the top right corner

From Choose an action drop-down menu to choose ‘Place on a tree (<description>)’ to place all graphs for this host on the tree created for this host.

Then click go and then continue to the next page. Now go to ‘Graphs’ and in Tree-mode click on the name of the new host added to see its graphs.

  1. Client-side SNMP configuration.

Ensure that packages ‘net-snmp’ and ‘net-snmp-utils’ are installed.

yum install net-snmp-utils net-snmp

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf_old

vi /etc/snmp/snmpd.conf and add following

com2sec local localhost public

com2sec mynetwork 64.37.52.254 public

group MyRWGroup v1 local

group MyRWGroup v2c local

group MyRWGroup usm local

group MyROGroup v1 mynetwork

group MyROGroup v2c mynetwork

group MyROGroup usm mynetwork

view all included .1 80

access MyROGroup “” any noauth exact all none none

access MyRWGroup “” any noauth exact all none

syslocation Linux (RH3_UP2), Home Linux Router.

syscontact admin (admins@jasmax.in)

Then restart snmpd service

/etc/init.d/snmpd start

Next, enable 161 port in csf udp_in and udp_out and restart csf

  1. How to create a user with limited access to cacti
  2. log in to cacti as an admin
  3. Click on Console -> User Management
  4. Click Add from the top right corner of the page
  5. Type User Name and Password
  6. Next, click on View Graphs under Realm Permissions
  7. Click on Graph Permissions
  8. Select the hostname/device for which you want to give permission to the user to view the graphs and click on Add button
  9. Next Tree Permissions. : Select the tree under which the host/device belongs. Next click on the add button
  10. Last click on the SAVE button at the end.
  11. Logout as an admin and try with newly created users with limited access.

That’s all.


HR-ADMIN

Recent Posts

Crafting a Professional Email: Step-by-Step Guide

Due to growing digitalization, Email Communication has become the backbone of professional interactions. Yet, surprisingly, many professionals struggle to craft…

1 day ago

Demystifying SSL: What Every Website Owner Should Know

As the digital landscape continues to evolve, securing your website has never been more crucial. SSL, or Secure Sockets Layer,…

1 week ago

Cyberduck and FileZilla: A Comprehensive Comparison

As a web designer and web developer your experience must have reached to new height, right? Further, you need to…

1 month ago

The Science Behind Social Media Posting Times

In today's digital landscape, timing is everything. Whether you're a social media manager, business owner, or content creator, the success…

1 month ago

Mastering Google Search Console: Tips for New Users

Are you a website owner? Maintaining the website is the prime concern for any website owner. Yes, it’s equally important…

1 month ago