顯示具有 snmp 標籤的文章。 顯示所有文章
顯示具有 snmp 標籤的文章。 顯示所有文章

2017年5月11日 星期四

[C][example code] snmp get


Makefile
#
# Warning: you may need more libraries than are included here on the
# build line.  The agent frequently needs various libraries in order
# to compile pieces of it, but is OS dependent and we can't list all
# the combinations here.  Instead, look at the libraries that were
# used when linking the snmpd master agent and copy those to this
# file.
#

CC=gcc

OBJS1=snmpdemoapp.o
OBJS2=example-demon.o nstAgentSubagentObject.o
OBJS3=asyncapp.o
TARGETS=example-demon snmpdemoapp asyncapp

CFLAGS=-I. `net-snmp-config --cflags`
BUILDLIBS=`net-snmp-config --libs`
BUILDAGENTLIBS=`net-snmp-config --agent-libs`

# shared library flags (assumes gcc)
DLFLAGS=-fPIC -shared

all: $(TARGETS)

snmpdemoapp: $(OBJS1)
    $(CC) -o snmpdemoapp $(OBJS1) $(BUILDLIBS)

asyncapp: $(OBJS3)
    $(CC) -o asyncapp $(OBJS3) $(BUILDLIBS)

example-demon: $(OBJS2)
    $(CC) -o example-demon $(OBJS2)  $(BUILDAGENTLIBS)

clean:
    rm $(OBJS2) $(OBJS2) $(TARGETS)

nstAgentPluginObject.so: nstAgentPluginObject.c Makefile
    $(CC) $(CFLAGS) $(DLFLAGS) -c -o nstAgentPluginObject.o nstAgentPluginObject.c
    $(CC) $(CFLAGS) $(DLFLAGS) -o nstAgentPluginObject.so nstAgentPluginObject.o


C code
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <string.h>

/* change the word "define" to "undef" to try the (insecure) SNMPv1 version */
#define DEMO_USE_SNMP_VERSION_3

#ifdef DEMO_USE_SNMP_VERSION_3
const char *our_v3_passphrase = "The Net-SNMP Demo Password";
#endif

int main(int argc, char ** argv)
{
    netsnmp_session session, *ss;
    netsnmp_pdu *pdu;
    netsnmp_pdu *response;

    oid anOID[MAX_OID_LEN];
    size_t anOID_len;

    netsnmp_variable_list *vars;
    int status;
    int count=1;

    /*
     * Initialize the SNMP library
     */
    init_snmp("snmpdemoapp");

    /*
     * Initialize a "session" that defines who we're going to talk to
     */
    snmp_sess_init( &session );                   /* set up defaults */
    session.peername = strdup("test.net-snmp.org");  /* Remote IP Address */

    /* set up the authentication parameters for talking to the server */

#ifdef DEMO_USE_SNMP_VERSION_3

    /* Use SNMPv3 to talk to the experimental server */

    /* set the SNMP version number */
    session.version=SNMP_VERSION_3;

    /* set the SNMPv3 user name */
    session.securityName = strdup("MD5User");
    session.securityNameLen = strlen(session.securityName);

    /* set the security level to authenticated, but not encrypted */
    session.securityLevel = SNMP_SEC_LEVEL_AUTHNOPRIV;

    /* set the authentication method to MD5 */
    session.securityAuthProto = usmHMACMD5AuthProtocol;
    session.securityAuthProtoLen = sizeof(usmHMACMD5AuthProtocol)/sizeof(oid);
    session.securityAuthKeyLen = USM_AUTH_KU_LEN;

    /* set the authentication key to a MD5 hashed version of our
       passphrase "The Net-SNMP Demo Password" (which must be at least 8
       characters long) */
    if (generate_Ku(session.securityAuthProto,
                    session.securityAuthProtoLen,
                    (u_char *) our_v3_passphrase, strlen(our_v3_passphrase),
                    session.securityAuthKey,
                    &session.securityAuthKeyLen) != SNMPERR_SUCCESS) {
        snmp_perror(argv[0]);
        snmp_log(LOG_ERR,
                 "Error generating Ku from authentication pass phrase. \n");
        exit(1);
    }

#else /* we'll use the insecure (but simplier) SNMPv1 */

    /* set the SNMP version number */
    session.version = SNMP_VERSION_1;

    /* set the SNMPv1 community name used for authentication */
    session.community = "demopublic";
    session.community_len = strlen(session.community);

#endif /* SNMPv1 */

    /*
     * Open the session
     */
    SOCK_STARTUP;
    ss = snmp_open(&session);                     /* establish the session */

    if (!ss) {
      snmp_sess_perror("ack", &session);
      SOCK_CLEANUP;
      exit(1);
    }

    /*
     * Create the PDU for the data for our request.
     *   1) We're going to GET the system.sysDescr.0 node.
     */
    pdu = snmp_pdu_create(SNMP_MSG_GET);
    anOID_len = MAX_OID_LEN;
    if (!snmp_parse_oid(".1.3.6.1.2.1.1.1.0", anOID, &anOID_len)) {
      snmp_perror(".1.3.6.1.2.1.1.1.0");
      SOCK_CLEANUP;
      exit(1);
    }
#if OTHER_METHODS
    /*
     *  These are alternatives to the 'snmp_parse_oid' call above,
     *    e.g. specifying the OID by name rather than numerically.
     */
    read_objid(".1.3.6.1.2.1.1.1.0", anOID, &anOID_len);
    get_node("sysDescr.0", anOID, &anOID_len);
    read_objid("system.sysDescr.0", anOID, &anOID_len);
#endif

    snmp_add_null_var(pdu, anOID, anOID_len);

    /*
     * Send the Request out.
     */
    status = snmp_synch_response(ss, pdu, &response);

    /*
     * Process the response.
     */
    if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR) {
      /*
       * SUCCESS: Print the result variables
       */

      for(vars = response->variables; vars; vars = vars->next_variable)
        print_variable(vars->name, vars->name_length, vars);

      /* manipuate the information ourselves */
      for(vars = response->variables; vars; vars = vars->next_variable) {
        if (vars->type == ASN_OCTET_STR) {
      char *sp = (char *)malloc(1 + vars->val_len);
      memcpy(sp, vars->val.string, vars->val_len);
      sp[vars->val_len] = '\0';
          printf("value #%d is a string: %s\n", count++, sp);
      free(sp);
    }
        else
          printf("value #%d is NOT a string! Ack!\n", count++);
      }
    } else {
      /*
       * FAILURE: print what went wrong!
       */

      if (status == STAT_SUCCESS)
        fprintf(stderr, "Error in packet\nReason: %s\n",
                snmp_errstring(response->errstat));
      else if (status == STAT_TIMEOUT)
        fprintf(stderr, "Timeout: No response from %s.\n",
                session.peername);
      else
        snmp_sess_perror("snmpdemoapp", ss);

    }

    /*
     * Clean up:
     *  1) free the response.
     *  2) close the session.
     */
    if (response)
      snmp_free_pdu(response);
    snmp_close(ss);

    SOCK_CLEANUP;
    return (0);
} /* main() */


Compile command as following:
[happy@localhost 3]$ make snmpdemoapp
gcc -I. net-snmp-config --cflags -c -o snmpdemoapp.o snmpdemoapp.c
gcc -o snmpdemoapp snmpdemoapp.o net-snmp-config --libs


Execute command as following:
[happy@localhost 3]$ ./snmpdemoapp
SNMPv2-MIB::sysDescr.0 = STRING: test.net-snmp.org
value #1 is a string: test.net-snmp.org


Reference:

2015年12月23日 星期三

2015年12月21日 星期一

2014年12月2日 星期二

[SNMP][JAVA][Open Source] How to compile mibble

[SNMP][JAVA][Open Source] How to compile mibble

Install compiler tool in ubuntu 14.04
sudo apt-get install ant
sudo apt-get install openjdk-7-jdk

Under mibble-2.9.3 then run
ant -buildfile build.xml

... 

doc-html:                                                                                                                                                                  [0/1956]
     [copy] Copying 1 file to /home/freeman/Downloads/mibble-2.9.3/doc
     [xslt] Transforming into /home/freeman/Downloads/mibble-2.9.3/doc
     [xslt] Processing /home/freeman/Downloads/mibble-2.9.3/src/doc/release/authors.xml to /home/freeman/Downloads/mibble-2.9.3/doc/authors.html
     [xslt] Loading stylesheet /home/freeman/Downloads/mibble-2.9.3/src/doc/html.xsl
     [xslt] Warning:  org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
     [xslt] Warning:  org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser: Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized.
     [xslt] Processing /home/freeman/Downloads/mibble-2.9.3/src/doc/release/bugs.xml to /home/freeman/Downloads/mibble-2.9.3/doc/bugs.html
     [xslt] Processing /home/freeman/Downloads/mibble-2.9.3/src/doc/release/features.xml to /home/freeman/Downloads/mibble-2.9.3/doc/features.html
     [xslt] Processing /home/freeman/Downloads/mibble-2.9.3/src/doc/release/index.xml to /home/freeman/Downloads/mibble-2.9.3/doc/index.html
     [xslt] Processing /home/freeman/Downloads/mibble-2.9.3/src/doc/release/install.xml to /home/freeman/Downloads/mibble-2.9.3/doc/install.html
     [xslt] Processing /home/freeman/Downloads/mibble-2.9.3/src/doc/release/version.xml to /home/freeman/Downloads/mibble-2.9.3/doc/version.html

doc-java:
  [javadoc] Generating Javadoc
  [javadoc] Javadoc execution
  [javadoc] Loading source files for package net.percederberg.mibble...
  [javadoc] Loading source files for package net.percederberg.mibble.snmp...
  [javadoc] Loading source files for package net.percederberg.mibble.type...
  [javadoc] Loading source files for package net.percederberg.mibble.value...
  [javadoc] Constructing Javadoc information...
  [javadoc] Standard Doclet version 1.7.0_65
  [javadoc] Building tree for all the packages and classes...
  [javadoc] Building index for all the packages and classes...
  [javadoc] Building index for all classes...

doc:

all:

BUILD SUCCESSFUL
Total time: 22 seconds

Compile specific function
ant -buildfile build.xml doc-html

Buildfile: /home/freeman/Downloads/mibble-2.9.3/build.xml

doc-html:
     [xslt] Transforming into /home/freeman/Downloads/mibble-2.9.3/doc

BUILD SUCCESSFUL
Total time: 0 seconds

Reference :
1. mibble :: MIB Parser

[Snmp][JAVA][Open Source] usage - mibble


bash ./bin/MibbleValidator.sh /home/happy/Desktop/ubeeWifi4all-v0.1.mib 
Using environment variables:
  MIBBLE_HOME = .
  JAVA        = /usr/bin/java
  CLASSPATH   = ./lib/mibble-parser-2.9.3.jar:./lib/mibble-mibs-2.9.3.jar:./lib/snmp6_0.jar

0/1: Reading /home/happy/Desktop/ubeeWifi4all-v0.1.mib... [OK]

Files processed:  1
  with errors:    0
  with warnings:  0
bash ./bin/MibblePrinter.sh  --debug /home/freeman/Desktop/ubeeWifi4all-v0.1.mib 
Using environment variables:
  MIBBLE_HOME = .
  JAVA        = /usr/bin/java
  CLASSPATH   = ./lib/mibble-parser-2.9.3.jar:./lib/mibble-mibs-2.9.3.jar:./lib/snmp6_0.jar

VALUE vcm [UNIVERSAL 6] OBJECT IDENTIFIER
    ::= 1.3.6.1.4.1.4684.37

VALUE ubeeWifi4allMib MODULE-IDENTITY (
  Last Updated: 201212100000Z
  Organization: Ubee Interactive
  Contact Info: web site: http://www.ubeeinteractive.com/
  Description: This MIB module supplies the basic management objects for WiFi4All.
)
    ::= 1.3.6.1.4.1.4684.37.4

VALUE ubeeWifi4allMibObjects [UNIVERSAL 6] OBJECT IDENTIFIER
    ::= 1.3.6.1.4.1.4684.37.4.1

VALUE ubeeWifi4allTable OBJECT-TYPE (
  Syntax: [UNIVERSAL 16] SEQUENCE OF [UNIVERSAL 16] SEQUENCE [ubeeWifi4allIndex [UNIVERSAL 2] INTEGER, ubeeWifi4allSSIDName [UNIVERSAL 4] OCTET STRING, ubeeWifi4allStatus [UNIVERSAL 2] INTEGER, ubeeWifi4allSecurityMode [UNIVERSAL 2] INTEGER, ubeeWifi4allMACAddress [UNIVERSAL 4] OCTET STRING, ubeeWifi4allFrequencyBand [UNIVERSAL 2] INTEGER, ubeeWifi4allOperatingMode [UNIVERSAL 4] OCTET STRING, ubeeWifi4allChannelBandwidth [UNIVERSAL 2] INTEGER, ubeeWifi4allOperatingChannel [APPLICATION 2] INTEGER (0..4294967295), ubeeWifi4allNumOfConnectedDevices [APPLICATION 2] INTEGER (0..4294967295)]
  Access: not-accessible
  Status: current
  Description: This table presents WiFi4All network information.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1

VALUE ubeeWifi4allEntry OBJECT-TYPE (
  Syntax: [UNIVERSAL 16] SEQUENCE [ubeeWifi4allIndex [UNIVERSAL 2] INTEGER, ubeeWifi4allSSIDName [UNIVERSAL 4] OCTET STRING, ubeeWifi4allStatus [UNIVERSAL 2] INTEGER, ubeeWifi4allSecurityMode [UNIVERSAL 2] INTEGER, ubeeWifi4allMACAddress [UNIVERSAL 4] OCTET STRING, ubeeWifi4allFrequencyBand [UNIVERSAL 2] INTEGER, ubeeWifi4allOperatingMode [UNIVERSAL 4] OCTET STRING, ubeeWifi4allChannelBandwidth [UNIVERSAL 2] INTEGER, ubeeWifi4allOperatingChannel [APPLICATION 2] INTEGER (0..4294967295), ubeeWifi4allNumOfConnectedDevices [APPLICATION 2] INTEGER (0..4294967295)]
  Access: not-accessible
  Status: current
  Description: List of WiFi4All network parameters.
  Index: [1.3.6.1.4.1.4684.37.4.1.1.1.1]
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1

TYPE UbeeWifi4allEntry ::= [UNIVERSAL 16] SEQUENCE [ubeeWifi4allIndex [UNIVERSAL 2] INTEGER, ubeeWifi4allSSIDName [UNIVERSAL 4] OCTET STRING, ubeeWifi4allStatus [UNIVERSAL 2] INTEGER, ubeeWifi4allSecurityMode [UNIVERSAL 2] INTEGER, ubeeWifi4allMACAddress [UNIVERSAL 4] OCTET STRING, ubeeWifi4allFrequencyBand [UNIVERSAL 2] INTEGER, ubeeWifi4allOperatingMode [UNIVERSAL 4] OCTET STRING, ubeeWifi4allChannelBandwidth [UNIVERSAL 2] INTEGER, ubeeWifi4allOperatingChannel [APPLICATION 2] INTEGER (0..4294967295), ubeeWifi4allNumOfConnectedDevices [APPLICATION 2] INTEGER (0..4294967295)]

VALUE ubeeWifi4allIndex OBJECT-TYPE (
  Syntax: [UNIVERSAL 2] INTEGER
  Access: not-accessible
  Status: current
  Description: The key for a unique instance of this object.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.1

VALUE ubeeWifi4allSSIDName OBJECT-TYPE (
  Syntax: [UNIVERSAL 4] OCTET STRING (SIZE (0..32))
  Access: read-only
  Status: current
  Description: The WiFi4All network name.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.2

VALUE ubeeWifi4allStatus OBJECT-TYPE (
  Syntax: [UNIVERSAL 2] INTEGER { active(1), enabledInactive(2), disabled(3), error(4) }
  Access: read-only
  Status: current
  Description: Indicates the status of the WiFi4All network.
               active(1): all necessary parameters are provisioned in config file and the 
               WiFi4All network is up and running.
               enabledInactive(2): all necessary parameters are provisioned in config file 
               but the WiFi4All network is down.
               disabled(3): WiFi4All network is not provisioned in config file.
               error(4):  any errors in parsing config file or failed in enable the WiFi4All 
               network.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.3

VALUE ubeeWifi4allSecurityMode OBJECT-TYPE (
  Syntax: [UNIVERSAL 2] INTEGER { none(1), wep64(2), wep128(3), wpaPersonal(4), wpa2Personal(5), wpawpa2Personal(6), wpaEnterprise(7), wpa2Enterprise(8), wpawpa2Enterprise(9) }
  Access: read-only
  Status: current
  Description: Indicates the configured security mode.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.4

VALUE ubeeWifi4allMACAddress OBJECT-TYPE (
  Syntax: [UNIVERSAL 4] OCTET STRING (SIZE (6))
  Access: read-only
  Status: current
  Description: The MAC address of this WiFi4All network.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.5

VALUE ubeeWifi4allFrequencyBand OBJECT-TYPE (
  Syntax: [UNIVERSAL 2] INTEGER { n2dot4Ghz(1), n5Ghz(2) }
  Access: read-only
  Status: current
  Description: Indicates the frequency band at which the radio is operating.
               1=2.4G
               2=5G
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.6

VALUE ubeeWifi4allOperatingMode OBJECT-TYPE (
  Syntax: [UNIVERSAL 4] OCTET STRING (SIZE (0..64))
  Access: read-only
  Status: current
  Description: Comma-separated list of strings. List items indicate which IEEE 802.11
               standard this Radio instance is configured for.
               Each value indicates support for the indicated standard.
               Only values b, g, n are available for 2.4G. Only values of a, n are available for 5G.
               For example, a value of ('g,b') (or ('b,g') - order is not important) means that
               the 802.11g standard [802.11g-2003] is used with a backwards-compatible mode
               for 802.11b [802.11b-1999]. A value of ('g') means that only the 802.11g standard
               can be used.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.7

VALUE ubeeWifi4allChannelBandwidth OBJECT-TYPE (
  Syntax: [UNIVERSAL 2] INTEGER { n20MHz(1), n40MHz(2), auto(3) }
  Access: read-only
  Status: current
  Description: The channel bandwidth (applicable to 802.11n specifications only).
               1=20MHz
               2=40MHz
               3=auto (20MHz/40MHz co-existence)
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.8

VALUE ubeeWifi4allOperatingChannel OBJECT-TYPE (
  Syntax: [APPLICATION 2] INTEGER (0..4294967295)
  Access: read-only
  Status: current
  Description: The current running channel of the WiFi4All network.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.9

VALUE ubeeWifi4allNumOfConnectedDevices OBJECT-TYPE (
  Syntax: [APPLICATION 2] INTEGER (0..4294967295)
  Access: read-only
  Status: current
  Description: The number of devices connnected the WiFi4All network.
)
    ::= 1.3.6.1.4.1.4684.37.4.1.1.1.10
Reference :
1. mibble :: MIB Parser

2014年10月17日 星期五

2014年6月5日 星期四

[SNMP] How to use snmp to set the value


[SNMP] How to use snmp to set the value



snmpset -h |& tail -4

  TYPE: one of i, u, t, a, o, s, x, d, b

    i: INTEGER, u: unsigned INTEGER, t: TIMETICKS, a: IPADDRESS

    o: OBJID, s: STRING, x: HEX STRING, d: DECIMAL STRING, b: BITS

    U: unsigned int64, I: signed int64, F: float, D: double



snmpset -v 2c -c private 111.111.111.111  1.3.6.1.4.1.9999.99.2.4.3.0 a "111.2.1.23"

snmpset -v 2c -c private 111.111.111.111  1.3.6.1.4.1.9999.99.2.4.5.0 s happy

snmpset -v 2c -c private 111.111.111.111  1.3.6.1.4.1.9999.99.2.4.6.0 s happy

snmpset -v 2c -c private 111.111.111.111  1.3.6.1.4.1.9999.99.2.4.7.0 s setup.exe

snmpset -v 2c -c private 111.111.111.111  1.3.6.1.4.1.9999.99.2.4.15.0 s /1/



snmpset -v 2c -c private 111.111.111.111  1.3.6.1.4.1.9999.99.2.4.8.0 i 2



Reference:


2013年9月24日 星期二

[snmp] How to get the OID which you want

[snmp] How to get the OID which you want

===== Command =====

snmptranslate -m all -Tz



===== Result =====

"org"            "1.3"

"dod"            "1.3.6"

"internet"            "1.3.6.1"

"directory"            "1.3.6.1.1"

"mgmt"            "1.3.6.1.2"

"mib-2"            "1.3.6.1.2.1"

"system"            "1.3.6.1.2.1.1"

"sysDescr"            "1.3.6.1.2.1.1.1"

"sysObjectID"            "1.3.6.1.2.1.1.2"

"sysUpTime"            "1.3.6.1.2.1.1.3"

"sysUpTimeInstance"            "1.3.6.1.2.1.1.3.0"

"sysContact"            "1.3.6.1.2.1.1.4"

"sysName"            "1.3.6.1.2.1.1.5"

"sysLocation"            "1.3.6.1.2.1.1.6"

"sysServices"            "1.3.6.1.2.1.1.7"

"sysORLastChange"            "1.3.6.1.2.1.1.8"

"sysORTable"            "1.3.6.1.2.1.1.9"

"sysOREntry"            "1.3.6.1.2.1.1.9.1"

"sysORIndex"            "1.3.6.1.2.1.1.9.1.1"

"sysORID"            "1.3.6.1.2.1.1.9.1.2"

"sysORDescr"            "1.3.6.1.2.1.1.9.1.3"

"sysORUpTime"            "1.3.6.1.2.1.1.9.1.4"

"interfaces"            "1.3.6.1.2.1.2"

"ifNumber"            "1.3.6.1.2.1.2.1"

...........



===== SNMPWalk =====

snmpwalk -v 2c -c public 10.15.140.85 1.3.6.1.4.1.1234.51.2.3.6

SNMPv2-SMI::enterprises.1234.51.2.3.6.0 = INTEGER: 30



===== SNMPSet =====

snmpset -v 2c -c private 10.15.140.85 1.3.6.1.4.1.1234.51.2.3.6.0 u 10

SNMPv2-SMI::enterprises.1234.51.2.3.6.0 = Gauge32: 10



snmpset -h |& tail -4

  TYPE: one of i, u, t, a, o, s, x, d, b

    i: INTEGER, u: unsigned INTEGER, t: TIMETICKS, a: IPADDRESS

    o: OBJID, s: STRING, x: HEX STRING, d: DECIMAL STRING, b: BITS

    U: unsigned int64, I: signed int64, F: float, D: double



2013年9月3日 星期二

[net-snmp] How to load mib file into mibs


[net-snmp] How to load mib file into mibs

1. Create the folder mibs

mkdir ~/.snmp/mibs



2. Change the name from *.mib to *.txt

rename 's/mib/txt/;' *





3. put the mib file into ~/.snmp/mibs



4. Excute

snmptranslate -m ALL -Tz



Reference :






 


2013年9月2日 星期一

[Snmp][Settings] LLC Filter and IP Filter Examples


[Snmp][Settings] LLC Filter and IP Filter Examples



LLC Filters



Basic LLC configuration is to accept only frames which carry IP or related protocols (example, ARP). All other LLC frames will be discarded on all interfaces.



Example :





        SnmpMibObject docsDevFilterLLCIfIndex.1 Integer 0 ;

        SnmpMibObject docsDevFilterLLCProtocolType.1 Integer 1; /* ethertype */

        SnmpMibObject docsDevFilterLLCProtocol.1 Integer 2048 ;

        SnmpMibObject docsDevFilterLLCStatus.1 Integer 4; /* createAndGo */





        SnmpMibObject docsDevFilterLLCIfIndex.2 Integer 0 ;

        SnmpMibObject docsDevFilterLLCProtocolType.2 Integer 1; /* ethertype */

        SnmpMibObject docsDevFilterLLCProtocol.2 Integer 2054 ;

        SnmpMibObject docsDevFilterLLCStatus.2 Integer 4; /* createAndGo */





        SnmpMibObject docsDevFilterLLCIfIndex.3 Integer 0 ;

        SnmpMibObject docsDevFilterLLCProtocolType.3 Integer 1; /* ethertype */

        SnmpMibObject docsDevFilterLLCProtocol.3 Integer 34525 ;

        SnmpMibObject docsDevFilterLLCStatus.3 Integer 4; /* createAndGo */



Reference :



2013年8月15日 星期四

2012年12月6日 星期四

[net-snmp][snmpget] Get the value (sysDescr)  from Board_IP


[net-snmp][snmpget] Get the value (sysDescr)  from Board_IP



snmpwalk -v 2c -c public 111.5.1.121 1.3.6.1.2.1.1.1

SNMPv2-MIB::sysDescr.0 = STRING: MAC



use snmpget

Must add 0 at the end of OID

snmpget -v 2c -c public 111.5.1.121 1.3.6.1.2.1.1.1.0

SNMPv2-MIB::sysDescr.0 = STRING: MAC



 



OID description :



Name:    sysDescr

Type:    OBJECT-TYPE

OID:    1.3.6.1.2.1.1.1

Full path:    iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1).sysDescr(1)

Module:    RFC1213-MIB



Parent:    system

Next sibling:    sysObjectID



Numerical syntax:    Octets

Base syntax:    OCTET STRING

Composed syntax:    DisplayString

Status:    mandatory

Max access:    read-only

Size list:    1: 0..255



Description:    A textual description of the entity.  This value

     should include the full name and version

     identification of the system's hardware type,

     software operating-system, and networking

     software.  It is mandatory that this only contain

     printable ASCII characters.


[ubuntu][net-snmp] How to install net-snmp into Ubuntu 10.04


1. Catch net-snmp-5.7.2 from net-snmp web site.
tar xvf net-snmp-5.7.2.tar.gz

2. Install dependent library ( libperl-dev )
sudo apt-get install libperl-dev

3. cd net-snmp-5.7.2
./configure --with-default-snmp-version="3" --with-sys-contact="@@no.where" --with-sys-location="Unknown" --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/var/net-snmp"

4. make && make install
sudo make
sudo make install

5. Execute " snmpget --version "
Error message

snmpget: error while loading shared libraries: libnetsnmp.so.30: cannot open shared object file: No such file or directory


Solve :
cp /usr/local/lib/libnetsnmp.so.30 /usr/lib

Reference:
  1. Ubuntu下安装net-snmp

2012年11月8日 星期四

[SNMP][Ubuntu] How to use SNMP on Ubuntu


[SNMP][Ubuntu] How to use SNMP on Ubuntu



1. Installl SNMP on Ubuntu

sudo apt-get install snmp



2. Use command to get or set what you want



snmpset -v 2c -c private 192.168.100.1 1.3.6.1.4.OID s password (s = String)

snmpset -v 2c -c private 192.168.100.1 1.3.6.1.4.OID i 1   (i = integer)



snmpset -v 2c -c private           111.5.1.19           1.3.6.1.4.1.4684.51.1.5.0        i           0



snmpwalk -v 2c -c private 192.168.100.1 1.3.6.1.4.OID