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

plugin snmp not working ? #873

Closed
GuillaumeLohez opened this issue Mar 17, 2016 · 18 comments
Closed

plugin snmp not working ? #873

GuillaumeLohez opened this issue Mar 17, 2016 · 18 comments
Labels
bug unexpected problem or unintended behavior

Comments

@GuillaumeLohez
Copy link

Hi,

I'm using config with mapping and subtables as example 'iftable4':

[[inputs.snmp]]
  snmptranslate_file = "/tmp/oids.txt"
  [[inputs.snmp.host]]
    address = "127.0.0.1:161"
    community = "public" # default public
    version = 2 # default 2
    [[inputs.snmp.host.table]]
      name = "iftable4"
      include_instances = ["eth0"]

  [[inputs.snmp.table]]
    name = "iftable4"
    mapping_table = ".1.3.6.1.2.1.31.1.1.1.1"
    sub_tables=[".1.3.6.1.2.1.2.2.1.13", "bytes_recv", "bytes_send"]

  [[plugins.snmp.subtable]]
    name = "bytes_recv"
    oid = ".1.3.6.1.2.1.31.1.1.1.6"
    unit = "octets"

  [[plugins.snmp.subtable]]
    name = "bytes_send"
    oid = ".1.3.6.1.2.1.31.1.1.1.10"
    unit = "octets"

I have:

~# /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d/ -test -debug
* Plugin: snmp, Collection 1
2016/03/17 15:19:09 marshal: Unable to parse OID: strconv.ParseInt: parsing "bytes_recv": invalid syntax

snmp is working on localhost:

~# snmpwalk -v2c -c public localhost .1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo"
iso.3.6.1.2.1.31.1.1.1.1.2 = STRING: "eth0"

I have the issue with an existing ifname 'eth0' here. If I set a name which does not exist, it returns nothing but it doesn't crash.

I'm using latest available version: 0.11.1

Regards
Guillaume

@titilambert
Copy link
Contributor

@glz-io I will check this one by the end of the day

@GuillaumeLohez
Copy link
Author

Hi,

May I do a little "UP" ?

Seriously, did you have any time to check what's happen ?

@titilambert
Copy link
Contributor

@glz-io Sorry for the delay :/
I don't get an error :/ Could you create a gist with your /tmp/oids.txt file ?
Thanks !

@r0bj
Copy link

r0bj commented Mar 21, 2016

I have similar case.
Config file:

[[inputs.snmp]]
  snmptranslate_file = "/etc/telegraf/oids.txt"
  [[inputs.snmp.host]]
    address = "127.0.0.1:161"
    community = "public" # default public
    version = 2 # default 2
    collect = ["interface_speed", "if_number", "if_out_octets"]

  [[inputs.snmp.get]]
    name = "interface_speed"
    oid = "ifSpeed"
    instance = "1"

  [[inputs.snmp.get]]
    name = "if_number"
    oid = "ifNumber"

  [[inputs.snmp.bulk]]
    name = "if_out_octets"
    oid = "ifOutOctets"

/etc/telegraf/oids.txt:
https://gist.github.com/r0bj/7c66db559c86f37cc299

Error message:

* Plugin: snmp, Collection 1
2016/03/21 14:11:45 marshal: Unable to parse OID: strconv.ParseInt: parsing "ifSpeed": invalid syntax

@sparrc sparrc added the bug unexpected problem or unintended behavior label Mar 21, 2016
@GuillaumeLohez
Copy link
Author

Hi,

No problem, here is the file:
https://gist.github.com/glz-io/5f460f61dbd57cc6b539

@titilambert
Copy link
Contributor

@glz-io @r0bj Could you confirm that you have an output like this:

$GOPATH/bin/telegraf -config snmp.conf   -debug
2016/03/21 18:41:12 Attempting connection to output: graphite
2016/03/21 18:41:12 Successfully connected to output: graphite
2016/03/21 18:41:12 Starting Telegraf (version 0.11.1-28-g2207304)
2016/03/21 18:41:12 Loaded outputs: graphite
2016/03/21 18:41:12 Loaded inputs: snmp snmp
2016/03/21 18:41:12 Tags enabled: dc=denver-1 host=...

You should note that you have 2 snmp inputs ... This is the issue ...

@r0bj
Copy link

r0bj commented Mar 21, 2016

My output looks like this:

# telegraf -config /etc/telegraf/telegraf.conf -debug
2016/03/21 23:05:23 Attempting connection to output: influxdb
2016/03/21 23:05:24 Successfully connected to output: influxdb
2016/03/21 23:05:24 Starting Telegraf (version 0.11.1)
2016/03/21 23:05:24 Loaded outputs: influxdb
2016/03/21 23:05:24 Loaded inputs: snmp
2016/03/21 23:05:24 Tags enabled: dc=POZ env=dev host=dev-rob
2016/03/21 23:05:24 Agent Config: Interval:10s, Debug:true, Quiet:false, Hostname:"dev-rob", Flush Interval:16.357761645s
2016/03/21 23:05:30 Error in input [snmp]: marshal: Unable to parse OID: strconv.ParseInt: parsing "ifSpeed": invalid syntax

@titilambert
Copy link
Contributor

@r0bj Thanks !

@titilambert
Copy link
Contributor

@r0bj @glz-io In fact there are 2 bugs ! :D
I found and fix @r0bj 's one
I'm looking for the next one ...

titilambert added a commit to titilambert/telegraf that referenced this issue Mar 22, 2016
@titilambert
Copy link
Contributor

@glz-io I found it !
This is a documentation error ...
You don't have to use "plugins.snmp.subtable" but "inputs.snmp.subtable" ...
I will make a PR to fix it.

titilambert added a commit to titilambert/telegraf that referenced this issue Mar 22, 2016
@GuillaumeLohez
Copy link
Author

@titilambert Ok I do not have the error message after changing "plugins" to "inputs".

But it still does not work. Due to the other bug ?

@r0bj
Copy link

r0bj commented Mar 22, 2016

I also can't get any results:

[[inputs.snmp]]
  snmptranslate_file = "/etc/telegraf/oids.txt"
  [[inputs.snmp.host]]
    address = "127.0.0.1:161"
    community = "public" # default public

    version = 2 # default 2
    [[inputs.snmp.host.table]]
      name = "iftable4"
      include_instances = ["eth0", "eth1"]

  [[inputs.snmp.table]]
    name = "iftable4"
    mapping_table = ".1.3.6.1.2.1.31.1.1.1.1"
    sub_tables=[".1.3.6.1.2.1.2.2.1.13", "bytes_recv", "bytes_send"]

  [[inputs.snmp.subtable]]
    name = "bytes_recv"
    oid = ".1.3.6.1.2.1.31.1.1.1.6"
    unit = "octets"

  [[inputs.snmp.subtable]]
    name = "bytes_send"
    oid = ".1.3.6.1.2.1.31.1.1.1.10"
    unit = "octets"
snmpwalk -v2c -c public 127.0.0.1 .1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo"
iso.3.6.1.2.1.31.1.1.1.1.2 = STRING: "eth4"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "eth5"
iso.3.6.1.2.1.31.1.1.1.1.4 = STRING: "eth6"
iso.3.6.1.2.1.31.1.1.1.1.5 = STRING: "eth7"
iso.3.6.1.2.1.31.1.1.1.1.6 = STRING: "eth0"
iso.3.6.1.2.1.31.1.1.1.1.7 = STRING: "eth1"
iso.3.6.1.2.1.31.1.1.1.1.8 = STRING: "eth2"
iso.3.6.1.2.1.31.1.1.1.1.9 = STRING: "eth3"
iso.3.6.1.2.1.31.1.1.1.1.10 = STRING: "npi0"
iso.3.6.1.2.1.31.1.1.1.1.11 = STRING: "npi1"
iso.3.6.1.2.1.31.1.1.1.1.12 = STRING: "npi2"
iso.3.6.1.2.1.31.1.1.1.1.13 = STRING: "npi3"
iso.3.6.1.2.1.31.1.1.1.1.14 = STRING: "loop0"
iso.3.6.1.2.1.31.1.1.1.1.15 = STRING: "loop1"
iso.3.6.1.2.1.31.1.1.1.1.16 = STRING: "loop2"
iso.3.6.1.2.1.31.1.1.1.1.17 = STRING: "loop3"
iso.3.6.1.2.1.31.1.1.1.1.18 = STRING: "gre0"
iso.3.6.1.2.1.31.1.1.1.1.19 = STRING: "gretap0"
iso.3.6.1.2.1.31.1.1.1.1.20 = STRING: "tun6"
iso.3.6.1.2.1.31.1.1.1.1.21 = STRING: "tun1"
snmpwalk -v2c -c public 127.0.0.1 .1.3.6.1.2.1.31.1.1.1.6
iso.3.6.1.2.1.31.1.1.1.6.1 = Counter64: 72119
iso.3.6.1.2.1.31.1.1.1.6.2 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.3 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.4 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.5 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.6 = Counter64: 362174716162
iso.3.6.1.2.1.31.1.1.1.6.7 = Counter64: 7357144134
iso.3.6.1.2.1.31.1.1.1.6.8 = Counter64: 2142909858357
iso.3.6.1.2.1.31.1.1.1.6.9 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.10 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.11 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.12 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.13 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.14 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.15 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.16 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.17 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.18 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.19 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.6.20 = Counter64: 4057879
iso.3.6.1.2.1.31.1.1.1.6.21 = Counter64: 10255148
snmpwalk -v2c -c public 127.0.0.1 .1.3.6.1.2.1.31.1.1.1.10
iso.3.6.1.2.1.31.1.1.1.10.1 = Counter64: 72119
iso.3.6.1.2.1.31.1.1.1.10.2 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.3 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.4 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.5 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.6 = Counter64: 2143628340474
iso.3.6.1.2.1.31.1.1.1.10.7 = Counter64: 10201203029
iso.3.6.1.2.1.31.1.1.1.10.8 = Counter64: 345972782403
iso.3.6.1.2.1.31.1.1.1.10.9 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.10 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.11 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.12 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.13 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.14 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.15 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.16 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.17 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.18 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.19 = Counter64: 0
iso.3.6.1.2.1.31.1.1.1.10.20 = Counter64: 2907957
iso.3.6.1.2.1.31.1.1.1.10.21 = Counter64: 25028349

There is SNMP traffic to the telegraf:
https://gist.github.com/r0bj/2b1fc7aadbb98a95fb82

Result is empty:

telegraf -config /etc/telegraf/telegraf.conf -test
* Plugin: snmp, Collection 1

@GuillaumeLohez
Copy link
Author

I have exactly the same behavior.
snmpwalk is ok, I can see trafic with tcpdump by telegraf, but I have no result.

@titilambert
Copy link
Contributor

@glz-io @r0bj Try to replace all spaces by tabs in oids.txt file

cp oids.txt oids.txt.back
sed -s 's/ /\t/g' oids.txt

@GuillaumeLohez
Copy link
Author

@titilambert this is working !
Thx

But in fact, I've created oids.txt with the command in documentation.

@titilambert
Copy link
Contributor

@glz-io Yeah, this is the bug.. I fix a regex in the code... I don't know why I didn't see this error before ...

@GuillaumeLohez
Copy link
Author

I've seen the regexp change in the diff.

It seems fixed for me at the moment.

thx a lot.

titilambert added a commit to titilambert/telegraf that referenced this issue Mar 22, 2016
@r0bj
Copy link

r0bj commented Mar 22, 2016

@titilambert it's working now. Thanks!

titilambert added a commit to titilambert/telegraf that referenced this issue Mar 23, 2016
@sparrc sparrc closed this as completed in a95710e Mar 23, 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

4 participants