Automation

 View Only
last person joined: 3 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Is the a function to convert JUNOS duration format to seconds or similar

    Posted 02-01-2012 06:52

    Getting the bgp established time for a bgp neighbor returns a string with a duration time. This format I can't figure out how Is the an easy way to convert the below junos duration format to for example seconds. The exslt date funtions use a different duration format. Would be nice note to write my own template if there exist an easy way.

     

    var $get-bgp-summary = <get-bgp-summary-information>;  
    var $bgp-summary = jcs:invoke($get-bgp-summary);
    var $tmp = $bgp-summary/bgp-peer[peer-address=="1.1.1.1"]/elapsed-time;

     

    The output for the @tmp variable can be like:

    10w6d14h

    4:14:43

    10:1

    1

     



  • 2.  RE: Is the a function to convert JUNOS duration format to seconds or similar

    Posted 02-02-2012 09:09

    Sometimes there is an alternative time format included as an attribute of the XML element. Like this element from "show system uptime":

     

    <date-time junos:seconds="1328202458">2012-02-02 10:07:38 MST</date-time>

     

    Does something like that exist in the RPC you're using? If not then you might have to write a conversion template yourself.



  • 3.  RE: Is the a function to convert JUNOS duration format to seconds or similar
    Best Answer

    Posted 02-06-2012 12:22

    Yes I totally overlooked this and wrote a template. But it is probably full of error, so I better take the value that is there directly by the junos:seconds attribute.

     

    The xml showed this

     

    <elapsed-time junos:seconds="285963">3d 7:26:03</elapsed-time>

     

    and reading a value like below gave me the needed information. Thanks a lot for the help

     

    var $get-bgp-summary = <get-bgp-summary-information>;         

    var $test = jcs:invoke($get-bgp-summary);

    <output> $test/bgp-peer[peer-address=="1.1.1.1"]/elapsed-time/@junos:seconds