I am pretty much new to telegraf. Currently I have a bash script gathering some SNMP data from a remote host, and inject the results into influxDB with curl. This is working fine, but I wanted to migrate this script to telegraf instead.
My current script do something like :
UPTIME=$(snmpget -Oqv -v 2c -c community server sysptime)
/usr/bin/curl --silent --request POST 'http://127.0.0.1:8086/write?db=mydb' --data-binary 'uptime,host=server value='$UPTIME''
But with telegraf, I am able to get the data injected, but I’m not able to find a very simple way to add a tag with hostname of the server.
[[inputs.snmp]]
agents = [ "server:161" ]
community = "public"
[[inputs.snmp.field]]
name = "uptime"
oid = "sysuptime"
I tried different configuration like this one :
[[inputs.snmp]]
agents = [ "server:161" ]
community = "public"
[[inputs.snmp.field]]
name = [ "uptime", "server" ]
oid = "sysuptime"
is_tag = true
There’s also the agent_host tag by default. (run telegraf with --test to see what’s actually collected)
You can also retrieve the hostname from the snmp device using this example:
[[inputs.snmp.field]]
oid = "RFC1213-MIB::sysUpTime.0"
name = "sysUptime"
conversion = "float(2)"
[[inputs.snmp.field]]
oid = "RFC1213-MIB::sysName.0"
name = "sysName"
is_tag = true
thank you !
Indeed this was a PEBKAC issue ! Sorry
I have a field agent_host which do the job :
select gpu_fan_speed,agent_host from “snmp” limit 10
side question : is there any good practice with regards on how to organize data within databases ?
currently my snmp database mix various data coming from snmp, could this be an issue some how ?
That’s why I said to use --test, then you see what metrics actually would be sent to InfluxDB.
It’s not really a database like you know ‘relational’ databases, it’s a ‘time series’ database; so you have a bucket, with metrics (in this case you name it snmp) which can have different tags and fields. There’s no big issue with that, depending on how you query your data afterwards.