Search the Community
Showing results for tags 'enaiman'.
-
Hi. To read the counters of a subset of our printers I wrote this code, using this UDF of enaiman: for the first value it's working fine, for the 2nd vaule the UDP:161 packet is never sent. I've already tried to do a UDPStartup() and UDPShutdown() for each and every value inside the "$x = 1 to ..." loop, no change. xerox.au3 #include <array.au3> #include <date.au3> #include 'SNMP_UDF_v1.7.3.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 If Not @Compiled Then Opt("trayicondebug", 1) $ini = StringTrimRight(@ScriptName, 3) & "ini" $sect = "Drucker" $aDrucker = IniReadSection($ini, $sect) $Ergebnis = "Zählerstände der Xerox Drucker von: " & _NowCalc() & @CRLF ; UDPStartup() --> moved inside "for $x = 1 to ..." loop: no change For $i = 1 To $aDrucker[0][0] $IP = $aDrucker[$i][0] ConsoleWrite($IP & @LF) ConsoleWrite($aDrucker[$i][1] & @LF) $Ergebnis &= $aDrucker[$i][1] $OIDsect = $aDrucker[$i][1] $OIDsect = StringTrimLeft($OIDsect, (StringInStr($OIDsect, " ", 0, -1))) $aOID = IniReadSection($ini, $OIDsect) For $x = 1 To $aOID[0][0] UDPStartup() $Socket = UDPOpen($aDrucker[$i][0], $Port) $SNMP_Command = _SNMPBuildPacket($aOID[$x][1], $SNMP_Community, $SNMP_Version, $SNMP_ReqID, "A0") UDPSend($Socket, $SNMP_Command) _StartListener() Sleep(200) $Ergebnis &= @TAB & $aOID[$x][0] & @TAB & $SNMP_Util[1][1] & @CRLF _ArrayDisplay($SNMP_Util, $aDrucker & ", " & $x) ConsoleWrite($aOID[$x][0] & ", " & $aOID[$x][1] & " = " & $SNMP_Util[1][1] & @LF) UDPCloseSocket($Socket) UDPShutdown() Sleep(200) Next Next ; UDPShutdown() ConsoleWrite($Ergebnis & @LF) Func _StartListener() If $Start = 1 Then $i = 0 While (1) $srcv = UDPRecv($Socket, 2048) If ($srcv <> "") Then $result = _ShowSNMPReceived($srcv) ConsoleWrite("received: " & $srcv & @CRLF) ;_ArrayDisplay($result) ExitLoop EndIf Sleep(100) WEnd EndIf EndFunc ;==>_StartListener Func OnAutoItExit() UDPCloseSocket($Socket) UDPShutdown() EndFunc ;==>OnAutoItExit the ini used: xerox.ini [drucker] 10.27.50.34=Doku Xerox-7525 10.27.50.38=AV Xerox-7232 10.27.50.39=Vertieb1 Xerox-7232 10.27.50.40=TBE Xerox-7232 10.27.50.41=Verwaltung Xerox-7232 10.27.50.43=AV Xerox-7435 10.27.50.44=TBE Xerox-7435 ; .... [Xerox-7232] Total=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.1 bw=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.34 color=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.33 [Xerox-7435] total=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.1 bw=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.34 color=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.33 oversize total=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.47 oversize BW=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.44 oversize color=1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.43 ; ..... Wireshark traces show, that the SNMP request for the 2nd value is never sent. console output: 10.27.50.34 Doku Xerox-7525 0x303002010104067075626C6963A023020200010201000201003017301506102B06010401817D08350D020106011401050100 received: 0x303002010104067075626C6963A2230201010201000201003018301606102B06010401817D08350D020106011401020211C1 Gesamt, 1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.1 = 4545 0x303002010104067075626C6963A023020200010201000201003017301506102B06010401817D08350D020106011422050100 What do I miss? Regards, Rudi. <edit: topic tags, added author's name of the UDF (enaiman)> <edit2: topic text>