Add Multiple SNMP Agents to Telegraf Config

Video Lecture

Add Multiple SNMP Agents to Telegraf Config Add Multiple SNMP Agents to Telegraf Config Add Multiple SNMP Agents to Telegraf Config


I will add several more SNMP agents to the Telegraf config.

In order for Telegraf to connect to the external SNMP agents, those other SNMP agents will need to be configured to allow my Telegraf agent to connect remotely.

On my servers, that I'd like monitor using SNMP, I install SNMPD using

sudo apt install snmpd

I then configure snmpd.conf.

sudo nano /etc/snmp/snmpd.conf

I change below,


to allow remote connections,

agentAddress udp:161

and I change below

view   systemonly  included   .
view   systemonly  included   .

to return more data,

view   systemonly  included   .
#view   systemonly  included   .

and I change below,

rocommunity public  default    -V systemonly
rocommunity6 public  default   -V systemonly

to set the community, and restrict to ipv4 only(optional).

rocommunity mycommunity  default    -V systemonly
#rocommunity6 mycommunity  default   -V systemonly

The SNMPD can now be connected to remotely by anybody on the internet, so I use iptables to restrict UDP connections on port 161 to the localhost and my external Grafana server domain or ip only.

iptables -A INPUT -p udp -s [domain name or ip] --dport 161 -j ACCEPT
iptables -A INPUT -p udp -s localhost --dport 161 -j ACCEPT
iptables -A INPUT -p udp --dport 161 -j DROP
iptables -L

I then start the SNMPD service

sudo service snmpd start

I then go back to my Grafana server, and test that I can query the new SNMPD on the other server using SNMPWALK.

snmpwalk -v 2c -c mycommunity [domain name or ip] .

I then reconfigure the Telegraf conf to add the information for my external SNMP agent.

I duplicate the existing [[inputs.snmp]] section from the last lecture, but change the SNMP agents address.

I also repeat the process for another server that I want to monitor SNMP for, so at the end of the lecture, I have 3 SNMP agents able to be queried using Grafana.

After I've added all my SNMP agent configs to the telegraf.conf, I then restart the Telegraf service on my Grafana server.

sudo systemctl restart telegraf

IPTables Cheatsheet