Network port(s) down-juniper-junos

Network port(s) down-juniper-junos

Vendor: juniper

OS: junos

Description:
Indeni will trigger an issue if one or more network ports is down.

Remediation Steps:
Review the cause for the ports being down.
|||
|1. On the device command line interface run “show interfaces extensive” command to check the status of the interface.
|2. Execute “show configuration interface” command to check interface configuration.
|3. Check the encapsulation type and physical media on the port.
|4. Check the port specification and the fiber cable.
|5. Review the following article on Juniper TechLibrary for more information: Operational Commands: show interfaces (SRX Series).

How does this work?
This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the “show interfaces extensive” command. The output includes all the interface related information and statistics.

Why is this important?
Capture the interface state. If an interface transitions from up to down an alert would be raised.

Without Indeni how would you find this?
It is possible to poll this data through SNMP. Interface state transitions will generate a syslog event.

junos-show-interfaces-extensive

name: junos-show-interfaces-extensive
description: JUNOS get interface information (including stats)
type: monitoring
monitoring_interval: 1 minute
requires:
  vendor: juniper
  os.name: junos
comments:
  network-interface-state:
    why: |
      Capture the interface state. If an interface transitions from up to down an alert would be raised.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: true
  network-interface-admin-state:
    why: |
      Capture the interface administrative state.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: true
  network-interface-description:
    why: |
      Capture the interface description.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: true
  network-interface-speed:
    why: |
      Capture the interface speed in human readable format such as 1G, 10G, etc. indeni will alert if the speed is below 1G.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-duplex:
    why: |
      Capture the interface duplex in human readable format such as full or half. In modern network environments it is very uncommon to see half-duplex interfaces, and that should be an indication for a potential exception.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: true
  network-interface-rx-frame:
    why: |
      Capture the interface Receive Errors (CRC) counter. If this counter increases an alarm will be raised.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-mac:
    why: |
      Capture the interface MAC address.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-type:
    why: |
      Capture the interface type, for example "Ethernet".
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-rx-bits:
    why: |
      Capture the interface Received bits counter. Knowing the amount of bits and packets flowing through an interface can help estimate an interface's performance and utilization.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-rx-dropped:
    why: |
      Capture the interface Received Errors counter. Packet loss may impact traffic performance.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-rx-packets:
    why: |
      Capture the interface Received Packets counter. Knowing the amount of bits and packets flowing through an interface can help estimate an interface's performance and utilization.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-ipv4-address:
    why: |
      Capture the interface IPv4 address. Only relevant for layer 3 interfaces, including Vlan interfaces (SVI).
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-ipv4-subnet:
    why: |
      Capture the interface IPv4 subnet mask. Only relevant for layer 3 interfaces, including Vlan interfaces (SVI).
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-tx-carrier:
    why: |
      Capture the interface carrier state change counter. It would increase every time the interface changes state from up to down.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-mtu:
    why: |
      Capture the interface MTU (Maximum Transmit Unit). A low MTU may cause issues.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-tx-bits:
    why: |
      Capture the interface Transmitted bits counter. Knowing the amount of bits and packets flowing through an interface can help estimate an interface's performance and utilization.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-tx-errors:
    why: |
      Capture the interface Transmit Errors counter. Transmission errors indicate an issue with duplex/speed matching.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-tx-packets:
    why: |
      Capture the interface Transmitted Packets counter. Knowing the amount of bits and packets flowing through an interface can help estimate an interface's performance and utilization.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
steps:
  -   run:
        type: SSH
        command: show interfaces extensive | display xml
      parse:
        type: XML
        file: show-interfaces-extensive.parser.1.xml.yaml

junos-show-interfaces-extensive

name: junos-show-interfaces-extensive
description: JUNOS get interface information (including stats)
type: monitoring
monitoring_interval: 1 minute
requires:
  vendor: juniper
  os.name: junos
comments:
  network-interface-state:
    why: |
      Capture the interface state. If an interface transitions from up to down an alert would be raised.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: true
  network-interface-admin-state:
    why: |
      Capture the interface administrative state.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: true
  network-interface-description:
    why: |
      Capture the interface description.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: true
  network-interface-speed:
    why: |
      Capture the interface speed in human readable format such as 1G, 10G, etc. indeni will alert if the speed is below 1G.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-duplex:
    why: |
      Capture the interface duplex in human readable format such as full or half. In modern network environments it is very uncommon to see half-duplex interfaces, and that should be an indication for a potential exception.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: true
  network-interface-rx-frame:
    why: |
      Capture the interface Receive Errors (CRC) counter. If this counter increases an alarm will be raised.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-mac:
    why: |
      Capture the interface MAC address.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-type:
    why: |
      Capture the interface type, for example "Ethernet".
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-rx-bits:
    why: |
      Capture the interface Received bits counter. Knowing the amount of bits and packets flowing through an interface can help estimate an interface's performance and utilization.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-rx-dropped:
    why: |
      Capture the interface Received Errors counter. Packet loss may impact traffic performance.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-rx-packets:
    why: |
      Capture the interface Received Packets counter. Knowing the amount of bits and packets flowing through an interface can help estimate an interface's performance and utilization.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-ipv4-address:
    why: |
      Capture the interface IPv4 address. Only relevant for layer 3 interfaces, including Vlan interfaces (SVI).
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-ipv4-subnet:
    why: |
      Capture the interface IPv4 subnet mask. Only relevant for layer 3 interfaces, including Vlan interfaces (SVI).
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-tx-carrier:
    why: |
      Capture the interface carrier state change counter. It would increase every time the interface changes state from up to down.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-mtu:
    why: |
      Capture the interface MTU (Maximum Transmit Unit). A low MTU may cause issues.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-tx-bits:
    why: |
      Capture the interface Transmitted bits counter. Knowing the amount of bits and packets flowing through an interface can help estimate an interface's performance and utilization.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-tx-errors:
    why: |
      Capture the interface Transmit Errors counter. Transmission errors indicate an issue with duplex/speed matching.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
  network-interface-tx-packets:
    why: |
      Capture the interface Transmitted Packets counter. Knowing the amount of bits and packets flowing through an interface can help estimate an interface's performance and utilization.
    how: |
      This script logs into the Juniper JUNOS-based device using SSH and retrieves the output of the "show interfaces extensive" command.
      The output includes all the interface related information and statistics.
    can-with-snmp: true
    can-with-syslog: false
steps:
  -   run:
        type: SSH
        command: show interfaces extensive | display xml
      parse:
        type: XML
        file: show-interfaces-extensive.parser.1.xml.yaml

cross_vendor_network_port_down

package com.indeni.server.rules.library.core
import com.indeni.ruleengine.expressions.conditions.{And, Equals}
import com.indeni.ruleengine.expressions.core.{StatusTreeExpression, _}
import com.indeni.ruleengine.expressions.data.{SelectTagsExpression, SelectTimeSeriesExpression, TimeSeriesExpression}
import com.indeni.server.common.data.conditions.True
import com.indeni.server.rules._
import com.indeni.server.rules.library.{ConditionalRemediationSteps, PerDeviceRule, RuleHelper}
import com.indeni.server.sensor.models.managementprocess.alerts.dto.AlertSeverity


case class PortIsDownRule() extends PerDeviceRule with RuleHelper {

  override val metadata: RuleMetadata = RuleMetadata.builder("cross_vendor_network_port_down", "Network port(s) down",
    "Indeni will trigger an issue if one or more network ports is down.", AlertSeverity.CRITICAL, categories = Set(RuleCategory.HealthChecks), deviceCategory = DeviceCategory.AllDevices).build()

  override def expressionTree(context: RuleContext): StatusTreeExpression = {

    val actualValue = TimeSeriesExpression[Double]("network-interface-state").last
    val adminValue = TimeSeriesExpression[Double]("network-interface-admin-state").last

    StatusTreeExpression(
      // Which objects to pull (normally, devices)
      SelectTagsExpression(context.metaDao, Set(DeviceKey), True),

      // What constitutes an issue
      And(StatusTreeExpression(
        // The additional tags we care about (we'll be including this in alert data)
        SelectTagsExpression(context.tsDao, Set("name"), withTagsCondition("network-interface-state")),
        And(
          StatusTreeExpression(
            SelectTimeSeriesExpression[Double](context.tsDao, Set("network-interface-state"), denseOnly = false),
            Equals(ConstantExpression[Option[Double]](Some(0)), actualValue)
          ).withoutInfo().asCondition(),
          StatusTreeExpression(
            SelectTimeSeriesExpression[Double](context.tsDao, Set("network-interface-admin-state"), denseOnly = false),
            adminValue.isNot(0.0)
          ).withoutInfo().asCondition().orElse(Some(true))
        )
      ).withSecondaryInfo(
        scopableStringFormatExpression("${scope(\"name\")}"),
        EMPTY_STRING,
        title = "Ports Affected"
      ).asCondition(), generateDevicePassiveAndPassiveLinkStateCondition(context.tsDao))
    ).withRootInfo(
      getHeadline(),
      ConstantExpression("One or more ports are down."),
      ConditionalRemediationSteps("Review the cause for the ports being down.",
        RemediationStepCondition.VENDOR_JUNIPER ->
          """|
            |1. On the device command line interface run "show interfaces extensive" command to check the status of the interface.
            |2. Execute "show configuration interface" command to check interface configuration.
            |3. Check the encapsulation type and physical media on the port.
            |4. Check the port specification and the fiber cable.
            |5. Review the following article on Juniper TechLibrary for more information: <a target="_blank" href="https://www.juniper.net/documentation/en_US/junos/topics/reference/command-summary/show-interfaces-security.html#jd0e1772">Operational Commands: show interfaces (SRX Series)</a>.""".stripMargin,
        RemediationStepCondition.VENDOR_FORTINET ->
          """|
            |1. Monitor hardware network operations (e.g. speed, duplex settings) by using the "diag hardware deviceinfo nic <interface>" FortiOS command.
            |2. Run the command "diag hardware deviceinfo nic <interface>" command to display a list of hardware related names and values. Review the next link for more details: http://help.fortinet.com/fos50hlp/54/Content/FortiOS/fortigate-toubleshooting-54/troubleshooting_tools.htm
            |3. Run the hidden FortiOS command "fnsysctl cat /proc/net/dev" to get a summary of  the interface statistics.
            |4. Check for a mismatch in the speed and duplex interface settings on two sides of a cable, or for a damaged cable / SFP. Try to manually configure both sides to the same speed/duplex mode when you can. For more information, review "Symptoms of Ethernet speed/duplex mismatches" at http://kb.fortinet.com/kb/documentLink.do?externalID=10653
            |5. Review the log history for interfaces status changes.
            |6. Review the interface configuration. For more information, use the following interface configuration guide: http://help.fortinet.com/fos50hlp/52data/Content/FortiOS/fortigate-system-administration-52/Interfaces/interfaces.htm""".stripMargin
      )
    )
  }
}