Re: something about reading kenel information ?

This is a discussion on Re: something about reading kenel information ? within the SNMP Users forums, part of the Networking and Network Related category; 2008/4/25 qugjie <qugjie@qq.com>: > #ifdef UDPSTAT_SYMBOL > (this macro is define in file include/...


Go Back   Usenet Forums > Networking and Network Related > SNMP Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-25-2008
Dave Shield
 
Posts: n/a
Default Re: something about reading kenel information ?

2008/4/25 qugjie <qugjie@qq.com>:
> #ifdef UDPSTAT_SYMBOL
> (this macro is define in file include/net-snmp/system/generic.h )
> auto_nlist(UDPSTAT_SYMBOL, 0, 0);
> #endif
>
> what has done this routine ?


This locates the UDPSTAT_SYMBOL within the running kernel,
ready for when it will be needed later. It does not retreive the
contents of this structure - just finds where the data is.


> UDP_STAT_STRUCTURE udpstat;
> here define a variable udpstat, this variable is used below.
> but what type is it?


It is of type 'UDP_STAT_STRUCTURE'
What type this actually is depends on the O/S

On HP-UX, this is a simple integer.
On Linux, it's an internally defined structure
On Solaris it's "mib2_udp_t"
On Windows it's MIB_UDPSTATS
On Irix (?and some other) systems it's "struct kna"
On BSD-like systems it's "struct udpstat"

Not all of these will actually use the auto_nlist mechanism.
This is probably mainly used for "struct udpstat".

That's one of the problems of having a single code base
that runs on a wide variety of kit, and delves deep into
the (O/S-specific) internals. This was an attempt to
simplify the code - ultimately unsuccessful.

More recently, we've tended to move away from this
#define / #ifdef approach, and have a separate code
file for each architecture - loading the underlying data
into a single common format.
(See 'mibgroup/hardware' for one set of examples)



> The macro UDP_STAT_STRUCTURE is defined above,
> #define UDP_STAT_STRUCTURE struct udpstat
> I cann't fine the struct udpstat where defined.


That will be defined in the system header files.
Assuming that you're using a relevant O/S.



> If i want to get the disk size, which step i must to do?
> In the linex kenel the struct statfs can know this, but
> i don't know how to relate net-snmp to kernel.


That's by far the hardest part of implementing a MIB module.
In general, you're better off avoiding the kernel whenever
possible. Linux in particular provides most information via
the /proc filesystem. Very little of the Linux support in the
Net-SNMP agent will dig directly into the kernel. I'd
forget all about auto_nlist if I were you.




> I know the disk size can also get form /proc/ file system.
> if i get this info from the /proc/file, can it be or not?


That's a better approach - yes.
Although the size of disks wouldn't typically be read from
either the kernel or /proc. The current Net-SNMP code
for reporting on disks uses 'ioctl()' calls on the disk devices
themselves.


> Is there some example?


See
mibgroup/ucd-snmp/disk.c
(which actually works with filesystems, not disks)
and
mibgroup/host/hr_disk.c

Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757...un.com/javaone
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:11 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0