NET-SNMP学习(二)Table

SNMP MIB库语法 标量和表table结构 本文介绍了snmp的mib库的一些编写规则,和提供了一些实际可用的例子,方便后续开发和复习 阅读详情

(一)编写MIBS

TEST-DEVICE-MIB DEFINITIONS ::= BEGIN
 
IMPORTS
    MODULE-IDENTITY, OBJECT-TYPE, TimeTicks FROM SNMPv2-SMI
       DisplayString, FROM SNMPv2-TC
    enterprises         
        FROM RFC1155-SMI;
    test OBJECT IDENTIFIER ::= { enterprises 1000 }
 
    
    Device OBJECT IDENTIFIER ::= { test 1 }
           
    boardSlotTable OBJECT-TYPE
        SYNTAX SEQUENCE OF BoardSlotEntry
        MAX-ACCESS not-accessible
        STATUS current
        DESCRIPTION " Fan status description table "
        ::= { Device  2 }
 
 
    boardSlotEntry OBJECT-TYPE
        SYNTAX BoardSlotEntry
        MAX-ACCESS not-accessible
        STATUS current
        DESCRIPTION " Boad status description table entry "
        INDEX   { boardSlotID }
        ::= { boardSlotTable 1}
 
 
    BoardSlotEntry::=
       SEQUENCE {
                boardSlotID  INTEGER,
                boardType INTEGER,
                boardSeriesNumber DisplayString, 
               }
 
    boardSlotID  OBJECT-TYPE
        SYNTAX  INTEGER
        MAX-ACCESS read-only
        STATUS current
        DESCRIPTION " Slot ID "
        ::= { boardSlotEntry 1 }
 
    --add enum value
    boardType  OBJECT-TYPE
        SYNTAX  INTEGER
        MAX-ACCESS read-only
        STATUS current
        DESCRIPTION " Slot Number "
        ::= { boardSlotEntry 2 }
        
    boardSeriesNumber  OBJECT-TYPE
        SYNTAX  DisplayString (SIZE (0..128))
        MAX-ACCESS read-only
        STATUS current
        DESCRIPTION " Slot Series Number "
        ::= { boardSlotEntry 3 }
 
    boardWorkMode  OBJECT-TYPE
        SYNTAX  INTEGER
        {
            normal (1),
            abnormal (2),
            offline (3)
        }
        MAX-ACCESS read-only
        STATUS current
        DESCRIPTION " Board Status: normal (1), abnormal (2) and offline (3)"
        ::= { boardSlotEntry 4 }
 
END

写完之后将其加入到snmp.conf中(即在conf文件里加mibs +xxx,  xxx指的是自己定义的BEGIN名称),如这里的定义的名称是

TEST-DEVICE-MIB。

TEST-DEVICE-MIB DEFINITIONS ::= BEGIN

然后通过命令

snmptranslate -Tp -IR TEST-DEVICE-MIB::Device

Note:Device是自定义Module名称

验证是否成功添加MIB:

+--Device(1)
   |
   +--boardSlotTable(2)
      |
      +--boardSlotEntry(1)
         |  Index: boardSlotID
         |
         +-- -R-- INTEGER   boardSlotID(1)
         +-- -R-- INTEGER   boardType(2)
         +-- -R-- String    boardSeriesNumber(3)
         |        Textual Convention: DisplayString
         |        Size: 0..128
         +-- -R-- EnumVal   boardWorkMode(4)
                  Values: normal(1), abnormal(2), offline(3)

出现这个代表已经成功添加到我们的MIB库里。

使用mib2c工具编译。表格使用mib2c.iterate.conf或mib2c.iterate_access.conf。

mib2c mib2c.iterate.conf TEST-DEVICE-MIB::Device

成功会有提示选择编译选项:

You requested mib2c to be run on the following part of the MIB tree:
  OID:                       	    Device
  numeric translation:       	    .1.3.6.1.4.1.1000.1
  number of scalars within:         0
  number of tables within:          1
  number of notifications within:   0

First, do you want to generate code that is compatible with the
ucd-snmp 4.X line of code, or code for the newer Net-SNMP 5.X code
base (which provides a much greater choice of APIs to pick from):

  1) ucd-snmp style code
  2) Net-SNMP style code

Select your choice :

根据提示选择即可。

继而生成了对应的.c  .h文件。

(二)修改代码

生成的.c代码:

/*
 * Note: this file originally auto-generated by mib2c using
 *  $
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "boardSlotTable.h"

/** Initializes the boardSlotTable module */
void
init_boardSlotTable(void)
{
  /* here we initialize all the tables we're planning on supporting */
    initialize_table_boardSlotTable();
}

  # Determine the first/last column names

/** Initialize the boardSlotTable table by defining its contents and how it's structured */
void
initialize_table_boardSlotTable(void)
{
    const oid boardSlotTable_oid[] = {1,3,6,1,4,1,1000,1,2};
    const size_t boardSlotTable_oid_len   = OID_LENGTH(boardSlotTable_oid);
    netsnmp_handler_registration    *reg;
    netsnmp_iterator_info           *iinfo;
    netsnmp_table_registration_info *table_info;

    DEBUGMSGTL(("boardSlotTable:init", "initializing table boardSlotTable\n"));

    reg = netsnmp_create_handler_registration(
              "boardSlotTable",     boardSlotTable_handler,
              boardSlotTable_oid, boardSlotTable_oid_len,
              HANDLER_CAN_RONLY
              );

    table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
    netsnmp_table_helper_add_indexes(table_info,
                           ASN_INTEGER,  /* index: boardSlotID */
                           0);
    table_info->min_column = COLUMN_BOARDSLOTID;
    table_info->max_column = COLUMN_BOARDWORKMODE;
    
    iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
    iinfo->get_first_data_point = boardSlotTable_get_first_data_point;
    iinfo->get_next_data_point  = boardSlotTable_get_next_data_point;
    iinfo->table_reginfo        = table_info;
    
    netsnmp_register_table_iterator( reg, iinfo );
    netsnmp_inject_handler_before( reg, 
        netsnmp_get_cache_handler(BOARDSLOTTABLE_TIMEOUT,
                                  boardSlotTable_load, boardSlotTable_free,
                                  boardSlotTable_oid, boardSlotTable_oid_len),
            TABLE_ITERATOR_NAME);

    /* Initialise the contents of the table here */
}

    /* Typical data structure for a row entry */
struct boardSlotTable_entry {
    /* Index values */
    long boardSlotID;

    /* Column values */
    long boardSlotID;
    long boardType;
    char boardSeriesNumber[NNN];
    size_t boardSeriesNumber_len;
    long boardWorkMode;

    /* Illustrate using a simple linked list */
    int   valid;
    struct boardSlotTable_entry *next;
};

struct boardSlotTable_entry  *boardSlotTable_head;

/* create a new row in the (unsorted) table */
struct boardSlotTable_entry *
boardSlotTable_createEntry(
                 long  boardSlotID,
                ) {
    struct boardSlotTable_entry *entry;

    entry = SNMP_MALLOC_TYPEDEF(struct boardSlotTable_entry);
    if (!entry)
        return NULL;

    entry->boardSlotID = boardSlotID;
    entry->next = boardSlotTable_head;
    boardSlotTable_head = entry;
    return entry;
}

/* remove a row from the table */
void
boardSlotTable_removeEntry( struct boardSlotTable_entry *entry ) {
    struct boardSlotTable_entry *ptr, *prev;

    if (!entry)
        return;    /* Nothing to remove */

    for ( ptr  = boardSlotTable_head, prev = NULL;
          ptr != NULL;
          prev = ptr, ptr = ptr->next ) {
        if ( ptr == entry )
            break;
    }
    if ( !ptr )
        return;    /* Can't find it */

    if ( prev == NULL )
        boardSlotTable_head = ptr->next;
    else
        prev->next = ptr->next;

    SNMP_FREE( entry );   /* XXX - release any other internal resources */
}

/* Example cache handling - set up linked list from a suitable file */
int
boardSlotTable_load( netsnmp_cache *cache, void *vmagic ) {
    FILE *fp;
    struct boardSlotTable_entry *this;
    char buf[STRMAX];

    /* The basic load routine template assumes that the data to
       be reported is held in a file - with one row of the file
       for each row of the table.
          If your data is available via a different API, you
       should amend this initial block (and the control of the
       'while' loop) accordingly.
          'XXX' marks where the template is incomplete and
       code will definitely need to be added. */

    fp = fopen( "/data/for/boardSlotTable", "r" );
    if ( !fp ) {
        return -1;
    }
    while ( fgets( buf, STRMAX, fp )) {
        this = SNMP_MALLOC_TYPEDEF( struct boardSlotTable_entry );
        /* XXX - Unpick 'buf' to extract the individual field values
                 and then populate the 'this' data structure with them */

        this->next = boardSlotTable_head;
        boardSlotTable_head = this;    /* Iterate helper is fine with unordered lists! */
    }
    fclose(fp);
    return 0;  /* OK */
}

void
boardSlotTable_free( netsnmp_cache *cache, void *vmagic ) {
    struct boardSlotTable_entry *this, *that;

    for ( this = boardSlotTable_head; this; this=that ) {
        that = this->next;
        SNMP_FREE( this );   /* XXX - release any other internal resources */
    }
    boardSlotTable_head = NULL;
}

/* Example iterator hook routines - using 'get_next' to do most of the work */
netsnmp_variable_list *
boardSlotTable_get_first_data_point(void **my_loop_context,
                          void **my_data_context,
                          netsnmp_variable_list *put_index_data,
                          netsnmp_iterator_info *mydata)
{
    *my_loop_context = boardSlotTable_head;
    return boardSlotTable_get_next_data_point(my_loop_context, my_data_context,
                                    put_index_data,  mydata );
}

netsnmp_variable_list *
boardSlotTable_get_next_data_point(void **my_loop_context,
                          void **my_data_context,
                          netsnmp_variable_list *put_index_data,
                          netsnmp_iterator_info *mydata)
{
    struct boardSlotTable_entry *entry = (struct boardSlotTable_entry *)*my_loop_context;
    netsnmp_variable_list *idx = put_index_data;

    if ( entry ) {
        snmp_set_var_typed_integer( idx, ASN_INTEGER, entry->boardSlotID );
        idx = idx->next_variable;
        *my_data_context = (void *)entry;
        *my_loop_context = (void *)entry->next;
        return put_index_data;
    } else {
        return NULL;
    }
}


/** handles requests for the boardSlotTable table */
int
boardSlotTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) {

    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_info;
    struct boardSlotTable_entry          *table_entry;

    DEBUGMSGTL(("boardSlotTable:handler", "Processing request (%d)\n", reqinfo->mode));

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request=requests; request; request=request->next) {
            table_entry = (struct boardSlotTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_BOARDSLOTID:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->boardSlotID);
                break;
            case COLUMN_BOARDTYPE:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->boardType);
                break;
            case COLUMN_BOARDSERIESNUMBER:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          table_entry->boardSeriesNumber,
                                          table_entry->boardSeriesNumber_len);
                break;
            case COLUMN_BOARDWORKMODE:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->boardWorkMode);
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;
            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}

修改后:

/*
 * Note: this file originally auto-generated by mib2c using
 *  $
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "boardSlotTable.h"

#define SN_SIZE 64
#define STRMAX  128



struct boardSlotTable_entry {
    /*
     * Index values 
     */
   // long            boardSlotID;

    /*
     * Column values 
     */
    long            boardSlotID;
    long            boardType;
    char            boardSeriesNumber[SN_SIZE];
    size_t          boardSeriesNumber_len;
    long            boardWorkMode;

    /*
     * Illustrate using a simple linked list 
     */
    int             valid;
    struct boardSlotTable_entry *next;
};

struct boardSlotTable_entry *boardSlotTable_head;


struct boardSlotTable_entry *
boardSlotTable_createEntry(long boardSlotID,long boardtype,char *boardSeriesNumber,size_t boardSeriesNumber_len)
{
    struct boardSlotTable_entry *entry;
	/*
	struct boardSlotTable_entry *entry1;
	struct boardSlotTable_entry *entry2;
    */
    entry = SNMP_MALLOC_TYPEDEF(struct boardSlotTable_entry);
	entry1 = SNMP_MALLOC_TYPEDEF(struct boardSlotTable_entry);
	entry2 = SNMP_MALLOC_TYPEDEF(struct boardSlotTable_entry);
    if (!entry || !entry1 || !entry1)
        return NULL;

    entry->boardSlotID = boardSlotID;
	memcpy(entry->boardSeriesNumber,boardSeriesNumber,strlen(boardSeriesNumber));
	entry->boardSeriesNumber_len = boardSeriesNumber_len;
	entry->boardType = boardtype;

#if 0
	entry1->boardSlotID = 2;
	//memcpy( entry1->boardSeriesNumber,"TRY-621-1", strlen("TRY-621-1"));
	strcpy(entry1->boardSeriesNumber,"TRY-621-1");
    entry1->boardSeriesNumber_len =strlen("TRY-621-1");
	entry1->boardType = 1;

	entry2->boardSlotID = 3;
	//memcpy( entry1->boardSeriesNumber,"TRY-621-2", strlen("TRY-621-2"));
	strcpy(entry2->boardSeriesNumber,"TRY-621-2");
    entry2->boardSeriesNumber_len =strlen("TRY-621-2");
	entry2->boardType = 2;

	entry->next = entry1;
	entry1->next = entry2;
    entry2->next = boardSlotTable_head;
    boardSlotTable_head = entry;
#endif 

	entry->next = boardSlotTable_head;
	boardSlotTable_head = entry;

    return entry;
}


/*
 * remove a row from the table 
 */
void
boardSlotTable_removeEntry(struct boardSlotTable_entry *entry)
{
    struct boardSlotTable_entry *ptr, *prev;

    if (!entry)
        return;                 /* Nothing to remove */

    for (ptr = boardSlotTable_head, prev = NULL;
         ptr != NULL; prev = ptr, ptr = ptr->next) {
        if (ptr == entry)
            break;
    }
    if (!ptr)
        return;                 /* Can't find it */

    if (prev == NULL)
        boardSlotTable_head = ptr->next;
    else
        prev->next = ptr->next;

    SNMP_FREE(entry);           /* XXX - release any other internal resources */
}


/** Initializes the boardSlotTable module */
void
init_boardSlotTable(void)
{
    /*
     * here we initialize all the tables we're planning on supporting 
     */
    initialize_table_boardSlotTable();
}

//#Determine the first/last column names

/** Initialize the boardSlotTable table by defining its contents and how it's structured */
void
initialize_table_boardSlotTable(void)
{
    const oid       boardSlotTable_oid[] =
        { 1, 3, 6, 1, 4, 1, 1000, 1, 2 };
    const size_t    boardSlotTable_oid_len =
        OID_LENGTH(boardSlotTable_oid);
    netsnmp_handler_registration *reg;
    netsnmp_iterator_info *iinfo;
    netsnmp_table_registration_info *table_info;

    DEBUGMSGTL(("boardSlotTable:init",
                "initializing table boardSlotTable\n"));

    reg =
        netsnmp_create_handler_registration("boardSlotTable",
                                            boardSlotTable_handler,
                                            boardSlotTable_oid,
                                            boardSlotTable_oid_len,
                                            HANDLER_CAN_RONLY);

    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER,   /* index: boardSlotID */
                                     0);
    table_info->min_column = COLUMN_BOARDSLOTID;
    table_info->max_column = COLUMN_BOARDWORKMODE;

    iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
    iinfo->get_first_data_point = boardSlotTable_get_first_data_point;
    iinfo->get_next_data_point = boardSlotTable_get_next_data_point;
    iinfo->table_reginfo = table_info;

    netsnmp_register_table_iterator(reg, iinfo);
    netsnmp_inject_handler_before(reg,
                                  netsnmp_get_cache_handler
                                  (BOARDSLOTTABLE_TIMEOUT,
                                   boardSlotTable_load,
                                   boardSlotTable_free, boardSlotTable_oid,
                                   boardSlotTable_oid_len),
                                  TABLE_ITERATOR_NAME);

    /*
     * Initialise the contents of the table here 
     */
	boardSlotTable_createEntry(1,0,"TRY-621-0",strlen("TRY-621-0"));
	boardSlotTable_createEntry(2,1,"TRY-621-1",strlen("TRY-621-1"));
	boardSlotTable_createEntry(3,2,"TRY-621-2",strlen("TRY-621-2"));
	boardSlotTable_createEntry(4,3,"TRY-621-3",strlen("TRY-621-3"));

	
}



/*
 * Example cache handling - set up linked list from a suitable file 
 */
int
boardSlotTable_load(netsnmp_cache * cache, void *vmagic)
{
    FILE           *fp;
    struct boardSlotTable_entry *this;
    char            buf[STRMAX];

    /*
     * The basic load routine template assumes that the data to
     * be reported is held in a file - with one row of the file
     * for each row of the table.
     * If your data is available via a different API, you
     * should amend this initial block (and the control of the
     * 'while' loop) accordingly.
     * 'XXX' marks where the template is incomplete and
     * code will definitely need to be added. 
     */

    fp = fopen("/data/for/boardSlotTable", "r");
    if (!fp) {
        return -1;
    }
    while (fgets(buf, STRMAX, fp)) {
        this = SNMP_MALLOC_TYPEDEF(struct boardSlotTable_entry);
        /*
         * XXX - Unpick 'buf' to extract the individual field values
         * and then populate the 'this' data structure with them 
         */

        this->next = boardSlotTable_head;
        boardSlotTable_head = this;     /* Iterate helper is fine with unordered lists! */
    }
    fclose(fp);
    return 0;                   /* OK */
}

void
boardSlotTable_free(netsnmp_cache * cache, void *vmagic)
{
    struct boardSlotTable_entry *this, *that;

    for (this = boardSlotTable_head; this; this = that) {
        that = this->next;
        SNMP_FREE(this);        /* XXX - release any other internal resources */
    }
    boardSlotTable_head = NULL;
}

/*
 * Example iterator hook routines - using 'get_next' to do most of the work 
 */
netsnmp_variable_list *
boardSlotTable_get_first_data_point(void **my_loop_context,
                                    void **my_data_context,
                                    netsnmp_variable_list * put_index_data,
                                    netsnmp_iterator_info *mydata)
{
    *my_loop_context = boardSlotTable_head;
    return boardSlotTable_get_next_data_point(my_loop_context,
                                              my_data_context,
                                              put_index_data, mydata);
}

netsnmp_variable_list *
boardSlotTable_get_next_data_point(void **my_loop_context,
                                   void **my_data_context,
                                   netsnmp_variable_list * put_index_data,
                                   netsnmp_iterator_info *mydata)
{
    struct boardSlotTable_entry *entry =
        (struct boardSlotTable_entry *) *my_loop_context;
    netsnmp_variable_list *idx = put_index_data;

    if (entry) {
        snmp_set_var_typed_integer(idx, ASN_INTEGER, entry->boardSlotID);
        idx = idx->next_variable;
        *my_data_context = (void *) entry;
        *my_loop_context = (void *) entry->next;
        return put_index_data;
    } else {
        return NULL;
    }
}


/** handles requests for the boardSlotTable table */
int
boardSlotTable_handler(netsnmp_mib_handler *handler,
                       netsnmp_handler_registration *reginfo,
                       netsnmp_agent_request_info *reqinfo,
                       netsnmp_request_info *requests)
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    struct boardSlotTable_entry *table_entry;

    DEBUGMSGTL(("boardSlotTable:handler", "Processing request (%d)\n",
                reqinfo->mode));

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            table_entry = (struct boardSlotTable_entry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case COLUMN_BOARDSLOTID:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           table_entry->boardSlotID);
                break;
            case COLUMN_BOARDTYPE:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           table_entry->boardType);
                break;
            case COLUMN_BOARDSERIESNUMBER:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         table_entry->boardSeriesNumber,
                                         table_entry->
                                         boardSeriesNumber_len);
                break;
            case COLUMN_BOARDWORKMODE:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
 net-snmp-config --compile-subagent xxx  xxx.c


table_entry->boardWorkMode); break; default: netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT); break; } } break; } return SNMP_ERR_NOERROR;}

(三)生成子代理

 net-snmp-config --compile-subagent xxx  xxx.c

xxx自定义生成名称,xxx.c为.c代码名字。

(四)测试

运行snmpd和生成的xxx可执行文件。用snmpwalk遍历节点。

snmpwalk -v2c -c public localhost 1.3.6.1.4.1.1000
SNMPv2-SMI::enterprises.1000.1.2.1.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.1000.1.2.1.1.2 = INTEGER: 2
SNMPv2-SMI::enterprises.1000.1.2.1.1.3 = INTEGER: 3
SNMPv2-SMI::enterprises.1000.1.2.1.1.4 = INTEGER: 4
SNMPv2-SMI::enterprises.1000.1.2.1.2.1 = INTEGER: 0
SNMPv2-SMI::enterprises.1000.1.2.1.2.2 = INTEGER: 1
SNMPv2-SMI::enterprises.1000.1.2.1.2.3 = INTEGER: 2
SNMPv2-SMI::enterprises.1000.1.2.1.2.4 = INTEGER: 3
SNMPv2-SMI::enterprises.1000.1.2.1.3.1 = STRING: "TRY-621-0"
SNMPv2-SMI::enterprises.1000.1.2.1.3.2 = STRING: "TRY-621-1"
SNMPv2-SMI::enterprises.1000.1.2.1.3.3 = STRING: "TRY-621-2"
SNMPv2-SMI::enterprises.1000.1.2.1.3.4 = STRING: "TRY-621-3"
SNMPv2-SMI::enterprises.1000.1.2.1.11.1 = INTEGER: 0
SNMPv2-SMI::enterprises.1000.1.2.1.11.2 = INTEGER: 0
SNMPv2-SMI::enterprises.1000.1.2.1.11.3 = INTEGER: 0
SNMPv2-SMI::enterprises.1000.1.2.1.11.4 = INTEGER: 0

End:记录下学习的过程

 

 

 

 

linux net-snmp(之mib2c工具生成表格代码) snmp 表格支持增删改查操作,比标量节点多了增删操作,那么为了实现增删操作,可以向表格增加一个RowStatus行状态类型的列,通过设置状态值对表格进行控制。 RowStatus状态值: -active(1):表明状态行是可用的 -notInService(2):表明行存在但不可用 -notReady (3):表明存在,但因为缺少必要的信息而不能用 -createAndGo (4):由管理者设置... 阅读详情

相关推荐

BMC snmp 开发二

snmp table的使用方法

wit_yuan的专栏 1182

net-snmp中自定义snmp table的实现

 每次调试程序的时候,都需要一个真实的设备来做agent,当agent出问题的时候往往会影响项目进度,于是想能否找到一个windows上的替代品来做测试,只要有MIB就可以测试了。经过几个月摸索现在终于找到一个替代品,用net-snmp 的扩展agent方式。这里以v5.4.2.1作介绍(注意,有些版本在windows上编译会带来一些问题,我没有去细究)。 1. 要在windows上编译,

sstower的专栏 1万+

避开CPU瓶颈:手把手教你用RK3588的DMA-BUF实现V4L2到NPU的零拷贝数据流

本文详细介绍了如何在RK3588平台上利用DMA-BUF实现V4L2到NPU的零拷贝数据流,显著提升异构计算性能。通过实战指南展示了如何配置摄像头采集、RGA图像预处理和NPU推理优化,最终实现CPU占用率降低60%、延迟减少60%的效果,特别适合YOLOv5等AI推理应用的高效部署。

weixin_30374009的博客 571

NET-SNMP学习 Table对象 (表格代码框架iterate)

SNMP Table是对象的有序集合,包含若干行。为什么SNMP中需要用表格呢,原因是有些数据的组织用表格来表达更方便,多个对象的组合才能完整描述一条信息。 表格代码框架概述: 表格框架的配置文件根据表格数据是否存在于Net-SNMP的内核中分为两大类: 一类是表格数据存放于其内部。这类框架代码中将所有的表格信息和数据都注册到系统中,同时生成单个处理句柄,在代理内核完成数据的GET/SET等操作。当对表格中某列有特殊的处理需求时,才自定义额外的处理句柄。这类框架配置文件有,mib2c.table_dat

linuxGc的博客 3166

计算机网络之NAT的解释与实验配置

NAT 静态NAT 动态NAT easy_ip NAT服务器映射

爱学习的JackYang的博客 1918

三维模型转变为点云模型的好工具——CloudCompare使用小记

普通三维模型能够直观地展示物体的三维全貌,但是在一些场合需要将三维模型变为相应的点云模型进行展示,而使用激光雷达等传感器采集到的点云信息往往只能反应模型表面的情况,或是使用PCL库中的可执行文件进行转换,这两种操作较为麻烦。笔者最近就遇到了这样一个情况,找到了一个名叫CloudCompare(CC)的软件,能够支持将多种文件格式的三维模型转变为点云模型。以下将本人在使用过程中所使用到的一些操作简记下来供朋友们和将来的自己参考。 一、下载 CloudCompare是一款免费软件,其可以在CloudComp

hdlwyt的博客 2万+

SNMP Table简介

SNMP Table 简介 收藏 SNMP Table简介 SNMP Table是对象的有序集合,包含若干行。为什么SNMP中需要用表格呢,原因是有些数据的组织用表格来表达更方便,多个对象的组合才能完整描述一条信息。格式相同的信息可能有多条,像表tcpConnTable: tcpConnState tcpConnLocalAddress tcpConnLocaPort...

mxdxm8899的专栏 2327

数字IC后端设计实现OCC(On-chip Clock Controller)电路介绍及时钟树综合案例

数字IC后端设计实现OCC(On-chip Clock Controller)电路介绍及时钟树综合案例

weixin_37584728的博客 4737

No4. net-snmp 非常好的开发介绍

目录 1SNMP协议简介 1.1网络管理协议结构 1.2管理信息库 1.3SNMP的版本 2SNMP开发软件包 2.1NET-SNMP简介和安装 2.2NET-SNMP代理的配置 2.3NET-SNMP工具的使用 3扩展开发——代理 3.1NET-SNMP中的scalar对象和...

编程到管理、技术到产品 1628

网络可视媒体的智能计算-胡事民

本文为胡事民教授在山大做报告的笔记,现场见下图: 可视媒体是承载视觉信息的媒体类型,如图像、视频等,它具有网络化、海量和无序涌现等特征。 可视媒体计算的研究意义 可视媒体作为一种信息承载的介质,是用来表达语义信息的。那么就有一种介质与信息之间相互转化的问题。转化方向正反两种,举个栗子说明一下: 1. 可视媒体→→\rightarrow语义信息:比如看到画面,理解其中发生的事件、各主题之...

gdymind的博客 2451

基于OpenClaw的AI数字员工协同团队架构设计

随着大型语言模型从被动的文本生成器向具备自主规划与执行能力的智能代理演进,企业级人工智能的应用范式正在发生根本性转变。在这一演进过程中,OpenClaw(前身为Clawdbot及Moltbot)作为一种开源的、本地优先的个人AI智能体网关基础设施,凭借其对持续内存、多通道接入以及沙盒化工具执行的原生支持,迅速成为构建“始终在线”数字劳动力的核心框架 1。然而,将单体个人助理扩展为能够处理复杂业务逻辑、支持跨组织协同并严格保障数据隔离的多智能体(Multi-Agent)团队,绝非简单的API拼接。系统架构必须

形上得其象,形下合于数;阴阳自济,玄理自明。 1048

NET-SNMP基本命令

当环境设置好后,运行snmpd,即snmp代理进程,就可以使用管理工具查询其中的信息了。Net- snmp提供的查询工具有很多,这里只介绍常用的几个,而且大部分查询命令的格式都大同小异。这里以.iso.org.dod.internet.mgmt.mib-2.system为例,其Oid为:.1.3.6.1.2.1.1。结构如下:    ………system                     .

老夫编代码就是一把梭 1万+

Esp32蓝牙Hid调用方案 http执行设备、鼠标、键盘相关操作

本文主要介绍 Esp32 蓝牙 Hid 相关的多种操作方式,详细的设备、鼠标、键盘相关操作的 http 调用方法。下面是整理出的所有 http 调用方法和 rhino 引擎方式。本机调用的话直接使用http://localhost:8080 如果是局域网调用则使用软件里的地址 比如我的是http://192.168.1.5:8080。文件地址: https://www.123865.com/s/Qtm4jv-xyZbd?使用前需要一块烧录好的ESP32板子并在手机安装好embedded软件用于蓝牙通信。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 569

Net-snmp总结(三)-net-snmp的MIBs扩展_添加get

一、编写MIB文件 MIB文件是用ASN.1语法来描述的,所以为了精确定义MIB中各管理对象,用户不得不参考一些ASN.1语法的有关文档如RFC1155、RFC1212等等来定义设备自己的MIB。ASN.1是抽象句法表示法一(Abstract SyntaxNotation One)的简称,对于每个管理对象它都用文本来描述,一般文件的后缀名都用“.mib”,在net-snmp中后缀名是“....

JIANGXIN04211的专栏 7779

【RT-DETR实战】RT-DETR实战手记(200):端侧实时目标检测,下一步往哪儿走?

昨天深夜调一个模型部署,在树莓派4B上跑RT-DETR-nano,帧率死活卡在8FPS上不去。量化也做了,算子也优化了,内存对齐也检查了,可就是离实时检测的底线还差一截。盯着终端里跳动的数字,突然意识到——我们可能正在接近当前技术路径的瓶颈。端侧实时目标检测的下一个突破口,恐怕不在现有框架的修修补补里。

企鹅码农的专属播客,分享10多年的实战案例和经验解读,包含YOLO、RT-DETR、AI等各个工作领域。 186

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

snmp-cmds:最简单的调用 Net-SNMP 二进制文件作为子进程的库可移植python SNMP 库

snmp-cmds 是一个 Python 库,用于通过 SNMP 与目标设备进行通信 那里有很多 SNMP 库。何苦? 确实有很多很棒的 SNMP 库可用于 python。 有些,比如 PySNMP,是纯 Python 的。这使得它们跨平台的可移植性令人难以置信,这很棒,但也使它们相对较慢。此外,与 PySNMP 一样令人惊奇的是,它并不以其易用性而著称。 有些,如 net-snmp 绑定和 easysnmp,是作为 Net-SNMP 等 C 库的扩展而构建的。这使得它们非常快速和高...

allway2的博客 978

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

net-snmp代理开发——自定义table实现

首先,编写含有table结构的MIB文件,检查好语法,TC-TABLE-MIB.txt内容如下: -- -- TC-TABLE-MIB.my -- MIB generated by MG-SOFT Visual MIB Builder Version 6.0  Build 88 -- Monday, October 17, 2011 at 17:39:34

hubi0952的专栏 2626

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

历史经验之Net-SNMP的mib2c

今天在搞net-snmp所提供的mib2c tool, 用起來說實在的實在有點難用。 大概是我對它還不太熟的關係吧。 以下是今天弄的一些心得: (因為開發需求,所以設定prefix為/opt/net-snmp。) 店铺地址:https://shop66907778.taobao.com/ 首先,在安裝net-snmp時,需在configure時加入以下參數 $ ./configure --prefix=/opt/net-snmp/ --enable-embedded-perl --enable-sha

上善若水的博客 987

Making a Mnesia Table SNMP Accessible

原文地址: [url]http://www.drxyzzy.org/mnesia-snmp/index.html[/url] [color=red]手册写的巨明白[/color] Contents Introduction Define a Mnesia Table Create the MIB File Create the .funcs File Compile the ...

erlang非业余研究 177

用NET-SNMP软件包开发简单客户端代理

    用NET-SNMP软件包开发简单客户端代理写在前面的话:对于net-snmp我也是一个初学者,开始学习时也碰到了很多低级的问题。在很多论坛上(事实上比较少^_^, 建议大家直接去sourcefoge社区看关于net-snmp的mail-list),都没有比较初级入门的文章,本着开源学习的精神,把自己的一点收获,共享给大家。通过参考一些前辈的文章和帮助文档,本文实现了一个简单

用心良苦 3212

net-snmp扩展table类型的私有mib

注:本文介绍的是静态编译的方法扩展的私有mib,别的方法请看本人整理的《net-snmp agent开发(用net-snmp扩展MIB库)》 1. 首先创建一个简单的含有table变量的mib文件取名test.mib,后缀名也可以是.txt 实际操作没有区别; TEST-DEVICE-MIB DEFINITIONS ::= BEGIN IMPORTS MODULE-IDENT

咔酷咿赤影的的专栏 5326

用NET-SNMP软件包开发简单客户端代理————较详细

用NET-SNMP软件包开发简单客户端代理 写在前面的话: 对于net-snmp我也是一个初学者,开始学习时也碰到了很多低级的问题。在很多论坛上(事实上比较少^_^, 建议大家直接去sourcefoge社区看关于net-snmp的mail-list),都没有比较初级入门的文章,本着开源学习的精神,把自己的一点收获,共享给大家。通过参考一些前辈的文章和帮助文档,本文实现了一个简单的mib,并编写

killerover84的专栏-----天下 1019

net-snmp MIB问题,求高人指导

如题: 小弟,学习SNMP,涉及到关于MIB的扩展,其中包括TABLE 求高人指导,感激不尽。

iteye_969的博客 115
上一篇: NET-SNMP学习(一)subagent
下一篇: SNMP(三)使用mib2c.mfd.conf生成的模版及代码中需注意的地方
just_run丶
博客等级 码龄10年 51粉丝 7原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

just_run丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值