Hi, maybe someone can help with this.
When doing snmptable I can get value for CardLicEndDateTime
CardLicEndDateTime
2020-10-3,23:59:59.0,+0:0
When testing with: telegraf --test --config /etc/telegraf/telegraf.d/licence.conf I get strange value back
CardLicEndDateTime=“▒;;+” = strange value
Telegraf config:
[[inputs.snmp.field]]
name = “hostname”
oid = “SNMPv2-MIB::sysName.0”
is_tag = true
[[inputs.snmp.table]]
oid = “XXXX-SYSTEM-MIB::CardLicenseTable”
inherit_tags = [“hostname”]
index_as_tag = true
Is there is way to get date and time??
Thanks!
I’ve never used that plugin, but just forcing a conversion to string type might solve the problem.
have a look at the converter processor
[[processors.converter]]
#if tag
[processors.converter.tags]
string = ["CardLicEndDateTime"]
##if field
[processors.converter.fields]
string = ["CardLicEndDateTime"]
Updated config and now it looks:
[[inputs.snmp.field]]
name = “hostname”
oid = “SNMPv2-MIB::sysName.0”
is_tag = true
[[inputs.snmp.table]]
name = “CardLicenseTable”
inherit_tags = [“hostname”]
index_as_tag = true
[[inputs.snmp.table.field]]
oid = “XXXX::CardLicEndDateTime”
[[processors.converter]]
[processors.converter.fields]
string = [“CardLicEndDateTime”]
But no changes, result CpmCardLicEndDateTime=“▒;;+”
Any suggestions what could be wrong?
Thanks!
Just look at the snmp docs.
if not specified, the name of the field is the same value you have in the “oid”, that might explain why you the value is not converted.
if the result you posted is exact CpmCardLicEndDateTime=“▒;;+”
, the field key is CpmCardLicEndDateTime, not CardLicEndDateTime, so obviously no match is found and no conversion made.
Possible solutions are:
## Solution 1 - Specify the name of the field
{...}
[[inputs.snmp.table.field]]
oid = "XXXX::CardLicEndDateTime"
name = "CardLicEndDateTime"
{...}
## Solution 2 - use a string pattern in the converter
{...}
[[processors.converter]]
[processors.converter.fields]
string = ["*CardLicEndDateTime"]