Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7184281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:10:02+00:00 2026-05-28T18:10:02+00:00

I am specifically trying to read data from an SNMP port in python using

  • 0

I am specifically trying to read data from an SNMP port in python using the PySNMP library. I am interested in getting data only through this library. This is because I am making a move from NetSNMP to PySNMP.

This is the working code I had for NetSNMP that actually gives me the data from the port

import netsnmp as snmp

infoSet = snmp.Varbind('1.3.6.1.2.1.123.1.7.1.1.0')
infoGet = snmp.snmpget(infoSet, Version = 1, DestHost = 'localhost', Community = "public")

print infoGet

These 3 lines of code return me the actual reading from that port and I am trying to get the same data from PySNMP and this is the code so far

from pysnmp.entity.rfc3413.oneliner import cmdgen

errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd(

cmdgen.CommunityData('my-agent', 'public', 0),
cmdgen.UdpTransportTarget(('localhost', 161)),
(1,3,6,1,2,1,1,1,0)
)

print varBinds[0][0]

This is printing the SNMP address and I am trying to get past this stage where I can get the actual reading for the port mentioned above and I am not sure how to. I am finding it hard to follow through the documentation.

Any help would be appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:10:03+00:00Added an answer on May 28, 2026 at 6:10 pm

    The varBinds is a list of tuples. Each tuple holds a OID-value pair.

    >>> print varBinds
    [(ObjectName(1.3.6.1.2.1.1.1.0), OctetString('Example Command Responder'))]
    >>> print varBinds[0]
    (ObjectName(1.3.6.1.2.1.1.1.0), OctetString('Example Command Responder'))
    >>> print varBinds[0][0]
    1.3.6.1.2.1.1.1.0
    >>> print varBinds[0][1]
    Example Command Responder
    

    So if all you need is a value, then

    >>> print varBinds[0][1]
    

    might help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a function call using the data I read from
I'm trying to read a file's id3v2 tag information using the TagLib# library with
I am trying to read a spreadsheet from app engine using text_db and authsub.
I'm trying to start using LINQ and specifically LINQ to SQL but I'm having
I am trying to scrape http://www.nscb.gov.ph/ggi/database.asp , specifically all the tables you get from
I'm trying to read-in a bunch of unsigned integers from a configuration file into
I'm trying to read and process lines from a file in Ruby. I have
I am trying to read attribute values from themes and styles which were designed
I am receiving a stream of data from a webservice and trying to save
I'm trying to parse data from stdin in binary mode under Win32. The first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.