Hello everyone,
I have generated a C code with mib2c tool, than implemented
it according to my need. Everything is working fine .I have assigned values
with system calls. These system call calling a shell script and getting
output from there. When I am using SNMPGET or WALK it gives correct values
. I am running these scripts with infinite for( ; ; ) loop to get the data.
Bt when I am trying to get these data with SNMPWALK after 10-15 times it
is returning me all the values " 0 " .What may be the reason behind it? I
want that it should return a correct value continuously, What methods or
changes I can do ??
Please help me ..
Below are my functions..
Thanks in advance.
int
handle_cpuPercentUsage(netsnmp_mib_handler*handler,netsnmp_handler_registrat
ion *reginfo,
netsnmp_agent_request_info *reqinfo,netsnmp_request_info
*requests) {
for(;;)
{
int *dat=(int *)temp(); /// temp function for getting
value
switch(reqinfo->mode)
{
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb,
ASN_INTEGER,
(u_char
*)&dat,sizeof(dat));
break;
default:
snmp_log(LOG_ERR, "unknown mode (%d) in
handle_cpuPercentUsage\n",
reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
sleep(1);
}
}
int temp()
{
int temp=0;
FILE *pipe = NULL;
/* cpu.sh is a script which returns value between 0-100 */
pipe=popen("/home/jatin/net-snmp-5.7.2.rc1/agent/mibgroup/cpu.sh","r");
if(pipe != NULL)
{
if( fscanf(pipe,"%d",&temp) != -1)
{
return temp;
}
}
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders