Hello, my question is the following: I have a device, for example 192.168.1.1, and I want to collect bandwidth values with a time interval of 300s using SNMP. But apart from that, I need to know the status of the device every 10s, for example. How should I do it? Should I make 2 configuration files for that device? That is, one that recovers the bandwidth and another for the status?
Thanks
Hi Carlos,
Telegraf will have one main telegraf.conf file. You can place your plugins there, but you can also create additional files at telegraf.d directory. There you can name the file the way you want using .con extension. Telegraf will read this directory for those files at the beginning. It starts, as tandard using “-config-directory /etc/telegraf/telegraf.d”
Those additional files only need to have the plugins you want, like:
[inputs.snmp]
…
[input.exec]
…
They do not include [agent] as in telegraf.conf.
In a simple way of explaining, when telegraf starts it loads telegraf.conf and concatenate all .conf files in telegraf.d
It´s a good practice to have additional files named in a way that help troubleshoot.
Hope it helps!
Bruno
Hello, how are you? Yes, I already have it created like this. I was referring to the following… if I have in /telegraf.d/ I have for example the file 1.conf which is a device that has an interval of 300s… but I want to recover data from that same device but every 10s… do I have to create another conf file? It’s not that it can be done in the same file, right?
Thanks
Hi Carlos!
If I understood correctly, It can be done at the same file defining the interval for each plugin, like:
[[inputs.exec]]
interval = “300s”
…
[[inputs.snmp]]
interval = “10s”
…
Plugins can have different intervals than the
[agent]
interval = “300s”
Please, let me know if this is what you are looking for.
Regards,
Bruno
Sure, great… the only thing is that it is within the same [[inputs.snmp]]. Because for example the signal levels every 300s and the status every 10s,. So in this case I will have to have a different conf file for that.
Thanks
You can’t have two different intervals in the same input (it wouldn’t know which one to use). You can have two different intervals in the same config file though. It would look similar to:
cat /etc/telegraf/telegraf.d/snmp.conf
[[inputs.snmp]]
interval = "300s"
**insert snmp query info here for a 300s collection**
[[inputs.snmp]]
interval = "10s"
**insert snmp query info here for a 10s collection**
Let me see if I understand correctly… should the structure of my .conf file be like this?
[[inputs.snmp]]
agents = [“192.168.1.1:161”]
version = 2
community = “test”
interval = “10s”
name = “ont”
[[inputs.snmp.table]]
name = “ont”
[[inputs.snmp.table.field]]
name = “status”
oid=“.1.3.6.1.4.1.3902.1012.3.28.2.1.3”
[[inputs.snmp]]
agents = [“192.168.1.1:161”]
version = 2
community = “test”
interval = “300s”
name = “olt”
[[inputs.snmp.table]]
name = “olt”
oid = “IF-MIB::ifXTable”
index_as_tag = true
[[inputs.snmp.table.field]]
name = “ifName”
oid = “IF-MIB::ifName”
is_tag = true
[[inputs.snmp.table.field]]
name = “ifIndex”
oid = “IF-MIB::ifIndex”
is_tag = true
Yes, something along those lines. You can add multiple items to the agents section too if you want to do the same thing across multiple devices.