Telegraf SNMP inputs agents on different file

telegraf
#1

Hi,
Is it possible add path to file which contains list of agent hosts instead of adding all host names or IP addresses in telegraf.conf.
For example now we have:
[[inputs.snmp]]
_ agents = [“10.0.0.1:161” , “10.0.0.5:161” , “test-router.mydomain.net:161”]_

Is it possible something like this:
[[inputs.snmp]]
_ agents = “/etc/telegraf/routers-and-switches.txt”_

I need that because I want to run multiple input.snmp instances for the same list of devices. Each instance would be dedicated for different metric (CPU, Memory, Interface). And I could easily add o remove devices to monitoring.

#2

No, it is not possible to do this.

#3

So I have a similar problem, but a different approach (which might work for you).

Instead of a monolithic file, I was planning on using a single config file per-device that would be generated via a script using a set of templates and a list of devices. In your case, I might try doing something like this:

Have a set of templates that looks like the following:

[[inputs.snmp]]
  agents = "<devices>"
  #rest of config

Then a script that would look something like this:

transform human-readable device list into telegraf-readable device list
for each file in <scriptdir>/templates:
  insert comment about file being automatically managed
  replace <devices> with device list
  save as <telegraf_dir>/telegraf.d/<template_name>.conf
reload telegraf

Adding a device then would involve updating the device list and running the update script.

IMO this approach is a little better than your original idea because it gives you the option to build in safeguards against accidentally breaking your telegraf config.

2 Likes
#4

Thanks @bcoleman , it is actuality really good idea, I did not realize that I ca run multiple telegraf configuration files. And it will let me provision new and decommissioned devices a lot easier.