×


Add Remote Linux Host to Cacti for Monitoring - Do it now

Cacti is a network monitoring device that creates personalized graphs of server efficiency. The process to add a remote Linux host to Cacti also involves steps to install and configure SNMP service on the remote host.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to Server Monitoring tasks.

In this context, we shall look into the steps to add a remote Linux host to Cacti.


Steps to add remote Linux host to Cacti?

1. Install SNMP service on remote Linux hosts.

2. Configuring SNMP service.

3. Configure the firewall rules for SNMP.

4. Adding remote Linux host to Cacti.


Now, let's get into them individually briefly.


1. Install SNMP service on remote Linux hosts

SNMP protocol allows us to collect information on CPU utilization, memory usage, disk utilization, network bandwidth, and so on.

Cacti create graphs on this information and provide an overview of the remote hosts’ performance.

Now, let us install and enable SNMP service on both Linux hosts: 

To install SNMP agent, run the command:

Ubuntu -$ sudo apt install snmp snmpd -y
Centos -$ sudo dnf install net-snmp net-snmp-utils -y

SNMP starts automatically upon installation. If the service is not running yet, start and enable it on boot. 

To confirm the status and start the service, use the commands below :

$ sudo systemctl status snmpd
$ sudo systemctl start snmpd


2. Configuring SNMP service

After the install of snmp service, the next step is to configure it. 

It will then help in collecting data and shipping it to the Cacti service. 

The configuration file is located at /etc/snmp/snmpd.conf.

Let us now discuss the steps involved in Ubuntu and Centos separately.


For Ubuntu 20.04

We need to configure a few parameters in the snmp configuration file.

i. First, locate the sysLocation and sysContact directives that define Linux client’s Physical location. Edit these parameters to set the values of our server.

ii. Next, locate the agentaddress directive. This refers to the IP address and the port number that the agent will listen to.

iii. Adjust the directive in the format below. Replace the IP_address field in the format with the original client system's address:

agentaddress udp:IP_address

The directive will now allow the system's local IP to listen to any snmp requests.

iv. Next, add the view directive given below on top of the other view directives:

view    all    included   .1    80

v. Next, change the rocommunity attribute shown below:

rocommunity public default -V systemonly
to:
rocommunity public default -V all

vi. Finally, to ensure the snmp service is working as expected, run the command below on the Linux host:

$ sudo snmpwalk -v 1 -c public -O e IP_address

Here IP_address is the IP address of the client's system.

This should output a large amount of data.


For CentOS 8

In CentOS 8, the configuration is slightly different. 

i. First, locate the line that begins with the com2sec directive in the configuration file as shown:

# sec.name source community
com2sec notConfigUser default public

ii. We will specify a new security name known as AllUser and delete the notConfigUser as shown:

# sec.name source community
com2sec AllUser default public

iii. Next, locate the line that starts with the group directive as shown.

# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser

iv. We will modify the second attribute and specify AllGroup as the group name and AllUser as the security name as previously defined:

# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group AllGroup v2c AllUser

v. In the view section, add this line:

view AllView included .1

vi. Finally, locate the line beginning with the access directive. Replace the notConfigGroup parameter with AllGroup and systemview with AllView.

Save the changes and exit the configuration file. Restart snmpd daemon for the changes to take effect

$ sudo systemctl restart snmpd

vii. Also, enable the service to start on boot.

$ sudo systemctl enable snmpd

viii. Once again, verify if the snmp configuration is working as expected using the snmpwalk command:

$ sudo snmpwalk -v 2c -c public -O e 127.0.0.1

 

3. Configure the firewall rules for snmp

Next, we need to open udp port 161 to allow snmp traffic on both the Cacti server and Linux hosts.


For Ubuntu 20.04 host

Run the beneath commands to allow udp port 161 in the firewall:

$ sudo ufw allow 161/udp
$ sudo ufw reload

For CentOS 8 host

For CentOS 8 client and the Cacti server that also runs on CentOS 8, invoke the following commands:

$ sudo firewall-cmd --add-port=161/udp --zone=public --permanent
$ sudo firewall-cmd --reload

Head over to the Cacti server and run the commands shown to confirm that snmp is shipping metrics from the remote clients:

$ sudo snmpwalk -v 1 -c public -O e IP_address# Ubuntu
$ sudo snmpwalk -v 2c -c public -O e IP_address # CentOS

This confirms that the Cacti server is receiving system metrics from the remote Linux systems.


4. Adding remote Linux host to Cacti

i. To log in into the Cacti monitoring tool, access the URL:

http://your.ip.add.ress/cacti

This is the section where you have to add your remote Linux hosts. 

ii. So, log in to the Cacti server and click on 'Create devices'. 

iii. We can also add device from the Management >> Devices >> + Sign .

iv. Once the device is added, click on "Create Graphs for this Host" link at the top right on the same page to create graphs. 

v. Select the templates depending on the requirements. 

vi. For network interfaces, select a graph type as In/Out Bits with Total Bandwidth and then click on Create.


[Need urgent assistance to add Linux host to Cacti ? – We're available 24*7. ]


Conclusion

This article covers how to add a #Linux host to #Cacti.

Basically, Cacti is a network #monitoring device that creates personalized graphs of server efficiency.

SNMP, short for Simple Network Management Protocol is a protocol used for gathering information about devices in a network. Using SNMP, you can poll metrics such as CPU utilization, memory usage, disk utilization, network bandwidth, and so on. 


To install snmp agent on Ubuntu, run the command:

$ sudo apt install snmp snmpd -y


To install #snmp agent On CentOS 8, run the command:

$ sudo dnf install net-snmp net-snmp-utils -y


SNMP starts automatically upon installation.

To confirm this, confirm the status by running:

$ sudo systemctl status snmpd

If the service is not running yet, start and enable it on boot as shown:

$ sudo systemctl start snmpd


To Add Remote Linux Host to Cacti for Monitoring:

1. Install SNMP service on Linux hosts. SNMP, short for Simple Network Management Protocol is a protocol used for gathering information about devices in a network.

2. Configuring SNMP service.

3. Configure the firewall rules for snmp.

4. Adding remote Linux host to Cacti.


To Install and Configure Cacti:

1. Cacti require few more dependencies, run the following command to install them:

yum -y install net-snmp rrdtool net-snmp-utils

2. As we have all the dependencies ready, we can now download the install package from Cacti website.

cd /var/www/html

wget http://www.cacti.net/downloads/cacti-1.1.10.tar.gz

3. You can always find the link to the latest version of the application on Cacti download page. Extract the archive using the following command.

tar xzvf cacti*.tar.gz

4. Rename your Cacti folder using:

mv cacti-1*/ cacti/

5. Now import the Cacti database by running the following command.

cd /var/www/html/cacti

mysql cacti_data < cacti.sql -u root -p

6. The above command will import the cacti.sql database into cacti_data using the user root. 

It will also ask you the password of root user before importing the database.

7. Now edit Cacti configuration by running the following command.

nano /var/www/html/cacti/include/config.php

8. Now find the following lines and edit them according to your MySQL database credentials.

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

$database_type     = 'mysql';

$database_default  = 'cacti_data';

$database_hostname = 'localhost';

$database_username = 'cacti_user';

$database_password = 'StrongPassword';

$database_port     = '3306';

$database_ssl      = false;