Below is my mib2c generated code for my own enterprise...
while compiling it it is showing following error :
# gcc -I/usr/local/include ionline.c -lnetsnmpagent
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function
`_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
please help me to get out of this error..
thanks in advance
-jatin
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.int_watch.conf 13957 2005-12-20 15:33:08Z tanders $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "ionline.h"
/*
* The variables we want to tie the relevant OIDs to.
* The agent will handle all GET and (if applicable) SET requests
* to these variables automatically, changing the values as needed.
*/
int cpuPercentUsage = 0; /* XXX: set default value */
/*
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
*/
void
init_ionline(void)
{
netsnmp_handler_registration *reg;
netsnmp_watcher_info *winfo;
static oid cpuPercentUsage_oid[] = { 1,3,6,1,4,1,21067,3,1,2,3,1 };
/*
* a debugging statement. Run the agent with -Dionline to see
* the output of this debugging statement.
*/
DEBUGMSGTL(("ionline", "Initializing the ionline module\n"));
/*
* Register scalar watchers for each of the MIB objects.
* The ASN type and RO/RW status are taken from the MIB definition,
* but can be adjusted if needed.
*
* In most circumstances, the scalar watcher will handle all
* of the necessary processing. But the NULL parameter in the
* netsnmp_create_handler_registration() call can be used to
* supply a user-provided handler if necessary.
*
* This approach can also be used to handle Counter64, string-
* and OID-based watched scalars (although variable-sized writeable
* objects will need some more specialised initialisation).
*/
DEBUGMSGTL(("ionline",
"Initializing cpuPercentUsage scalar integer. Default value =
%d\n",
cpuPercentUsage));
reg = netsnmp_create_handler_registration(
"cpuPercentUsage",NULL,
cpuPercentUsage_oid, OID_LENGTH(cpuPercentUsage_oid),
HANDLER_CAN_RONLY);
winfo = netsnmp_create_watcher_info(
&cpuPercentUsage, sizeof(long),
ASN_INTEGER, WATCHER_FIXED_SIZE);
////winfo->max_size = sizeof(cpuPercentUsage);
if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) {
snmp_log( LOG_ERR, "Failed to register watched cpuPercentUsage" );
}
int handle_diskp(netsnmp_mib_handler *handler,netsnmp_handler_registration
*reginfo,
netsnmp_agent_request_info *reqinfo,netsnmp_request_info
*requests)
{
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode)
{
int data=20;
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb,
ASN_INTEGER,
// XXX: a pointer to the scalar's data
(u_char *) data,
// XXX: the length of the data in bytes
sizeof(data)
);
break;
default:
// we should never get here, so this is a really bad error
snmp_log(LOG_ERR, "unknown mode (%d) in handle_diskp\n",
reqinfo->mode );
printf("error to getting value\n");
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
------------------------------------------------------------------------------
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
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders