SNMP Queries

I recently help someone out getting a monitor working that uses the System.SnmpQueryProvider module in the System.Snmp.Library management pack to perform a query against an SNMP device.  They were getting back an error message showing some cryptic characters in the community string.  They were just providing simple text like "public" for the CommunityString parameter on the module, so this looked pretty strange.

After some research, it turns out that module wants the community string specified in Base64 format.  Nothing special from the MP perspective – you just need to specify the Base64 equivalent of your community string in the CommunityString parameter rather than the simple text.

If you already have a means of converting a string to Base64, then you should be fine.  If not, here’s bit of PowerShell that will do the conversion for you.

 $communityString = 'public'
[System.Convert]::ToBase64String([System.Text.Encoding]::UNICODE.GetBytes($communityString))

If I run that code, I get the following value: cAB1AGIAbABpAGMA.  Pasting that into the CommunityString parameter on the module should get you the results you want.  Obviously, if you have a community name different than "public" you would paste that in and use the resulting converted value.

Comments

  • Anonymous
    January 01, 2003
    Courtesy of Brian Wren - http://blogs.technet.com/brianwren/archive/2009/01/21/snmp-queries.aspx

  • Anonymous
    January 01, 2003
    Hi Brian, For most of my SNMP rules and monitors I use the community name used when the device is discovered with the admin wizard.  So just use $Target/Property[Type="ND!Microsoft.SystemCenter.NetworkDevice"]/CommunityString$. But some devices have different community names for SNMP gets and traps.  So I can't use the target property for monitors using System.SnmpTrapProvider. I noticed that it is possible to create a Community String Run As Account in the Admin console but I can't workout how to use $RunAs with a MP SecureReference. Got any ideas?