Network port(s) running in low speed-paloaltonetworks-panos

error
health-checks
panos
paloaltonetworks
Network port(s) running in low speed-paloaltonetworks-panos
0

#1

Network port(s) running in low speed-paloaltonetworks-panos

Vendor: paloaltonetworks

OS: panos

Description:
Indeni will alert one or more network ports is running in a speed lower than 1000Mbps.

Remediation Steps:
Many times ports are in a low speed due to an autonegotation error or a misconfiguration.

How does this work?
This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the actual runtime speed of each interface.

Why is this important?
Generally, these days network interfaces are set at 1Gbps or more. Sometimes, due to a configuration or device issue, an interface can be set below that (to 100mbps or even 10mbps). As that is usually not the intended behavior, it is important to track the speed of all network interfaces.

Without Indeni how would you find this?
The status of network interfaces is visible through the web interface. If a configured interface is down, it will appear with a red indicator.

panos-show-interface

#! META
name: panos-show-interface
description: Fetch interface information and stats
type: monitoring
monitoring_interval: 5 minute
requires:
    vendor: paloaltonetworks
    os.name: panos
    product: firewall

#! COMMENTS
network-interface-admin-state:
    why: |
        If a network interface is set to be up (what's known as "admin up") but is actually down (a cable is not connected, the device on the other side is down, etc.) it is important to know.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for interfaces that are set to be up, but are actually down.
    without-indeni: |
        An administrator would normally use SNMP or write a script to poll the status and details of network interfaces and alert accordingly.
    can-with-snmp: true
    can-with-syslog: true
network-interface-speed:
    why: |
        Generally, these days network interfaces are set at 1Gbps or more. Sometimes, due to a configuration or device issue, an interface can be set below that (to 100mbps or even 10mbps). As that is usually _not_ the intended behavior, it is important to track the speed of all network interfaces.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the actual runtime speed of each interface.
    without-indeni: |
        The status of network interfaces is visible through the web interface. If a configured interface is down, it will appear with a red indicator.
    can-with-snmp: true
    can-with-syslog: true
network-interface-bandwidth-mbps:
    why: |
        This is similar to network-interface-speed but returns double value for alerting purpose.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the actual runtime speed of each interface.
    without-indeni: |
        The status of network interfaces is visible through the web interface. If a configured interface is down, it will appear with a red indicator.
    can-with-snmp: true
    can-with-syslog: true
network-interface-duplex:
    why: |
        Generally, these days network interfaces are set at full duplex. Sometimes, due to a configuration or device issue, an interface can be set to half duplex. As that is usually _not_ the intended behavior, it is important to track the duplex setting of all network interfaces.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the actual runtime duplex of each interface.
    without-indeni: |
        The duplex setting of network interfaces can be manually reviewed through the CLI.
    can-with-snmp: true
    can-with-syslog: true
network-interface-tx-packets:
    why: |
        Tracking the number of packets flowing through each network interface is important to identify potential issues, spikes in traffic, etc.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the number of packets transmitted through the interface.
    without-indeni: |
        The traffic statistics of network interfaces can be manually reviewed through the CLI.
    can-with-snmp: true
    can-with-syslog: true
network-interface-tx-bytes:
    why: |
        Tracking the amount of data flowing through each network interface is important to identify potential issues, spikes in traffic, etc.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the number of bytes transmitted through the interface.
    without-indeni: |
        The traffic statistics of network interfaces can be manually reviewed through the CLI.
    can-with-snmp: true
    can-with-syslog: true
network-interface-rx-packets:
    why: |
        Tracking the number of packets flowing through each network interface is important to identify potential issues, spikes in traffic, etc.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the number of packets received through the interface.
    without-indeni: |
        The traffic statistics of network interfaces can be manually reviewed through the CLI.
    can-with-snmp: true
    can-with-syslog: true
network-interface-rx-bytes:
    why: |
        Tracking the amount of data flowing through each network interface is important to identify potential issues, spikes in traffic, etc.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the number of bytes received through the interface.
    without-indeni: |
        The traffic statistics of network interfaces can be manually reviewed through the CLI.
    can-with-snmp: true
    can-with-syslog: true
network-interface-rx-dropped:
    why: |
        If incoming packets are being dropped on a network interface, it is important to be aware of it. This may be due to a high load on the firewall, or another capacity issue.
    how: |
        This script logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for the number of packets dropped on an interface.
    without-indeni: |
        The traffic statistics of network interfaces can be manually reviewed through the CLI.
    can-with-snmp: true
    can-with-syslog: true
network-interface-state:
    why: |
        If a network interface is set to be up (what's known as "admin up") but is actually down (a cable is not connected, the device on the other side is down, etc.) it is important to know.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it looks for interfaces that are set to be up, but are actually down.
    without-indeni: |
        An administrator would normally use SNMP or write a script to poll the status and details of network interfaces and alert accordingly.
    can-with-snmp: true
    can-with-syslog: true
network-interface-mtu:
    why: |
        The MTU of an interface may be inadvertently set to a low value. It's important to know if this happens and fix it.
    how: |
        This alert logs into the Palo Alto Networks firewall through SSH and retrieves the status of all network interfaces. In that output, it retrieves the MTU values.
    without-indeni: |
        Alerting on low MTU values normally requires scripting to be done by the administrator.
    can-with-snmp: true
    can-with-syslog: true
network-interface-mac:
    skip-documentation: true
network-interface-rx-errors:
    skip-documentation: true
network-interfaces:
    skip-documentation: true

#! REMOTE::HTTP
url: /api?type=op&cmd=<show><interface>all</interface></show>&key=${api-key}
protocol: HTTPS

#! PARSER::XML
_vars:
    root: /response/result
_dynamic_vars:
    _dynamic:
        nic:
            _text: "${root}/ifnet/entry[contains(name, '/')]/name"

#! REMOTE::HTTP
url: /api?type=op&cmd=<show><interface>${nic}</interface></show>&key=${api-key}
protocol: HTTPS

#! PARSER::XML
_vars:
    root: /response/result
_metrics:
    -
        _tags:
            "im.name":
                _constant: "network-interface-state"
            "name":
                _text: "${root}/ifnet/name"
            "live-config":
                _constant: "true"
            "display-name":
                _constant: "Interface state"
            "im.dstype.displayType":
                _constant: "state"
            "im.identity-tags":
                _constant: "name"
        _temp:
            "state":
                _text: "${root}/hw/state"
        _transform:
            _value.double: |
                {
                    if (temp("state") == "up") {
                        print "1"
                    } else {
                        print "0"
                    }
                }
    -
        _tags:
            "im.name":
                _constant: "network-interface-admin-state"
            "name":
                _text: "${root}/ifnet/name"
            "live-config":
                _constant: "true"
            "display-name":
                _constant: "Interface admin states"
            "im.dstype.displayType":
                _constant: "state"
            "im.identity-tags":
                _constant: "name"
        _temp:
            "state_c":
                _text: "${root}/hw/state_c"
        _transform:
            _value.double: |
                {
                    if (temp("state_c") == "up" || temp("state_c") == "auto") {
                        print "1"
                    } else {
                        print "0"
                    }
                }
    -
        _tags:
            "im.name":
                _constant: "network-interface-duplex"
            "name":
                _text: "${root}/ifnet/name"
            "live-config":
                _constant: "true"
            "display-name":
                _constant: "Interface duplex settings"
            "im.identity-tags":
                _constant: "name"
        _value.complex:
            value:
                _text: "${root}/hw[not(duplex = 'unknown')]/duplex"
    -
        _tags:
            "im.name":
                _constant: "network-interface-speed"
            "name":
                _text: "${root}/ifnet/name"
            "live-config":
                _constant: "true"
            "display-name":
                _constant: "Interface speeds"
            "im.identity-tags":
                _constant: "name"
        _temp:
            "speed":
                _text: ${root}/hw[not(speed = 'unknown')]/speed
        _transform:
            _value.complex:
                value: |
                    {
                        print temp("speed") "M"
                    }
    -
        _tags:
            "im.name":
                _constant: "network-interface-bandwidth-mbps"
            "name":
                _text: "${root}/ifnet/name"
        _transform:
            _tags:
                "name": |
                    {
                        print dynamic("nic")
                    }
        _value.double:
            _text: ${root}/hw[not(speed = 'unknown')]/speed
    -
        _tags:
            "im.name":
                _constant: "network-interface-mtu"
            "name":
                _text: "${root}/ifnet/name"
            "live-config":
                _constant: "true"
            "display-name":
                _constant: "Interface MTU settings"
            "im.dstype.displayType":
                _constant: "number"
            "im.identity-tags":
                _constant: "name"
        _value.complex:
            value:
                _text: "${root}/ifnet/mtu"
    -
        _tags:
            "im.name":
                _constant: "network-interface-mac"
            "name":
                _text: "${root}/ifnet/name"
            "live-config":
                _constant: "true"
            "display-name":
                _constant: "Interface mac addresses"
            "im.identity-tags":
                _constant: "name"
        _value.complex:
            value:
                _text: "${root}/hw/mac"
    -
        _tags:
            "im.name":
                _constant: "network-interface-tx-bytes"
            "name":
                _text: "${root}/ifnet/name"
            "im.dsType":
                _constant: "counter"
        _value.double:
            _text: "${root}/ifnet/counters/hw/entry/obytes"
    -
        _tags:
            "im.name":
                _constant: "network-interface-rx-bytes"
            "name":
                _text: "${root}/ifnet/name"
            "im.dsType":
                _constant: "counter"
        _value.double:
            _text: "${root}/ifnet/counters/hw/entry/ibytes"
    -
        _tags:
            "im.name":
                _constant: "network-interface-tx-packets"
            "name":
                _text: "${root}/ifnet/name"
            "im.dsType":
                _constant: "counter"
        _value.double:
            _text: "${root}/ifnet/counters/hw/entry/opackets"
    -
        _tags:
            "im.name":
                _constant: "network-interface-rx-packets"
            "name":
                _text: "${root}/ifnet/name"
            "im.dsType":
                _constant: "counter"
        _value.double:
            _text: "${root}/ifnet/counters/hw/entry/ipackets"
    -
        _tags:
            "im.name":
                _constant: "network-interface-rx-errors"
            "name":
                _text: "${root}/ifnet/name"
            "live-config":
                _constant: "true"
            "im.dsType":
                _constant: "counter"
            "display-name":
                _constant: "Interface RX errors"
            "im.dstype.displayType":
                _constant: "number"
            "im.identity-tags":
                _constant: "name"
        _value.double:
            _text: "${root}/ifnet/counters/hw/entry/ierrors"
    -
        _tags:
            "im.name":
                _constant: "network-interface-rx-dropped"
            "name":
                _text: "${root}/ifnet/name"
            "live-config":
                _constant: "true"
            "display-name":
                _constant: "Interface rx dropped"
            "im.dsType":
                _constant: "counter"
            "im.dstype.displayType":
                _constant: "number"
            "im.identity-tags":
                _constant: "name"
        _value.double:
            _text: "${root}/ifnet/counters/hw/entry/idrops"
    -
        _tags:
            "im.name":
                _constant: "network-interfaces"
        _value.complex:
            "name":
                _text: "${root}/ifnet/name"
        _value: complex-array

cross_vendor_network_port_speed_low

package com.indeni.server.rules.library.templatebased.crossvendor

import com.indeni.ruleengine.expressions.Expression
import com.indeni.ruleengine.expressions.conditions.{Equals => RuleEquals, Not => RuleNot, Or => RuleOr}
import com.indeni.ruleengine.expressions.data.SnapshotExpression
import com.indeni.server.rules.RuleContext
import com.indeni.server.rules.library._

/**
  *
  */
case class cross_vendor_network_port_speed_low() extends SingleSnapshotValueCheckTemplateRule(
  ruleName = "cross_vendor_network_port_speed_low",
  ruleFriendlyName = "All Devices: Network port(s) running in low speed",
  ruleDescription = "Indeni will alert one or more network ports is running in a speed lower than 1000Mbps.",
  metricName = "network-interface-speed",
  applicableMetricTag = "alert-item-port-speed",
  alertItemsHeader = "Ports Affected",
  alertDescription = "One or more ports are set to a speed lower than 1000Mbps. This is usually an error. Review the list of ports below.",
  baseRemediationText = "Many times ports are in a low speed due to an autonegotation error or a misconfiguration.",
  complexCondition = RuleOr(
    RuleEquals(SnapshotExpression("network-interface-speed").asSingle().mostRecent().value().noneable, RuleHelper.createComplexStringConstantExpression("10M")),
    RuleEquals(SnapshotExpression("network-interface-speed").asSingle().mostRecent().value().noneable, RuleHelper.createComplexStringConstantExpression("100M"))
  ),
  alertItemHeadlineExpersion =
    new Expression[String] {
      val networkInterfaceSpeedExpersion = SnapshotExpression("network-interface-speed").asSingle().mostRecent()
      override def eval(time: Long): String = networkInterfaceSpeedExpersion.eval(time).value.getOrElse("value", "")
      override def args: Set[Expression[_]] = Set(networkInterfaceSpeedExpersion)
    },
  headlineFormat = "%s set has a %s"
  )(
  ConditionalRemediationSteps.OS_NXOS ->
    """|
      |1. Use the "show interface" NX-OS command to display speed and duplex settings of an interface.
      |2. Use the "show interface status" and "show interface capabilities" NX-OS commands to gather more information about ports.
      |3. You can disable link negotiation using the "no negotiate auto" command. Use the "negotiate auto" command to enable auto negotiation on 1-Gigabit ports when the connected peer does not support auto negotiation. By default, auto-negotiation is enabled on 1-Gigabit ports and disabled on 10-Gigabit ports.
      |4. Cisco does not recommend to enable auto negotiation on 10-Gigabit ports. Enabling auto-negotiation on 10-Gigabit ports brings the link down. By default, link negotiation is disabled on 10-Gigabit ports.
      |NOTE: A shut and no shut to the interface may be required after the aforementioned configuration change.""".stripMargin
)