Support Support Downloads Knowledge Base Juniper 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

JUNOScript for utility MIB of 64-bit system uptime

0

0

Article ID: KB30674 KB Last Updated: 03 Dec 2015Version: 1.0
Summary:

This JUNOScript overcomes the 497-day limitation of the standard sysUpTime MIB.

Symptoms:

The standard sysUpTime MIB has a 32-bit value and its unit is 0.01 seconds. Because of this, it can only express up to 497 days, 3 hours, 27 minutes, and 52.95 seconds. However, in many cases, system uptime is longer than this limitation. With the Junos utility MIB described in this article, system uptime can be longer than 497 days.

Cause:

The standard sysUpTime MIB has a 32-bit value.

Solution:

Background information:

  • Standalone system and virtual-chassis system need different scripts.
  • Even when EX4200 or EX4500 are being used as a standalone system, they need the script for virtual chassis.
  • You can distinguish which script is necessary for your system by using the show system uptime | display xml command.

Step 1.  JUNOScript for Utility MIB
Standalone System


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/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);
  }
}

-----------------

jun@EX8208_3_RE0> show system uptime | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/12.3I0/junos">
    <system-uptime-information xmlns="http://xml.juniper.net/junos/12.3I0/junos">
        <current-time>
            <date-time junos:seconds="1448610768">2015-11-27 16:52:48 KST</date-time>
        </current-time>
        <system-booted-time>
            <date-time junos:seconds="1447660028">2015-11-16 16:47:08 KST</date-time>
            <time-length junos:seconds="950740">1w4d 00:05</time-length>
        </system-booted-time>
        <protocols-started-time>
            <date-time junos:seconds="1447660194">2015-11-16 16:49:54 KST</date-time>
            <time-length junos:seconds="950574">1w4d 00:02</time-length>
        </protocols-started-time>
        <last-configured-time>
            <date-time junos:seconds="1448610058">2015-11-27 16:40:58 KST</date-time>
            <time-length junos:seconds="710">00:11:50</time-length>
            <user>jun</user>
        </last-configured-time>
        <uptime-information>
            <date-time junos:seconds="1448610768">4:52PM</date-time>
            <up-time junos:seconds="950770">11 days, 6 mins</up-time>
            <active-user-count junos:format="3 users">3</active-user-count>
            <load-average-1>0.01</load-average-1>
            <load-average-5>0.06</load-average-5>
            <load-average-15>0.04</load-average-15>
        </uptime-information>
    </system-uptime-information>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>


Virtual Chassis System

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=="fpc0"]/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);
  }
}

-----------------
jun@EX4200_VC> show system uptime | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/12.3R9/junos">
    <multi-routing-engine-results>

        <multi-routing-engine-item>

            <re-name>fpc0</re-name>

            <system-uptime-information xmlns="http://xml.juniper.net/junos/12.3R9/junos">
                <current-time>
                    <date-time junos:seconds="1426851938">2015-03-20 20:45:38 KST</date-time>
                </current-time>
                <system-booted-time>
                    <date-time junos:seconds="1426241161">2015-03-13 19:06:01 KST</date-time>
                    <time-length junos:seconds="610777">1w0d 01:39</time-length>
                </system-booted-time>
                <protocols-started-time>
                    <date-time junos:seconds="1426241283">2015-03-13 19:08:03 KST</date-time>
                    <time-length junos:seconds="610655">1w0d 01:37</time-length>
                </protocols-started-time>
                <last-configured-time>
                    <date-time junos:seconds="1426851827">2015-03-20 20:43:47 KST</date-time>
                    <time-length junos:seconds="111">00:01:51</time-length>
                    <user>jun</user>
                </last-configured-time>
                <uptime-information>
                    <date-time junos:seconds="1426851938">8:45PM</date-time>
                    <up-time junos:seconds="610807">7 days, 1:40</up-time>
                    <active-user-count junos:format="4 users">4</active-user-count>
                    <load-average-1>0.12</load-average-1>
                    <load-average-5>0.07</load-average-5>
                    <load-average-15>0.05</load-average-15>
                    </uptime-inf ormation>
            </system-uptime-information>
        </multi-routing-engine-item>

    </multi-routing-engine-results>
    <cli>
    <banner>{master:0}</banner>
    </cli>
</rpc-reply>



Step 2.  CLI configuration

set event-options generate-event 1MIN time-interval 60
set event-options policy sysuptime events 1MIN
set event-options policy sysuptime then event-script sysuptime.slax
set event-options event-script file sysuptime.slax

 

Step 3.  Verification

{master:0}
jun@EX4200_VC> show snmp mib walk jnxUtil
jnxUtilCounter64Value.115.121.115.116.101.109.85.112.116.105.109.101 = 610721
jnxUtilCounter64Time.115.121.115.116.101.109.85.112.116.105.109.101 = 07 df 03 14 14 2c 0f 00 2b 09 00

{master:0}
jun@EX4200_VC> show snmp mib walk jnxUtil ascii
jnxUtilCounter64Value."systemUptime" = 610721
jnxUtilCounter64Time."systemUptime" = 07 df 03 14 14 2c 0f 00 2b 09 00
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