hello everyone, i’m monitoring my routers with telegraf/influxdb via snmp , but i was wondering if it’s possible to add agents from a text file instead of adding the IPs
the current conf:
agents = [ “192.168.1.1:161”,“192.168.1.1:161” ]
The wanted conf:
agents = [ import/include /etc/telegraf/MyIPs.txt ]
Depending on how long your agents list is and how frequently it is updated you may be able to use environment variables to work around the current requirement to list agents in the telegraf configuration file. The link Anaisdg shared describes how to use environment variables.
If your concern is that your configuration file is too large, it might help to split it into multiple files and load them all with the --config-directory command line option. For example you could have a file just for snmp.
Thank you very much for your reply, actually, i don’t have variables and my list is not that long, i only have a text file that contains all my IPs (this list is static and won’t be changing) so in need just to know how i can load the text file in
agents = [ IPs.text ] instead of adding the IPs one by one. I think what i want is not that hard to do and surely we can do it with telegraf but i wasn’t able to find a solution online
I’ve read the link that Anaisdg has sent me but i have a small question please, in the link the variable was a HTTP link, so my question is will it accepts to put the path of my file in the same way? and if so is telegraf will be able to read what i have written in this file?