Re: how can I display the oid as string value?

2011-08-03 Thread Dave Shield
On 3 August 2011 06:44, sujata patra sujata_patra2...@yahoo.com wrote:
 I like to display the OID as string. So instead of integer I have chosen some 
 char*
 as the key

 but while doing snmpwalk I am not getting them as String
 snmpwalk -v2c -c public -Oa localhost:11161 1.3.6.1.4.1.11456
 ABC-MIB::messageType.0.3.65.70.77.98374.98374.4 = STRING: AFM

What does the MIB definition look like?

Dave

--
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos  much more. Register early  save!
http://p.sf.net/sfu/rim-blackberry-1
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: how can I display the oid as string value?

2011-08-03 Thread Wes Hardaker
 On Wed, 3 Aug 2011 10:20:25 +0100, Dave Shield 
 d.t.shi...@liverpool.ac.uk said:

 but while doing snmpwalk I am not getting them as String
 snmpwalk -v2c -c public -Oa localhost:11161 1.3.6.1.4.1.11456
 ABC-MIB::messageType.0.3.65.70.77.98374.98374.4 = STRING: AFM

DS What does the MIB definition look like?

Specifically, the Net-SNMP code will only display a string in the OID if
the MIB definition is properly set up to match the table's indexes and
contains the same set of indexes (and one of which is the string in question).
-- 
Wes Hardaker
Please mail all replies to net-snmp-coders@lists.sourceforge.net

--
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos  much more. Register early  save!
http://p.sf.net/sfu/rim-blackberry-1
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: how can I display the oid as string value?

2011-08-03 Thread Dave Shield
On 3 August 2011 16:18, Wes Hardaker harda...@users.sourceforge.net wrote:
 Specifically, the Net-SNMP code will only display a string in the OID if
 the MIB definition is properly set up to match the table's indexes and
 contains the same set of indexes (and one of which is the string in question).

Which it didn't/wasn't

Dave

--
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos  much more. Register early  save!
http://p.sf.net/sfu/rim-blackberry-1
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: how can I display the oid as string value?

2011-08-03 Thread Wes Hardaker
 On Wed, 3 Aug 2011 19:16:48 +0100, Dave Shield 
 d.t.shi...@liverpool.ac.uk said:

DS On 3 August 2011 16:18, Wes Hardaker harda...@users.sourceforge.net wrote:
 Specifically, the Net-SNMP code will only display a string in the OID if
 the MIB definition is properly set up to match the table's indexes and
 contains the same set of indexes (and one of which is the string in 
 question).

DS Which it didn't/wasn't

Hence the reason I (vaguely) informed it's likely a MIB problem and
that's why you were asking about it.

-- 
Wes Hardaker
Please mail all replies to net-snmp-coders@lists.sourceforge.net

--
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos  much more. Register early  save!
http://p.sf.net/sfu/rim-blackberry-1
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


how can I display the oid as string value?

2011-08-02 Thread sujata patra
I like to display the OID as string. So instead of integer I have chosen some 
char* as the key
initialize_table_messageTable(void) {

    netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, 
 ASN_OCTET_STR,
 ASN_INTEGER,
 ASN_INTEGER, 
 ASN_INTEGER, 0);

}


but while doing snmpwalk I am not getting them as String
snmpwalk -v2c -c public -Oa localhost:11161 1.3.6.1.4.1.11456
ABC-MIB::messageType.0.3.65.70.77.98374.98374.4 = STRING: AFM

--OID has been displayed as 65.70.77 which is basically AFM

Where I expect to display as ABC-MIB::messageType.0.3.AFM.98374.98374.4 = 
STRING: AFM

how can I achive this ?



/*
 * Note: this file originally auto-generated by mib2c using
 *  : mib2c.iterate.conf 19302 2010-08-13 12:19:42Z dts12 $
 */

#include net-snmp/net-snmp-config.h
#include net-snmp/net-snmp-includes.h
#include net-snmp/agent/net-snmp-agent-includes.h
#include abcModule.h

#define STRMAX 256
static void update_stats( unsigned int, void* );

/** Initializes the abcModule module */
void
init_abcModule(void)
{
  /* here we initialize all the tables we're planning on supporting */
initialize_table_messageTable();
initialize_table_msgVMTable();
}



/** Initialize the messageTable table by defining its contents and how it's structured */
void
initialize_table_messageTable(void)
{
const oid messageTable_oid[] = {1,3,6,1,4,1,11456,3,3};
const size_t messageTable_oid_len   = OID_LENGTH(messageTable_oid);
netsnmp_handler_registration*reg;
netsnmp_iterator_info   *iinfo;
netsnmp_table_registration_info *table_info;

DEBUGMSGTL((abcModule:init, initializing table messageTable\n));

reg = netsnmp_create_handler_registration(
  messageTable, messageTable_handler,
  messageTable_oid, messageTable_oid_len,
  HANDLER_CAN_RONLY
  );

table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, 
 ASN_OCTET_STR,
 ASN_INTEGER,
 ASN_INTEGER, 
 ASN_INTEGER, 0);
table_info-min_column = COLUMN_MESSAGETYPE;
table_info-max_column = COLUMN_CURRENTMSGID;

iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
iinfo-get_first_data_point = messageTable_get_first_data_point;
iinfo-get_next_data_point  = messageTable_get_next_data_point;
iinfo-table_reginfo= table_info;

netsnmp_register_table_iterator( reg, iinfo );
snmp_alarm_register( 5, SA_REPEAT , update_stats, NULL );
/* Initialise the contents of the table here */
}
/* Typical data structure for a row entry */
struct msgVMTable_entry {
/* Index values */
long messageIndex;
long msgVMIndex;

/* Column values */
char msgVMName[10];

long msgVMId;

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


/* Typical data structure for a row entry */
struct messageTable_entry {
/* Index values */
long messageIndex;

/* Column values */
char messageType[10];
long sentMsgCount;
long errorMsgCount;
long currentMsgID;

/* Illustrate using a simple linked list */
int   valid;
struct messageTable_entry *next;
//struct msgVMTable_entry  *msgVMTable_head;
};

struct messageTable_entry  *messageTable_head; //top level Table
struct msgVMTable_entry  *msgVMTable_head; // vm table is repeated for each row of messageTable
/* create a new row in the (unsorted) table */

struct messageTable_entry *
messageTable_createEntry(
 long  messageIndex
) {
struct messageTable_entry *entry;

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

entry-messageIndex = messageIndex;
entry-next = messageTable_head;
messageTable_head = entry;
return entry;
}
void
messageTable_removeEntry( struct messageTable_entry *entry ) {
struct messageTable_entry *ptr, *prev;

if (!entry)
return;

for ( ptr  = messageTable_head, prev = NULL;
  ptr != NULL;
  prev = ptr, ptr = ptr-next ) {
if ( ptr == entry )
break;
}
if ( !ptr )
return;   

if ( prev == NULL )
messageTable_head = ptr-next;
else
prev-next = ptr-next;

SNMP_FREE( entry );   
}


/* Example iterator hook routines - using 'get_next' to do most of the work */
netsnmp_variable_list *
messageTable_get_first_data_point(void