Kyan Posted March 18, 2015 Share Posted March 18, 2015 (edited) Sorry for posting this here, the other board is being spam by some jerk so I'm posting this here temporarily I'm trying to retrieve a snmp output from my router, I can do it using "snmpwalk 5.7.0" and "MIB Browser", so is not a problem with router configuration. expandcollapse popup#include "snmp_UDF-v1.7.4.au3" Global $Port = 161 ; UDP 161 = SNMP port Global $SNMP_Version = 2 ; SNMP v2c (1 for SNMP v1) Global $SNMP_Community = "public" ; SNMPString(Community) (change it) Global $SNMP_ReqID = 1 Global $SNMP_Command Global $Start = 1 Global $result Global $Timeout_msec = 2500 UDPStartup() $Socket = UDPOpen('192.168.1.1', $Port) $SNMP_Command = _SNMPBuildPacket('.1.3.6.1.2.1.1.5', $SNMP_Community, $SNMP_Version, $SNMP_ReqID, "A0") UDPSend($Socket, $SNMP_Command) _StartListener() Sleep(200) UDPCloseSocket($Socket) UDPShutdown() Sleep(200) Exit Func _StartListener() If $Start = 1 Then $Timeout = TimerInit() While (1) $srcv = UDPRecv($Socket, 1200) If ($srcv <> "") Then $result = _ShowSNMPReceived($srcv) ConsoleWrite("received: " & $srcv &@LF) ;_ArrayDisplay($result) ExitLoop EndIf Sleep(100) If TimerDiff($Timeout) > $Timeout_msec Then ExitLoop EndIf WEnd EndIf EndFunc ;==>_StartListener Func OnAutoItExit() UDPCloseSocket($Socket) UDPShutdown() EndFunc ;==>OnAutoItExit Request oid: .1.3.6.1.2.1.1.5 Expected result: TP-LINK Received: 0x3082002E02010104067075626C6963A282001F020101020100020100308200123082000E060A2B0001030601020101058000 [ascii: 0‚.public¢‚0‚0‚ +€] what am I doing wrong here? There's other cleaner way of doing this, like _snmpGet(server,comunity, oid)? thanks for your time EDIT: So, there's an output when I use "A1" parameter (but not the correct one), but with A0 I returns 0 or something like that Edited March 18, 2015 by Kyan Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Kyan Posted March 18, 2015 Author Share Posted March 18, 2015 (edited) Was using the OID with a dot in the beginning, snmp udf doesn't like it. How do I interpret this: 0‚3public¢‚$0‚0‚+TP-LINK Looks random the way is made, everything between commas, but why "+" before the normal output? EDIT: There's a _ShowSNMPReceived() function for it *facepalm*, that's what I get for doing this sleepy. Now I have another problem, how do I receive bulk requests, in snmpwalk I just need to make the OID "less specific" but with this UDF I'm not seeing how to do it. Edited March 18, 2015 by Kyan Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Kyan Posted March 19, 2015 Author Share Posted March 19, 2015 BUMP Anyway I can get the subtree using _SNMPBuildPacket() in bulk? Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now