snmpget query error
purushotam rao <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Dear Sir, When I give the snmpwalk command, I am getting the following error.* *Please find the attached .c and .h along with this mail for your kind reference. If possible please correct the code. *Query: [root@localhost ~]*# snmpwalk -v 2c -c devasena localhost .1.3.6.1.4.1.10296.1.1000.1 SNMPv2-SMI::enterprises.10296.1.1000.1 = No Such Object available on this agent at this OID [root@localhost ~]# But my object is having the value. How to check that value? How to give the snmpwalk command? With Regards, U.Purushotham Rao, EE, NMS Group ITI Limited, Bangalore - 560 016. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users
akshaya.c
(text/plain, 4.2 KB)
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.old-api.conf 14476 2006-04-18 17:36:51Z hardaker $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "akshaya.h"
/*
* akshaya_variables_oid:
* this is the top level oid that we want to register under. This
* is essentially a prefix, with the suffix appearing in the
* variable below.
*/
oid akshaya_variables_oid[] = { 1,3,6,1,4,1,10296,1 };
/*
* variable4 akshaya_variables:
* this variable defines function callbacks and type return information
* for the akshaya mib section
*/
struct variable7 akshaya_variables[] = {
/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
#define DEVASENA 1
{DEVASENA, ASN_INTEGER, RWRITE, var_akshaya, 2, { 1000,1 }},
};
/* (L = length of the oidsuffix) */
/** Initializes the akshaya module */
void
init_akshaya(void)
{
DEBUGMSGTL(("akshaya", "Initializing\n"));
/* register ourselves with the agent to handle our mib tree */
REGISTER_MIB("akshaya", akshaya_variables, variable4,
akshaya_variables_oid);
/* place any other initialization junk you need here */
}
/*
* var_akshaya():
* This function is called every time the agent gets a request for
* a scalar variable that might be found within your mib section
* registered above. It is up to you to do the right thing and
* return the correct value.
* You should also correct the value of "var_len" if necessary.
*
* Please see the documentation for more information about writing
* module extensions, and check out the examples in the examples
* and mibII directories.
*/
unsigned char *
var_akshaya(struct variable *vp,
oid *name,
size_t *length,
int exact,
size_t *var_len,
WriteMethod **write_method)
{
/* variables we may use later */
static long long_ret;
static u_long ulong_ret;
static unsigned char string[SPRINT_MAX_LEN];
static oid objid[MAX_OID_LEN];
static struct counter64 c64;
static char *var;
var="1111";
if (header_generic(vp,name,length,exact,var_len,write_method)
== MATCH_FAILED )
return NULL;
/*
* this is where we do the value assignments for the mib results.
*/
switch(vp->magic) {
case DEVASENA:
*write_method = write_devasena;
//*var="Chinnadurai";
//var = VALUE; /* XXX */
return (u_char*) &var;
default:
ERROR_MSG("Dont Try with wrong MIB IDs please - Devasena");
}
return NULL;
}
int
write_devasena(int action,
u_char *var_val,
u_char var_val_type,
size_t var_val_len,
u_char *statP,
oid *name,
size_t name_len)
{
long value;
int size;
switch ( action ) {
case RESERVE1:
if (var_val_type != ASN_INTEGER) {
fprintf(stderr, "write to akshaya not ASN_INTEGER\n");
return SNMP_ERR_WRONGTYPE;
}
if (var_val_len > sizeof(long)) {
fprintf(stderr,"write to akshaya: bad length\n");
return SNMP_ERR_WRONGLENGTH;
}
break;
case RESERVE2:
size = var_val_len;
value = * (long *) var_val;
break;
case FREE:
/* Release any resources that have been allocated */
break;
case ACTION:
/*
* The variable has been stored in 'value' for you to use,
* and you have just been asked to do something with it.
* Note that anything done here must be reversable in the UNDO case
*/
break;
case UNDO:
/* Back out any changes made in the ACTION case */
break;
case COMMIT:
/*
* Things are working well, so it's now safe to make the change
* permanently. Make sure that anything done here can't fail!
*/
break;
}
return SNMP_ERR_NOERROR;
}
akshaya.h
(text/plain, 309 B)
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.old-api.conf 14476 2006-04-18 17:36:51Z hardaker $
*/
#ifndef AKSHAYA_H
#define AKSHAYA_H
/* function declarations */
void init_akshaya(void);
FindVarMethod var_akshaya;
WriteMethod write_devasena;
#endif /* AKSHAYA_H */