Discussion:
objects marked not-accessible returned by snmpwalk
(too old to reply)
Tim Culhane
2015-04-27 10:47:08 UTC
Permalink
Hi,

I believe it is correct for index objects in a mib to be marked as
'not-accessible'. Hence, when doing a walk of the mib such oids should be
skipped over and not returned. If you specifically try to get the object
then it should return ' no such object'.

I have a shared object which is loaded by snmpd voa the dlmod directive and
which has the below function for retrieving column values from a table
defined in my mib:

Hi Fulko,

Originally in my  shared object I had the following code to retrieve a
specific column:

***********************************************************************/
/*
* @internal
* Retrieve the value for a particular column
*/
NETSNMP_STATIC_INLINE int
_razorgateSmtpStatusCountersTable_get_column
(razorgateSmtpStatusCountersTable_rowreq_ctx * rowreq_ctx,
netsnmp_variable_list * var, int column)
{
int             rc = SNMPERR_SUCCESS;

DEBUGMSGTL(("internal:razorgateSmtpStatusCountersTable:_mfd_razorgateSmtpSta
tusCountersTable_get_column", "called for %d\n", column));

netsnmp_assert(NULL != rowreq_ctx);

/*
* (INDEX)
razorgateSmtpIPAddress(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/
d/H
*/
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
else if (RAZORGATESMTPSTATUSCOUNTERSTABLE_MIN_COL < column
&& column <= RAZORGATESMTPSTATUSCOUNTERSTABLE_MAX_COL)
{
var->val_len = sizeof(long);
var->type = ASN_INTEGER;
rc = column_value_get(rowreq_ctx,
(long *) var->val.string, column);
}
else
{
snmp_log(LOG_ERR,
"unknown column %d in _razorgateSmtpStatusCountersTable_get_column\n",
column);
}

return rc;
}

However, if I do a talk of the tableall values are returned, including the
index field.


I then removed the if branch dealing with the IPAddress column, e.g.:

if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}

But then if I do a walk of the table I get the below error:


snmpwalk -v2c -c public  10.128.19.86:161 -Os
razorgateSmtpStatusCountersTable
razorgateSmtpStatusCountersTable = No Such Object available on this agent at
this OID

It seems to be failing on the first oid in the table which is the IPAddress
oid.

Can anybody tell me how I should handle requests for oids in my shared
objects when those oids are 'not-accessible'?

Many thanks,

Tim
Bill Fenner
2015-04-27 18:28:05 UTC
Permalink
You don't mention which helper you're using, but if you're using the
table_iterator, is the not-accessible column in
your column_info->details.list?

Bill
Post by Tim Culhane
Hi,
I believe it is correct for index objects in a mib to be marked as
'not-accessible'. Hence, when doing a walk of the mib such oids should be
skipped over and not returned. If you specifically try to get the object
then it should return ' no such object'.
I have a shared object which is loaded by snmpd voa the dlmod directive and
which has the below function for retrieving column values from a table
Hi Fulko,
Originally in my shared object I had the following code to retrieve a
***********************************************************************/
/*
* Retrieve the value for a particular column
*/
NETSNMP_STATIC_INLINE int
_razorgateSmtpStatusCountersTable_get_column
(razorgateSmtpStatusCountersTable_rowreq_ctx * rowreq_ctx,
netsnmp_variable_list * var, int column)
{
int rc = SNMPERR_SUCCESS;
DEBUGMSGTL(("internal:razorgateSmtpStatusCountersTable:_mfd_razorgateSmtpSta
tusCountersTable_get_column", "called for %d\n", column));
netsnmp_assert(NULL != rowreq_ctx);
/*
* (INDEX)
razorgateSmtpIPAddress(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/
d/H
*/
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
else if (RAZORGATESMTPSTATUSCOUNTERSTABLE_MIN_COL < column
&& column <= RAZORGATESMTPSTATUSCOUNTERSTABLE_MAX_COL)
{
var->val_len = sizeof(long);
var->type = ASN_INTEGER;
rc = column_value_get(rowreq_ctx,
(long *) var->val.string, column);
}
else
{
snmp_log(LOG_ERR,
"unknown column %d in _razorgateSmtpStatusCountersTable_get_column\n",
column);
}
return rc;
}
However, if I do a talk of the tableall values are returned, including the
index field.
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
snmpwalk -v2c -c public 10.128.19.86:161 -Os
razorgateSmtpStatusCountersTable
razorgateSmtpStatusCountersTable = No Such Object available on this agent
at
this OID
It seems to be failing on the first oid in the table which is the IPAddress
oid.
Can anybody tell me how I should handle requests for oids in my shared
objects when those oids are 'not-accessible'?
Many thanks,
Tim
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Net-snmp-coders mailing list
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
Tim Culhane
2015-04-28 07:30:01 UTC
Permalink
Hi Bill,



I generated my files using the mfd (mib for dummies) option to mib2c and chose the caching option.



Its not using the table iterator, just the “normal” table helper 
 I think.



Tim





From: Bill Fenner [mailto:***@gmail.com]
Sent: 27 April 2015 19:28
To: Tim Culhane
Cc: Net-SNMP Coders; net-snmp-***@lists.sourceforge.net
Subject: Re: objects marked not-accessible returned by snmpwalk



You don't mention which helper you're using, but if you're using the table_iterator, is the not-accessible column in your column_info->details.list?



Bill





On Mon, Apr 27, 2015 at 6:47 AM, Tim Culhane <***@gmail.com <mailto:***@gmail.com> > wrote:

Hi,

I believe it is correct for index objects in a mib to be marked as
'not-accessible'. Hence, when doing a walk of the mib such oids should be
skipped over and not returned. If you specifically try to get the object
then it should return ' no such object'.

I have a shared object which is loaded by snmpd voa the dlmod directive and
which has the below function for retrieving column values from a table
defined in my mib:

Hi Fulko,

Originally in my shared object I had the following code to retrieve a
specific column:

***********************************************************************/
/*
* @internal
* Retrieve the value for a particular column
*/
NETSNMP_STATIC_INLINE int
_razorgateSmtpStatusCountersTable_get_column
(razorgateSmtpStatusCountersTable_rowreq_ctx * rowreq_ctx,
netsnmp_variable_list * var, int column)
{
int rc = SNMPERR_SUCCESS;

DEBUGMSGTL(("internal:razorgateSmtpStatusCountersTable:_mfd_razorgateSmtpSta
tusCountersTable_get_column", "called for %d\n", column));

netsnmp_assert(NULL != rowreq_ctx);

/*
* (INDEX)
razorgateSmtpIPAddress(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/
d/H
*/
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
else if (RAZORGATESMTPSTATUSCOUNTERSTABLE_MIN_COL < column
&& column <= RAZORGATESMTPSTATUSCOUNTERSTABLE_MAX_COL)
{
var->val_len = sizeof(long);
var->type = ASN_INTEGER;
rc = column_value_get(rowreq_ctx,
(long *) var->val.string, column);
}
else
{
snmp_log(LOG_ERR,
"unknown column %d in _razorgateSmtpStatusCountersTable_get_column\n",
column);
}

return rc;
}

However, if I do a talk of the tableall values are returned, including the
index field.


I then removed the if branch dealing with the IPAddress column, e.g.:

if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}

But then if I do a walk of the table I get the below error:


snmpwalk -v2c -c public 10.128.19.86:161 <http://10.128.19.86:161> -Os
razorgateSmtpStatusCountersTable
razorgateSmtpStatusCountersTable = No Such Object available on this agent at
this OID

It seems to be failing on the first oid in the table which is the IPAddress
oid.

Can anybody tell me how I should handle requests for oids in my shared
objects when those oids are 'not-accessible'?

Many thanks,

Tim
Tim Culhane
2015-04-28 11:33:43 UTC
Permalink
Hi Again,



I notice that MFD_SKIP -- (SNMP_NOSUCHINSTANCE) can be returned if an oid is “reserved”.



I wonder if I could do this for my IPAddress oid and any other oids marked ‘not-accessible’.



Does anybody know if it is possible to get the ‘MAX-ACCESS’ value for an oid from a request via the net-snmp API?



I don’t see anything obvious in the 5.7.3 code base.



Thanks,



Tim





From: Tim Culhane [mailto:***@gmail.com]
Sent: 28 April 2015 08:30
To: 'Bill Fenner'
Cc: 'Net-SNMP Coders'; 'net-snmp-***@lists.sourceforge.net'
Subject: RE: objects marked not-accessible returned by snmpwalk



Hi Bill,



I generated my files using the mfd (mib for dummies) option to mib2c and chose the caching option.



Its not using the table iterator, just the “normal” table helper 
 I think.



Tim





From: Bill Fenner [mailto:***@gmail.com]
Sent: 27 April 2015 19:28
To: Tim Culhane
Cc: Net-SNMP Coders; net-snmp-***@lists.sourceforge.net <mailto:net-snmp-***@lists.sourceforge.net>
Subject: Re: objects marked not-accessible returned by snmpwalk



You don't mention which helper you're using, but if you're using the table_iterator, is the not-accessible column in your column_info->details.list?



Bill





On Mon, Apr 27, 2015 at 6:47 AM, Tim Culhane <***@gmail.com <mailto:***@gmail.com> > wrote:

Hi,

I believe it is correct for index objects in a mib to be marked as
'not-accessible'. Hence, when doing a walk of the mib such oids should be
skipped over and not returned. If you specifically try to get the object
then it should return ' no such object'.

I have a shared object which is loaded by snmpd voa the dlmod directive and
which has the below function for retrieving column values from a table
defined in my mib:

Hi Fulko,

Originally in my shared object I had the following code to retrieve a
specific column:

***********************************************************************/
/*
* @internal
* Retrieve the value for a particular column
*/
NETSNMP_STATIC_INLINE int
_razorgateSmtpStatusCountersTable_get_column
(razorgateSmtpStatusCountersTable_rowreq_ctx * rowreq_ctx,
netsnmp_variable_list * var, int column)
{
int rc = SNMPERR_SUCCESS;

DEBUGMSGTL(("internal:razorgateSmtpStatusCountersTable:_mfd_razorgateSmtpSta
tusCountersTable_get_column", "called for %d\n", column));

netsnmp_assert(NULL != rowreq_ctx);

/*
* (INDEX)
razorgateSmtpIPAddress(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/
d/H
*/
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
else if (RAZORGATESMTPSTATUSCOUNTERSTABLE_MIN_COL < column
&& column <= RAZORGATESMTPSTATUSCOUNTERSTABLE_MAX_COL)
{
var->val_len = sizeof(long);
var->type = ASN_INTEGER;
rc = column_value_get(rowreq_ctx,
(long *) var->val.string, column);
}
else
{
snmp_log(LOG_ERR,
"unknown column %d in _razorgateSmtpStatusCountersTable_get_column\n",
column);
}

return rc;
}

However, if I do a talk of the tableall values are returned, including the
index field.


I then removed the if branch dealing with the IPAddress column, e.g.:

if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}

But then if I do a walk of the table I get the below error:


snmpwalk -v2c -c public 10.128.19.86:161 <http://10.128.19.86:161> -Os
razorgateSmtpStatusCountersTable
razorgateSmtpStatusCountersTable = No Such Object available on this agent at
this OID

It seems to be failing on the first oid in the table which is the IPAddress
oid.

Can anybody tell me how I should handle requests for oids in my shared
objects when those oids are 'not-accessible'?

Many thanks,

Tim
Bill Fenner
2015-04-28 20:46:07 UTC
Permalink
Post by Tim Culhane
Does anybody know if it is possible to get the ‘MAX-ACCESS’ value for an
oid from a request via the net-snmp API?
mib2c has access to it (and in theory it's in charge of getting that info
into the code). There's no access to this info from the request.

Bill
Tim Culhane
2015-04-29 07:52:12 UTC
Permalink
Hi Bill,



But then how can I check if an object is ‘not-accessible’ from my code?



Tim





From: Bill Fenner [mailto:***@gmail.com]
Sent: 28 April 2015 21:46
To: Tim Culhane
Cc: Net-SNMP Coders; net-snmp-***@lists.sourceforge.net
Subject: Re: objects marked not-accessible returned by snmpwalk



On Tue, Apr 28, 2015 at 7:33 AM, Tim Culhane <***@gmail.com <mailto:***@gmail.com> > wrote:

Does anybody know if it is possible to get the ‘MAX-ACCESS’ value for an oid from a request via the net-snmp API?



mib2c has access to it (and in theory it's in charge of getting that info into the code). There's no access to this info from the request.



Bill

Loading...