Is Counter64 the appropriate SYNTAX for implementing SNMP private MIBs using the /proc/uptime value?

Asked 1 months ago, Updated 1 months ago, 6 views

  • Ubuntu 18.04 (32-bit and 64-bit)
  • net-snmp
  • SNMP v2

SNMP defines hrSystemUptime RFC2790-Host Resources MIB, but hrSystemUptime returns to 0 in approximately 497 days (one count up every 1/100 seconds).4294967295/100/3600/24=>497)

Therefore, I am thinking of using the value obtained from /proc/uptime.Use the left of the two values shown below.

%cat/proc/uptime
24939.24 78721.83

Also, the uptime command seems to use the /proc/uptime value (https://gitlab.com/procps-ng/procps/blob/master/uptime.c#L47 https://gitlab.com/procps-ng/procps/blob/master/proc/sysinfo.c#L106).

And I'm thinking of adding a new private MIB and defining SYNTAX in the MIB as Counter64.

In a Linux implementation, the value to the left of /proc/uptime is obtained in tv_sec and output in unsigned long (linux/uptime.cat master·torvalds/linux).For 64-bit CPUs, unsigned long is a 64-bit representation of the 64MP bit.

    Even though the
  • /proc/uptime value goes up from zero, is it appropriate to use Counter64 for time-handling purposes?(Do you want me to implement it?)
  • Will Counter64 be treated as 64-bit on Linux with 32-bit CPUs?

linux snmp

2022-09-30 13:47

1 Answers

Selfless

yes

RFC 2578 7.1.10.Counter64 For https://www.rfc-editor.org/rfc/rfc2578#section-7.1.10, use

  • Use for incremented values
  • Wrap around to 0

It only says

yes

The value ASN_COUNTER64 is used for snmp_set_var_value().

https://sourceforge.net/p/net-snmp/code/ci/master/tree/snmplib/snmp_client.c#l968

Since the implementation sets the value to structure counter64, pass the structure counter64 to snmp_set_var_value().

structure counter64 is defined in asn1.h.

https://sourceforge.net/p/net-snmp/code/ci/master/tree/include/net-snmp/library/asn1.h#l79

structure counter64 {
    u_long high;
    u_long low;
};

u_long is unsigned long

  • 4 bytes (32-bit) in 32-bit environments
  • 8 bytes (64-bit) in 64-bit environments


2022-09-30 13:47

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.