On 29 May 2012 12:50, Magda Stefan <[email protected]> wrote:
>         I'm using a program that will write every 1 second in 2 files de
> values that I need: eth0_delay.out and eth0_datarate.out.In those files it
> is only one row that contains a string[15] that represent the measured
> values from my interface.

This pair of files contains just one pair of values?
That means you've got a single row in the table?

Why are you using a table at all?
If you've only got one value, then surely you only need a pair
of scalar objects?




>     This is what I have tried to do:
> ##################################################################################
> int
> netSnmpPrvTable_load(netsnmp_cache * cache, void *vmagic)
> {
>     netsnmp_tdata  *table = (netsnmp_tdata *) vmagic;
>     netsnmp_tdata_row *row;
>     FILE           *fp;
>     char            buf[STRMAX];
>     struct netSnmpPrvTable_entry *entry;
>
>     printf("Reading file: eth0_delay.out\n");
>     fp = fopen("/tmp/eth0_delay", "r");
>
>     long netSnmpPrvIndex=1;
>     netsnmp_tdata_row *this;
>
>     printf("loading cache: %d\n" ,(int) &cache);
>
>
>   // while (fgets(buf, STRMAX, fp)) {
>         /*
>          * Unpick 'buf' to extract the index values...
>          */
>     //////////////////////////////////////////////// Trying to bind static
> values/////////
>     row->data = entry;

Where does 'entry' come from?

>     strcpy(entry->netSnmpPrvOWD,"1234");
>     entry->netSnmpPrvOWD_len=4;
>     strcpy(entry->netSnmpPrvOWD,"4321");
>     entry->netSnmpPrvOWD_len=4;
>
>
>      entry->netSnmpPrvIndex = 1;
>         netsnmp_tdata_row_add_index(row, ASN_INTEGER,
>                                 &(entry->netSnmpPrvIndex),
>                                 sizeof(entry->netSnmpPrvIndex));
>         netsnmp_tdata_add_row(table, row);

This is where the data structure for holding the row values
is created.   Here - not before.

>
> //////////////////////////////////////////////////////////////////////////////////////
>         this = netSnmpPrvTable_createEntry(table, netSnmpPrvIndex);
>         /*
>          * ... and then populate 'this' with the column values
>          */

Please note the comment above.
And *THEN* (not before) populate 'this' (not 'entry') with the column values.




> when I start the subagent it looks like:
>
> cache created: -1078654040
> table refistered: -1078654036
> NET-SNMP version 5.5 AgentX subagent connected
> netSnmpPrvTable_subagent is up and running.
>
> And then for the request: snmpget -v2c -c public localhost
> .1.3.6.1.4.1.8072.9999.9999.1.2.1.2.1
> the subagent displays: handling request: 160 and I get the response:
> NET-SNMP-MIB2::netSnmpPrvOWD.1 = No Such Instance currently exists at this OID

I'd have expected the subagent to crash, since you're dereferencing
a variable (entry) that you haven't initialised.

Dave

------------------------------------------------------------------------------
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-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

Reply via email to