This is a discussion on Re: something about reading kenel information ? - SNMP ; 2008/4/25 qugjie : > #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 ...
> #ifdef UDPSTAT_SYMBOL
> (this macro is define in file include/net-snmp/system/generic.h )
> auto_nlist(UDPSTAT_SYMBOL, 0, 0);
> 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
> Is there some example?
(which actually works with filesystems, not disks)
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.
Net-snmp-users mailing list
Please see the following page to unsubscribe or change other options: