enaiman Posted September 30, 2007 Share Posted September 30, 2007 Again asking for help ... I'm trying to get some MIB sections over an UDP connection (SNMP). The port used to connect to a device and to get some information using SNMP is 161. I've found many 3rd party MIB browsers and SNMP software but I would like to avoid using them and I wonder if it is possible to do it using UDP commands in AutoIt. If some1 have the knowledge and could help me in this matter I would really appreciate it. Thank you, SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
BrettF Posted October 1, 2007 Share Posted October 1, 2007 First step, see what we can recive? #include <GUIConstants.au3> $IP = "127.0.0.1" $hwnd = GUICreate ("MIB Data Viewer", 800, 600) $edit1 = GUICtrlCreateEdit ("", 0, 0, 800, 600) GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetColor ($edit1, 0xFFFFFF) UDPStartup() $socket = UDPBind($IP, 161) If @error <> 0 Then Exit GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg () $data = UDPRecv($socket, 256) If $data <> "" Then GUICtrlSetData ($edit1, GUICtrlRead ($edit1) & @CRLF & _ "------------------------------------------------------------------------------------------" & _ @CRLF & $data) EndIf Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() EndFunc Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
enaiman Posted October 1, 2007 Author Share Posted October 1, 2007 It looks like it doesn't work. Your code exits on $socket = UDPBind($IP, 161) If @error <> 0 Then Exit I've added a couple lines for debugging: If @error = 1 Then MsgBox(0, "error", "Incorrect IP") If @error = 2 Then MsgBox(0, "error", "Incorrect port") MsgBox(0, "error", @error) to see what's happening - the error returned was 10049 - so it is not a matter of wrong IP neither a wrong port (my switch IP is 192.168.0.20 and I've modified the script accordingly). Also tried to send a character to see if I receive something - the same result. I guess I'll have to look for an explanation for SNMP ... dunno if I can find something but I'll try. Thanks for help Bert, SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
ptrex Posted October 1, 2007 Share Posted October 1, 2007 (edited) @allMaybe this tool can get you started.SNMP ToolEDIT : Added commentsIn Windows there is a tied integration between SNMP and WMI. How to get started is like this :SNMP In WMIregardsptrex Edited October 1, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
enaiman Posted October 1, 2007 Author Share Posted October 1, 2007 Thanks Ptrex - the link to MSDN Library is awesome I've found many things about SNMP on the Internet but this is by far the most useful. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
ptrex Posted October 2, 2007 Share Posted October 2, 2007 @enaiman This should get you started reading the MIB files : $objLocator = ObjCreate("WbemScripting.SWbemLocator") $objServices = $objLocator.connectServer("", "root/snmp/localhost") $objNamedValueSet= ObjCreate("WbemScripting.SWbemNamedValueSet") $objNamedValueSet.Add ("AgentAddress", "localhost") $objNamedValueSet.Add ("AgentReadCommunityName", "public") $objNamedValueSet.Add ("AgentWriteCommunityName", "private") $class = "SNMP_RFC1213_MIB_system" $objSet = $objServices.instancesof( $class,Default,$objNamedValueSet) for $obj in $objset ConsoleWrite ( "-----------------------------" & @CRLF) for $prop in $obj.properties_ ConsoleWrite ( $prop.name & " : " & $prop.value & @CRLF) next next I hope it does get you going. If you have found what you are looking for, please post some example scritps in the Example section of the forum. This can help some more people when needed. regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
enaiman Posted October 2, 2007 Author Share Posted October 2, 2007 If you have found what you are looking for,please post some example scritps in the Example section of the forum.This can help some more people when needed.@ptrex Thank you very much for your help. Be sure that once I figure out what to do and I'll get a working script I'll post it there. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
skewltek Posted December 3, 2007 Share Posted December 3, 2007 First post here, I'm a MAJOR newbie. Has anyone created a solution for trapping SNMP in AutoIT? I'm just touching the surface of AutoIT and SNMP, and I need a little direction. I'm trying to create a script that would require a limited user to enter a hostname of a printer (IP Printing) and would then retrieve some basic info about the printer using SNMP (OIDs .1.3.6.1.2.1.1.1.0 [Printer model] and .1.3.6.1.2.1.1.6.0 [Description]) before setting up the printer for the user. I looked through the sample scripts but didn't find anything that satisfied my need. Thanks! Link to comment Share on other sites More sharing options...
ptrex Posted December 4, 2007 Share Posted December 4, 2007 (edited) @skewltekMaybe this can get you going :$wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $objLocator = ObjCreate("wbemscripting.swbemlocator") $objServices = $objLocator.ConnectServer(, "root\snmp\mngd_hub") $objServices.security_.privileges.AddAsString("SeSecurityPrivilege") $objSet = $objServices.ExecQuery ("SELECT * FROM SNMP_NET_DEVICE_123 WHERE hdwr_idx>1" , "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) for $obj in $objset ConsoleWrite( "do whatever ..." & @LF) Next ;---------------------- SNMP Action ------------------------ $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $objLocator = ObjCreate("wbemscripting.swbemlocator") $objServices = $objLocator.ConnectServer(, "root\snmp\mngd_hub") $objServices.security_.privileges.AddAsString("SeSecurityPrivilege") $obj= $objServices.Get("SNMP_NET_DEVICE_123=@") $obj.deviceLocation = "40/5073" $obj.put_It's not showing how to Monitor traps, but you will find examples on the net to do so.Anyhow this is a link on how to : WMI and SNMP monitoringBasically you need to map the SNMP TRAPS to the WMI EVENTS in order to get the ball rolling.Regards,ptrex Edited December 4, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
skewltek Posted December 5, 2007 Share Posted December 5, 2007 Thanks for your quick reply, ptrex. I think that the problem that I have is that I want user machines to be able to poll SNMP on thier computers, and most of them won't have the WMI SNMP service installed or started on thier machines. If there is not a way I can use the native TCP and/or UDP libraries in AutoIT for this then I will just use a third party command line app to retrieve what I need. Link to comment Share on other sites More sharing options...
ptrex Posted December 5, 2007 Share Posted December 5, 2007 @skewltek if you have a commandline tool that can do this. Let me know which one I might need it too. Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
skewltek Posted December 5, 2007 Share Posted December 5, 2007 if you have a commandline tool that can do this. Let me know which one I might need it too.There are a couple, one is in a Windows RK, it's called Snmputil.exe and it is pretty simple. Basically: Snmputil.exe get 10.0.212.2 public .1.3.6.1.2.1.1.6.0 >Variable = system.sysLocation.0 >Value = String Front Office The other is in an opensource package from http://www.net-snmp.org/ and it comes with several SNMP monitoring commandline tools. I haven't played with it enough to know what it can do, but it looks pretty extensive. So are you confirming that AutoIT doesn't have a way built into it that can perform SNMP traps, and that it relies on an outside source (either WMI or a commandline tool like one here) to handle that? I just want to make sure before I spend any more time searching in vain and start researching how to parse commandline output in AutoIT. Thanks for you're help. 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