SNMP ifSpeed

Discussion in 'Mac Programming' started by Spike099, Nov 15, 2010.

  1. macrumors regular

    #1
    Hey Guys,

    I'm not all that familiar with SNMP. However I know it can be used to get the current bandwidth utilization using "ifSpeed".

    First off, I'm not certain how to obtain the MIB tree. snmpwalk returns the following:

    Code:
    > snmpwalk -v1 -c public localhost
    SNMPv2-MIB::sysContact.0 = STRING: Administrator <postmaster@example.com>
    End of MIB
    This doesn't look right does it? Is my MIB incomplete?

    When I start SNMP I get some config errors. However its the default config!

    Code:
    > snmpd -L
    Couldn't find a table entry for the model name MacBook5,1
    Sensor Data Collection not supported
    Error opening specified endpoint ""
    Server Exiting with code 1
    I've been playing with the config file, this is what it looks like now.

    Code:
    ###########################################################################
    #
    # snmpd.conf
    #
    # - created by the snmpconf configuration program
    #
    ###########################################################################
    # SECTION: Access Control Setup
    #
    # This section defines who is allowed to talk to your running
    # snmp agent.
    
    # rouser: a SNMPv3 read-only user
    # arguments: user [noauth|auth|priv] [restriction_oid]
    
    rouser public auth
    
    # rocommunity: a SNMPv1/SNMPv2c read-only access community name
    # arguments: community [default|hostname|network/bits] [oid]
    
    rocommunity public localhost/32
    
    ###############################################################################
    # Access Control
    ###############################################################################
    
    # As shipped, the snmpd demon will only respond to queries on the
    # system mib group until this file is replaced or modified for
    # security purposes. Examples are shown below about how to increase the
    # level of access.
    
    # By far, the most common question I get about the agent is "why won't
    # it work?", when really it should be "how do I configure the agent to
    # allow me to access it?"
    #
    # By default, the agent responds to the "public" community for read
    # only access, if run out of the box without any configuration file in 
    # place. The following examples show you other ways of configuring
    # the agent so that you can change the community names, and give
    # yourself write access to the mib tree as well.
    #
    # For more information, read the FAQ as well as the snmpd.conf(5)
    # manual page.
    
    ####
    # First, map the community name "public" into a "security name"
    
    # sec.name source community
    # com2sec notConfigUser	default public
    
    com2sec notConfigUser	localhost/32 public
    
    ####
    # Second, map the security name into a group name:
    
    # groupName securityModel securityName
    group notConfigGroup v1 notConfigUser
    group notConfigGroup v2c notConfigUser
    
    ####
    # Third, create a view for us to let the group have rights to:
    
    # Make at least snmpwalk -v 1 localhost -c public system fast again.
    # name incl/excl subtree mask(optional)
    view systemview included .1.3.6.1.2.1.1
    view systemview included .1.3.6.1.2.1.25.1.1
    
    ####
    # Finally, grant the group read-only access to the systemview view.
    
    # group context sec.model sec.level prefix read write notif
    access notConfigGroup "" any noauth exact systemview none none
    
    ###########################################################################
    # SECTION: System Information Setup
    #
    # This section defines some of the information reported in
    # the "system" mib group in the mibII tree.
    
    # syslocation: The [typically physical] location of the system.
    # Note that setting this value here means that when trying to
    # perform an snmp SET operation to the sysLocation.0 variable will make
    # the agent return the "notWritable" error code. IE, including
    # this token in the snmpd.conf file will disable write access to
    # the variable.
    # arguments: location_string
    
    syslocation work
    
    # syscontact: The contact information for the administrator
    # Note that setting this value here means that when trying to
    # perform an snmp SET operation to the sysContact.0 variable will make
    # the agent return the "notWritable" error code. IE, including
    # this token in the snmpd.conf file will disable write access to
    # the variable.
    # arguments: contact_string
    
    syscontact test@test.com
    
    I'm running OS X 10.6.4.

    Any help would be greatly appreciated, thanks!
     
  2. macrumors regular

    #2
    Og I got it!

    Ok, I solved it.

    I changed back to the default config and made the following changes

    from
    com2sec local localhost COMMUNITY
    to
    com2sec local localhost public

    from
    rocommunity public default .1.3.6.1.2.1.1.4
    to
    #rocommunity public default .1.3.6.1.2.1.1.4

    I should change this as it's probably a security issue that i am opening the public to view all snmp info. But at the moment I just want to see the list.
     

Share This Page