Junos OS

 View Only
last person joined: 4 days ago 

Ask questions and share experiences about Junos OS.
  • 1.  show interface command with options

    Posted 26 days ago
    Hello, 

    I'm trying to figure out if there is a syntax to use to show interfaces that are physically down, and if they are down, to also include the last flapped date.

    I was trying to use:
    show interfaces | except "Physical link is Up" | match "Last Flapped|Physical Interface"
    and 
    show interfaces extensive | match "Physical link is Down|flapped"

    However, neither of these give the desired output. It's almost like I need an "If" statement of some sort. 

    Any help is appreciated.

    ------------------------------
    BEN GRASSO
    ------------------------------


  • 2.  RE: show interface command with options

    Posted 25 days ago
    Quick onbox op script if it's something that is useful often enough?...
    Take a look in sh-int-terse for a similar query, and the info that "show int media" is a good start to exclude logical (but I don't think you will get it straight out of the CLI)
    from jnpr.junos import Device
    from jnpr.junos.op.phyport import PhyPortTable
    
    with Device() as dev:
     phyports = PhyPortTable(dev).get()
     print ("|{:10}|{:4} | \"{:32}\"|{:32}|".format("Port", "Link", "Description", "Flapped"))
     for port in phyports:
      port.description = port.description or ""
      print ("|{:10}|{:4} | \"{:32}\"|{:32}|".format(port.name, port.oper, port.description, port.flapped))
    
    vmx01> op url /var/home/user/juniper-interfaces-flapped.py
    |Port      |Link | "Description                     "|Flapped                         |
    |ge-0/0/0  |up   | "MX02_PE1                        "|2022-12-07 11:29:15 UTC (5w1d 22:34 ago)|
    |ge-0/0/1  |up   | "MX03_PE2                        "|2022-12-07 11:29:15 UTC (5w1d 22:34 ago)|
    |ge-0/0/2  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/3  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/4  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/5  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/6  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/7  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/8  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/9  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    
    vmx01> op url /var/home/user/juniper-interfaces-flapped.py | except "\|up"
    |Port      |Link | "Description                     "|Flapped                         |
    |ge-0/0/2  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/3  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/4  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/5  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/6  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/7  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/8  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    |ge-0/0/9  |down | "                                "|2022-12-07 11:29:16 UTC (5w1d 22:34 ago)|
    ​

    You can brute force it with bash from off-box too..

    ssh vmx01 "show int media ge-*" | egrep "(Phys|flapped)" | tr -d "\\n" | sed -e 's/Physical interface/\nPhysical interfaces/g' | grep "is Down"
    Physical interfaces: ge-0/0/2, Enabled, Physical link is Down  Last flapped   : 2022-12-07 11:29:16 UTC (5w1d 22:46 ago)
    Physical interfaces: ge-0/0/3, Enabled, Physical link is Down  Last flapped   : 2022-12-07 11:29:16 UTC (5w1d 22:46 ago)
    Physical interfaces: ge-0/0/4, Enabled, Physical link is Down  Last flapped   : 2022-12-07 11:29:16 UTC (5w1d 22:46 ago)
    Physical interfaces: ge-0/0/5, Enabled, Physical link is Down  Last flapped   : 2022-12-07 11:29:16 UTC (5w1d 22:46 ago)
    Physical interfaces: ge-0/0/6, Enabled, Physical link is Down  Last flapped   : 2022-12-07 11:29:16 UTC (5w1d 22:46 ago)
    Physical interfaces: ge-0/0/7, Enabled, Physical link is Down  Last flapped   : 2022-12-07 11:29:16 UTC (5w1d 22:46 ago)
    Physical interfaces: ge-0/0/8, Enabled, Physical link is Down  Last flapped   : 2022-12-07 11:29:16 UTC (5w1d 22:46 ago)
    Physical interfaces: ge-0/0/9, Enabled, Physical link is Down  Last flapped   : 2022-12-07 11:29:16 UTC (5w1d 22:46 ago)