SNMP (Simple Network Management Protocol) is a protocol used for network management and monitoring. You can install and configure the SNMP daemon (snmpd
) service on a Debian or Ubuntu Linux system to monitor various aspects of the system’s performance, such as CPU usage, memory usage, and network traffic.
Here’s how to install and configure snmpd
on Debian or Ubuntu:
- Install the
snmpd
package:sudo apt-get update
sudo apt-get install snmpd
- Edit the
snmpd.conf
configuration file, which is located in the/etc/snmp/
directory. You’ll need to be root to edit this file. Here’s an example of how to configure SNMP for monitoring the system’s CPU usage and memory usage:rocommunity public
syslocation "Server Room"
syscontact admin .com
disk /
disk /var
load 5 10 15
extend cputemp /usr/bin/sensors | /bin/grep "^Core 0:" | /usr/bin/awk '{ print $3 }'
extend memfree /usr/bin/free | /bin/grep Mem | /usr/bin/awk '{ print $4 }'
The
rocommunity public
line sets the community string to “public”, which is the default and allows read-only access to the SNMP data. Thesyslocation
andsyscontact
lines provide information about the system’s location and contact information, respectively.The
disk
lines specify which filesystems to monitor. In this example, we’re monitoring the root filesystem and the/var
filesystem.The
load
line specifies the load average thresholds to monitor.The
extend
lines provide custom commands to monitor the CPU temperature and free memory. You can customize these as needed. - Restart the
snmpd
service:sudo systemctl restart snmpd
This will apply the changes you made to the
snmpd.conf
file.
You should now be able to monitor your Debian or Ubuntu system using an SNMP client. For example, you can use the snmpwalk
command to query the SNMP data:
snmpwalk -v 2c -c public localhost
This will display a list of SNMP data for your system. You can also use a graphical SNMP client, such as Cacti or Nagios, to monitor your system.