Re: CPU consumption

"Marwan Khoury" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hi Dave,

I started following your advise and I used

mib2c mib2c.table_data.conf methodTable

I have 4 questions if you din't mind.
1-Why did mib2c generate the following structure:
struct methodTable_entry {
    /*
     * Index values
     */
    char            name[NNN];
    size_t          name_len;

    /*
     * Column values
     */
    char            name[NNN];
    size_t          name_len;
    u_long          profact_total;
    u_long          profact_ok;

    int             valid;
};
what is the reason behind the existing of two field of value name and 
name_len

2-How can I set the values of each colomn in a row? I have tried to add the 
following (just for testing purposes):
    /*
     * Typical data structure for a row entry
     */
#define XXX 2
#define YYY 3
struct methodTable_entry {
    /*
     * Index values
     */
    char            name[256];
    size_t          name_len;

    /*
     * Column values
     */
    u_long          profact_total;
    u_long          profact_ok;

    int             valid;
};

netsnmp_tdata_row *
methodTable_createEntry(netsnmp_tdata * table_data, char *name,
                        size_t name_len)
{
    struct methodTable_entry *entry;
    netsnmp_tdata_row *row;

    entry = SNMP_MALLOC_TYPEDEF(struct methodTable_entry);
    if (!entry)
        return NULL;

    row = netsnmp_tdata_create_row();
    if (!row) {
        SNMP_FREE(entry);
        return NULL;
    }

   entry-> profact_total=1;
   entry-> profact_ok=1;

   row->data = entry;
    memcpy(entry->name, name, name_len);
    entry->name_len = name_len;

    netsnmp_tdata_row_add_index(row, ASN_OCTET_STR, entry->name, name_len);
    netsnmp_tdata_add_row(table_data, row);
    return row;
}

and the following command:
env MIBS=All snmpwalk -v 2c -c public localhost jpm
gave:
JINNY-JPM-MIB::profact-total.0 = Counter32: 0
JINNY-JPM-MIB::profact-ok.0 = Counter32: 0

What am I doing wrong? How can I add the value of a row colomn

3-My aim is to read the OID from the snmp request and fetch the value of it 
from a shared memory, How can I extract the OID from the request in order to 
print it as a string and search fro it in the shared memory?

4-Am I using the proper configuration file in mib2c to realise what I need?

Best Regards,
Marwan


----- Original Message ----- 
From: "Dave Shield" <[email protected]>
To: "Marwan Khoury" <[email protected]>
Cc: <[email protected]>
Sent: Tuesday, August 25, 2009 10:23 AM
Subject: Re: CPU consumption


> 2009/8/25 Marwan Khoury <[email protected]>:
>> From whatI understand I need to generate a C file and an H file for each
>> node that I have in my mib.
>
> No.
> You would typically have one pair of code files for each table,
> and another for (all of) the scalar objects.   But it's also possible
> to combine two or more related tables, or a table and associated
> scalars, into the same code file.
>   That would normally be done by creating separate code files
> (using mib2c) and then combining the files manually.
>
>
>
>> woud i have to use mib2c for each node? and what configuration file 
>> should i
>> use? I need to search for these entries in a table that is loaded in the
>> subagent and
>
>> Should I be doing
>> mib2c -c mib2c.scalar.conf profact-total
>> mib2c -c mib2c.scalar.conf profact-ok
>
> No - "mib2c -c mib2c.scalar.conf  jpm"
> should generate a single code file for all of the scalar objects.
>
>
>> mib2c -S cache=1 -c mib2c.table_data.conf methodTable
>
> That would be a sensible starting point.
>
> Dave


--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.409 / Virus Database: 270.13.65/2324 - Release Date: 08/24/09 
12:55:00


------------------------------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.