Code Monkey home page Code Monkey logo

Comments (8)

soniah avatar soniah commented on May 18, 2024

👍

from gosnmp.

wdreeveii avatar wdreeveii commented on May 18, 2024

After a quick review of the source code, I was unable to locate a likely
source for this problem.

Do you think you could pin point where in the call graph this is blowing up?

On Mon, Apr 4, 2016 at 6:33 AM, Sonia Hamilton [email protected]
wrote:

[image: 👍]


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#61 (comment)

Whitham D. Reeve II
907-764-5263

from gosnmp.

toni-moreno avatar toni-moreno commented on May 18, 2024

Hi @wdreeveii ,@sonia. I've done all the test again , And the problem happens only with security level "NoAuthNoPriv" and"AuthNoPriv" .

With security level "AuthPriv" the code works ok.

You can see current code here:

https://github.com/toni-moreno/influxsnmp/tree/added_snmpv3_support

Here one example of snmpwalk with 2 host snmp version 2c and other with snmpv3 with security mode AuthPriv.

[snmp.hostsnmpv3c]
#conection parameters
host = "hostsnmpv3c"
port = 161
timeout = 20
retries = 5
repeat = 0
#snmp version /auth params
snmpversion = "3"
v3seclevel = "AuthPriv"
#only needed if Auth v3 enabled
v3authuser = "v3userpriv"
v3authpass = "v3passpriv"
v3authprot = "MD5"
#only needed if Privacy v3 enabled
v3privpass = "v3passenc"
v3privprot = "DES"

[root@lab01 influxsnmp]# ./influxsnmp -names

SNMP host: 127.0.0.1
=========================================
lo .1.3.6.1.2.1.31.1.1.1.1.1
eth0 .1.3.6.1.2.1.31.1.1.1.1.2

SNMP host: hostsnmpv2_2
=========================================
lo .1.3.6.1.2.1.31.1.1.1.1.1
eth0 .1.3.6.1.2.1.31.1.1.1.1.2

SNMP host: hostsnmpv3c
=========================================
2016/04/04 22:54:19 Selected SI Auth - Priv
lo .1.3.6.1.2.1.31.1.1.1.1.1
eth0 .1.3.6.1.2.1.31.1.1.1.1.2
sit0 .1.3.6.1.2.1.31.1.1.1.1.3

Here with AuthNoPriv example config

[snmp.hostsnmpv3b]
#conection parameters
host = "hostsnmpv3b"
port = 161
timeout = 20
retries = 5
repeat = 0
#snmp version /auth params
snmpversion = "3"
v3seclevel = "AuthNoPriv"
#only needed if Auth v3 enabled
v3authuser = "v3userauth"
v3authpass = "v3passauth"
v3authprot = "MD5"

Here the output.

[root@grafanalab01 influxsnmp]# ./influxsnmp -names -verbose
Looking up column names for: 127.0.0.1 NAMES 1.3.6.1.2.1.31.1.1.1.1
COLUMNS [ifHCInOctets ifHCInUcastPkts ifHCOutOctets ifHCOutUcastPkts]
[1.3.6.1.2.1.31.1.1.1.6 1.3.6.1.2.1.31.1.1.1.7 1.3.6.1.2.1.31.1.1.1.10 1.3.6.1.2.1.31.1.1.1.11]
Looking up column names for: hostsnmpv2_2 NAMES 1.3.6.1.2.1.31.1.1.1.1
COLUMNS [ifHCInOctets ifHCInUcastPkts ifHCOutOctets ifHCOutUcastPkts]
[1.3.6.1.2.1.31.1.1.1.6 1.3.6.1.2.1.31.1.1.1.7 1.3.6.1.2.1.31.1.1.1.10 1.3.6.1.2.1.31.1.1.1.11]
2016/04/04 23:02:51 Selected SI Auth - No Priv
Looking up column names for: hostsnmpv3b NAMES 1.3.6.1.2.1.31.1.1.1.1
2016/04/04 23:02:51 SNMP bulkwalk error recover: runtime error: integer divide by zero

I don't know any better way to debug the exact point where code does "divide by zero", I'm still a beginner in the goland world.
But snmpbulkwalk command is working with these parameters.

[root@grafanalab01 influxsnmp]# snmpwalk -v 3 -u v3userauth -l authNoPriv -a MD5 -A v3passauth  192.168.1.99 ifName
IF-MIB::ifName.1 = STRING: lo
IF-MIB::ifName.2 = STRING: eth0
IF-MIB::ifName.3 = STRING: sit0

What can I do? There is any way to get a stacktrace in a easy way? I have tested unsuccessfully with this lib https://github.com/go-errors/errors .

Do you know any other way?

from gosnmp.

wdreeveii avatar wdreeveii commented on May 18, 2024

I nailed down that the divide by zero error is caused by a mod on a password field that is only dealt with when the security level is set to authpriv. I couldn't figure out why that code was enabled when you were doing auth only requests until I looked at your code.

https://github.com/toni-moreno/influxsnmp/blob/added_snmpv3_support/snmp.go#L302

You only ever pass the security mode as AuthPriv. Naturally all communication will then get performed in the AuthPriv security level, even if you don't provide a password.

I think the real failure here on gosnmp's part is that these params were not validated for sanity up front. A situation I will soon remedy.

from gosnmp.

toni-moreno avatar toni-moreno commented on May 18, 2024

@wdreeveii Thank you very much !!! And sorry for this terrible mistake

I've solved it and , tested successfully with snmpv2 and snmpv3 with the 3 security Levels.

[root@lab01 influxsnmp]# ./influxsnmp -names

SNMP host: 127.0.0.1
=========================================
lo .1.3.6.1.2.1.31.1.1.1.1.1
eth0 .1.3.6.1.2.1.31.1.1.1.1.2

SNMP host: hostsnmpv2_2
=========================================
lo .1.3.6.1.2.1.31.1.1.1.1.1
eth0 .1.3.6.1.2.1.31.1.1.1.1.2

SNMP host: hostsnmpv3a
=========================================
lo .1.3.6.1.2.1.31.1.1.1.1.1
eth0 .1.3.6.1.2.1.31.1.1.1.1.2
sit0 .1.3.6.1.2.1.31.1.1.1.1.3

SNMP host: hostsnmpv3b
=========================================
lo .1.3.6.1.2.1.31.1.1.1.1.1
eth0 .1.3.6.1.2.1.31.1.1.1.1.2
sit0 .1.3.6.1.2.1.31.1.1.1.1.3

SNMP host: hostsnmpv3c
=========================================
lo .1.3.6.1.2.1.31.1.1.1.1.1
eth0 .1.3.6.1.2.1.31.1.1.1.1.2
sit0 .1.3.6.1.2.1.31.1.1.1.1.3

from gosnmp.

soniah avatar soniah commented on May 18, 2024

Thanks @toni-moreno

Reopened, as I imagine @wdreeveii is going to submit a patch :-)

from gosnmp.

soniah avatar soniah commented on May 18, 2024

@wdreeveii poke :-)

from gosnmp.

wdreeveii avatar wdreeveii commented on May 18, 2024

I have committed code to validate parameters so this cannot happen any more.

from gosnmp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.