Re: How to implement Counter64
"Dave Shield" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
On 09/10/2007, Vinh Nguyen <[email protected]> wrote: > Does anyone know how to implement a Counter64 variable (in a subagent) > using net-snmp? Such values are handled using "struct counter64" variables. This is basically two 32-bit integers bundled together, containing the low and high order halves of the 64-bit value. There's an example of this in the file 'mibgroup/ucd-snmp/diskio.c' Look for mention of DISKIO_NREADX or DISKIO_NWRITTENX This particular module uses the old UCD v4 API, so the style of code is very different from the v5 helper-based approach. But the way of handling 64-bit values is the same. > From the source code, there seems to be a special struct U64 The type "U64" is a typdef alternative to "struct counter64", yes. > Also, if instead of using that U64 type, I store my data as an "unsigned > long long" (64bit) in C++, and on retrieving data for snmp GET, use > pointer to this variable + set type to ASN_COUNTER64, would it work? No. The Net-SNMP library holds 64-bit values as a pair of 32-bit values, rather than as a single 64-bit value. You'd need to split the "u long long" value into two before passing it into the net-snmp library routines, and then stitch the two halves back again afterwards. Dave ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ 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