Blog Viewer

Scripting How-To: Get the interface-flapped time in seconds instead of in days and hours

By Erdem posted 02-22-2016 06:50

  

Overview

 

To retrieve the interface-flapped time in seconds instead of in days and hours from a SLAX script

 

Discussion


The interface-flapped time from the show interfaces command in Junos OS indicates the last time the interface went down and came back up. This information is useful when you’re trying to figure out why traffic is lost on your network. The <get-interface-information> command output shows the ./interface-flapped time in days and hours.

 

For example:
<interface-flapped junos:seconds="273880">2013-02-08 01:48:40 EST (3d 04:04 ago)</interface-flapped>


But the XML format for show interfaces ( show interfaces | display xml ) displays that the last-flapped time is tracked in seconds.

 

It is possible to get the interface-flapped time from the show interfaces command in Junos OS in seconds instead of in days and hours.


Solution

In the SLAX script, to retrieve "junos:seconds" instead of the full date/day&hours, use:


./interface-flapped/@junos:seconds

This returns the interface-flapped time in seconds.

 

For example:
./interface-flapped output:
2013-02-08 01:48:40 EST (3d 04:50 ago)

./interface-flapped/@junos:seconds output:
276603

 


#Slax
#How-To
#JUNOS

Permalink