This article explains how to use utility MIB to get the system uptime of both nodes in SRX HA, especially when the device boot up time length is more than 248 days.
Normally, you can get the system booted time length value using the MIB OID below:
Note: Refer to KB32009 - [SRX] How to get the system booted time using SNMP MIB OID [juniper.net]
jnxBoxInstalled 1.3.6.1.4.1.2636.3.1.5.0
However, when the time length is more than 248 days, the value will stop increasing and stay in 2147483647.
Prepare the following Junos Script for both nodes. Put them under the following directory of both nodes (Node0 & Node1), respectively:
version 1.0; ns junos = "http://xml.juniper.net/junos/*/junos"; ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; ns ext = "http://xmlsoft.org/XSLT/namespace"; match / { <op-script-results> { var $cmd = <command> "show system uptime"; var $out = jcs:invoke($cmd); var $showuptime = ($out/multi-routing-engine-item[re-name=="node0"]/system-uptime-information/uptime-information/up-time/@junos:seconds); var $mibset-fd = <request-snmp-utility-mib-set> { <object-type> "counter64"; <instance> "systemUptime"; <object-value> $showuptime; } var $stdout=jcs:invoke($mibset-fd); } }
version 1.0; ns junos = "http://xml.juniper.net/junos/*/junos"; ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; ns ext = "http://xmlsoft.org/XSLT/namespace"; match / { <op-script-results> { var $cmd = <command> "show system uptime"; var $out = jcs:invoke($cmd); var $showuptime = ($out/multi-routing-engine-item[re-name=="node1"]/system-uptime-information/uptime-information/up-time/@junos:seconds); var $mibset-fd = <request-snmp-utility-mib-set> { <object-type> "counter64"; <instance> "systemUptime"; <object-value> $showuptime; } var $stdout=jcs:invoke($mibset-fd); } }
CLI configuration
set groups node0 event-options generate-event 1MIN time-interval 60 set groups node0 event-options policy sysuptime_node0 events 1MIN set groups node0 event-options policy sysuptime_node0 then event-script sysuptime_node0.slax set groups node0 event-options event-script file sysuptime_node0.slax set groups node1 event-options generate-event 1MIN time-interval 60 set groups node1 event-options policy sysuptime_node1 events 1MIN set groups node1 event-options policy sysuptime_node1 then event-script sysuptime_node1.slax set groups node1 event-options event-script file sysuptime_node1.slax set apply-groups "$[NODE]" commit
Verification
{primary:node0}[edit] root# run show snmp mib walk jnxUtil jnxUtilCounter64Value.115.121.115.116.101.109.85.112.116.105.109.101 = 67071 jnxUtilCounter64Time.115.121.115.116.101.109.85.112.116.105.109.101 = 07 e1 07 15 01 39 31 00 2b 00 00 {primary:node0}[edit] root# run show snmp mib walk jnxUtil ascii jnxUtilCounter64Value."systemUptime" = 67131 jnxUtilCounter64Time."systemUptime" = 07 e1 07 15 01 3a 30 00 2b 00 00 {secondary:node1}[edit] root# run show snmp mib walk jnxUtil jnxUtilCounter64Value.115.121.115.116.101.109.85.112.116.105.109.101 = 2477 jnxUtilCounter64Time.115.121.115.116.101.109.85.112.116.105.109.101 = 07 e1 07 15 02 02 16 00 2b 00 00 {secondary:node1}[edit] root# run show snmp mib walk jnxUtil ascii jnxUtilCounter64Value."systemUptime" = 2537 jnxUtilCounter64Time."systemUptime" = 07 e1 07 15 02 03 16 00 2b 00 00
2020-07-14: Article reviewed for accuracy; no changes required.