In the previous guide, we demonstrated how you can install Cacti monitoring server on CentOS 8. This tutorial goes a step further and shows you how you can add and monitor remote Linux hosts on Cacti. We are going to add remote Ubuntu 20.04 LTS and CentOS 8 systems to the cacti server for monitoring.
Step 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. Using SNMP, you can poll metrics such as CPU utilization, memory usage, disk utilization, network bandwidth etc. This information will, later on, be graphed in Cacti to provide an intuitive overview of the remote hosts’ performance.
With that in mind, we are going to install and enable SNMP service on both Linux hosts:
On Ubuntu 20.04
To install snmp agent, run the command:
$ sudo apt install snmp snmpd -y
On CentOS 8
$ 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
We can clearly see that the service is up and running. By default, SNMP runs listens on UDP port 161, You can verify this using the netstat command as shown.
$ sudo netstat -pnltu | grep snmpd
Step 2) Configuring SNMP service
So far, we have succeeded in installing snmp service and confirmed that it is running as expected. The next course of action is to configure the snmp service so that data can be collected and shipped to the Cacti service.
The configuration file is located at /etc/snmp/snmpd.conf
For Ubuntu 20.04
We need to configure a few parameters. First, locate the sysLocation and sysContact directives. These define your Linux client’s Physical location.
Therefore, feel free to provide your client’s location.
Next, locate the agentaddress directive. This refers to the IP address and the port number that the agent will listen to.
Adjust the directive as shown below where 192.168.2.106 is my client system’s address.
The directive will now allow the system’s local IP to listen to any snmp requests. Next up, add the view directive below above the other view directives:
view all included .1 80
Next, change the rocommunity attribute shown below
rocommunity public default -V systemonly
rocommunity public default -V all
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 192.168.2.106
You should get some massive output as shown.
For CentOS 8
In CentOS 8, the configuration is slightly different. First, locate the line that begins with the com2sec directive as shown:
We will specify a new security name known as AllUser and delete the notConfigUser as shown:
Next, locate the line that starts with the group directive as shown.
We will modify the second attribute and specify AllGroup as the group name and AllUser as the security name as previously defined.
In the view section, add this line
view AllView included .1
Finally, locate the line beginning with the access directive.