Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMP - problems with emtpy string #1835

Closed
grisu-cl opened this issue Oct 1, 2016 · 3 comments
Closed

SNMP - problems with emtpy string #1835

grisu-cl opened this issue Oct 1, 2016 · 3 comments
Labels
bug unexpected problem or unintended behavior

Comments

@grisu-cl
Copy link

grisu-cl commented Oct 1, 2016

Bug report

Hi,
i am querying interfaces from a switch and i set the ifAlias as tag
If ifAlias is empty no tag added

so far so good,
but sometime a get the ifAlias added with an empty string

it seems like (given that ifAlias is empty) :

  • using inputs.snmp.fields i always get the empty tag
  • using inputs.snmp.table i only get an empty tag if it is the last return-value of the bulk-response
  • as a cross-check: setting max_repetitions = 1 i always get the empty tag added

Relevant telegraf.conf:

[[inputs.snmp]]
  max_repetitions = 50

  [[inputs.snmp.table]]
    name = "interface"
    [[inputs.snmp.table.field]]
      name = "ifName"
      oid = ".1.3.6.1.2.1.31.1.1.1.1"
      is_tag = true
   [[inputs.snmp.table.field]]
      name = "ifAlias"
      oid = ".1.3.6.1.2.1.31.1.1.1.18"
      is_tag = true
   [[inputs.snmp.table.field]]
      name = "ifHCInOctets"
      oid = ".1.3.6.1.2.1.31.1.1.1.6"

and for another test:

[[inputs.snmp.field]]
   name = "ifAlias"
   oid = ".1.3.6.1.2.1.31.1.1.1.18.10"
   is_tag = true
[[inputs.snmp.field]]
   name = "ifHCInOctets"
   oid = ".1.3.6.1.2.1.31.1.1.1.6.10"


System info:

Telegraf - version 1.0.0
CentOS Linux release 7.2.1511

Expected behavior:

if ifAlias is empty no tag should be added

Actual behavior:

sometimes the tag is added - with an empty string

Additional info:

empty ifAlias means a null-string

00008040  6f 6e 32 38 76 2c 69 66  41 6c 69 61 73 3d 00 2c  |on28v,ifAlias=.,|
00008050  69 66 4e 61 6d 65 3d 67  31 30 20 69 66 48 43 49  |ifName=g10 ifHCI|
00008060  6e 4f 63 74 65 74 73 3d  30 69 20 31 34 37 35 33  |nOctets=0i 14753|
00008070  35 34 32 31 30 30 30 30  30 30 30 30 30 30 0a     |54210000000000.|

single-request looks like:
test,agent_host=vie-sw4,host=phoron28v,ifAlias=,ifName=g10 ifHCInOctets=0i 1475354210000000000

with a bulk request it looks like:

nterface,agent_host=vie-sw4,host=phoron28v,ifName=g46 ifHCInOctets=1204381399i 1475354051000000000                                         
interface,agent_host=vie-sw4,host=phoron28v,ifName=ch8 ifHCInOctets=0i 1475354051000000000                                                  
interface,agent_host=vie-sw4,host=phoron28v,ifName=g9 ifHCInOctets=0i 1475354051000000000                                                   
interface,agent_host=vie-sw4,host=phoron28v,ifName=g39 ifHCInOctets=23785986308i 1475354051000000000                                        
interface,agent_host=vie-sw4,host=phoron28v,ifAlias=,ifName=g25 ifHCInOctets=0i 1475354051000000000                                       
interface,agent_host=vie-sw4,host=phoron28v,ifAlias=uplink-switch1,ifName=g47 ifHCInOctets=30828034462116i 1475354051000000000   
@sparrc sparrc added the bug unexpected problem or unintended behavior label Oct 2, 2016
@phemmer
Copy link
Contributor

phemmer commented Oct 3, 2016

I cant see anything in the snmp code which might cause this. I suspect it's an issue with the underlying gosnmp library.
However I might argue that the empty tag is the right behavior. If the snmp agent returns an empty string, then telegraf should also report empty string. Only if the snmp agent reports no such object should we omit it.

Now I might not be opposed to an option to control the behavior. But not sure.

@grisu-cl
Copy link
Author

grisu-cl commented Oct 4, 2016

hi,
sorry for my late response,

seems that there is still a fix in gosnmp
gosnmp/gosnmp@3fe3beb fixes the issue with the null-string
after recompiling telegraf with (at least) that version everything works as expected

thanks

@phemmer
Copy link
Contributor

phemmer commented Oct 4, 2016

I'll create another PR to update gosnmp.

jackzampolin pushed a commit that referenced this issue Oct 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants