Support Support Downloads Knowledge Base Apex Support Portal Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[SRX] How to use utility MIB to get the system uptime of both nodes in SRX HA

0

0

Article ID: KB32009 KB Last Updated: 21 Jul 2020Version: 2.0
Summary:

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.

Symptoms:

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

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.

Solution:
  1. Prepare the following Junos Script for both nodes. Put them under the following directory of both nodes (Node0 & Node1), respectively:

    /var/db/scripts/event//

    For Node0, the file name could be sysuptime_node0.slax
    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);
      }
    }


    For Node1, the file name could be sysuptime_node1.slax
    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);
      }
    }
  2. 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
  3. 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 
Modification History:
2020-07-14: Article reviewed for accuracy; no changes required.

Related Links

Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search