Network port(s) running in low speed-fortinet-FortiOS

Network port(s) running in low speed-fortinet-FortiOS
0

Network port(s) running in low speed-fortinet-FortiOS

Vendor: fortinet

OS: FortiOS

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 script logs into the Fortinet firewall using SSH and retrieves the output of the “get system interface physical” and “get system interface” FortiOS commands. The output includes all the interface related information and statistics.

Why is this important?
Capture the physical interface speed in human readable format such as 1G, 10G, etc. More details can be found to the next link: http://help.fortinet.com/cli/fos50hlp/56/Content/FortiOS/fortiOS-cli-ref-56/config/system/interface.htm

Without Indeni how would you find this?
It is possible to poll this data through SNMP.

fortios-get-system-interface

name: fortios-get-system-interface
description: Fortinet firewall check interface stats
type: monitoring
monitoring_interval: 1 minute
requires:
    vendor: fortinet
    os.name: FortiOS
    product: firewall
comments:
    network-interface-state:
        why: |
            Capture the physical interface state. If a physical interface transitions from up to down an alert will be raised. More details can be found to the next link:http://help.fortinet.com/cli/fos50hlp/56/Content/FortiOS/fortiOS-cli-ref-56/config/system/interface.htm
        how: |
            This script logs into the Fortinet firewall using SSH and retrieves the output of the "get system interface physical" and "get system interface" FortiOS commands. The output includes all the interface related information and statistics.
        without-indeni: |
            It is possible to poll this data through SNMP. Interface state transitions will generate a syslog event.
        can-with-snmp: true
        can-with-syslog: true
    network-interface-speed:
        why: |
            Capture the physical interface speed in human readable format such as 1G, 10G, etc. More details can be found to the next link: http://help.fortinet.com/cli/fos50hlp/56/Content/FortiOS/fortiOS-cli-ref-56/config/system/interface.htm
        how: |
            This script logs into the Fortinet firewall using SSH and retrieves the output of the "get system interface physical" and "get system interface" FortiOS commands. The output includes all the interface related information and statistics.
        without-indeni: |
            It is possible to poll this data through SNMP.
        can-with-snmp: true
        can-with-syslog: false
    network-interface-duplex:
        why: |
            Capture the physical 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.  More details can be found to the next link: http://help.fortinet.com/cli/fos50hlp/56/Content/FortiOS/fortiOS-cli-ref-56/config/system/interface.htm
        how: |
            This script logs into the Fortinet firewall using SSH and retrieves the output of the "get system interface physical" FortiOS command. The output includes all the interface related information and statistics.
        without-indeni: |
            It is possible to poll this data through SNMP.
        can-with-snmp: true
        can-with-syslog: false
    network-interface-mode:
        why: |
            Capture the the interface IP addressing allocation type: static, from external dhcp or external pppoe. More details can be found to the  next link: http://help.fortinet.com/cli/fos50hlp/56/Content/FortiOS/fortiOS-cli-ref-56/config/system/interface.htm
        how: |
            This script logs into the Fortinet firewall using SSH and retrieves the output of the "get system interface physical" FortiOS command. The output includes all the interface related information and statistics.
        without-indeni: |
            It is possible to poll this data through SNMP.
        can-with-snmp: false
        can-with-syslog: false
    network-interface-type:
        why: |
            Capture the the interface type e.g. vdom-link, tunnel, physical. More details can be found to the  next link: http://help.fortinet.com/cli/fos50hlp/56/Content/FortiOS/fortiOS-cli-ref-56/config/system/interface.htm
        how: |
            This script logs into the Fortinet firewall using SSH and retrieves the output of the "get system interface physical" and "get system interface" FortiOS commands. The output includes all the interface related information and statistics.
        without-indeni: |
            It is possible to poll this data through SNMP.
        can-with-snmp: true
        can-with-syslog: false
    network-interface-ipv4-address:
        why: "Capture the physical interface IPv4 address. \n"
        how: |
            This script logs into the Fortinet firewall using SSH and retrieves the output of the "get system interface physical" and "get system interface" FortiOS commands. The output includes all the interface related information and statistics.
        without-indeni: |
            It is possible to poll this data through SNMP.
        can-with-snmp: true
        can-with-syslog: false
    network-interface-ipv4-subnet:
        why: |
            Capture the interface IPv4 subnet mask.
        how: |
            This script logs into the Fortinet firewall using SSH and retrieves the output of the "get system interface physical" and "get system interface" FortiOS commands. The output includes all the interface related information and statistics.
        without-indeni: |
            It is possible to poll this data through SNMP.
        can-with-snmp: true
        can-with-syslog: false
    network-interface-admin-state:
        why: |
            Capture the interface administrative status. Alerts won't fire for interfaces that are administratively down."
        how: |
            This script logs into the Fortinet firewall using SSH and retrieves the output of the "show system interface" command.
        without-indeni: |
            The user would have to login to the device and use the "show system interface" command.
        can-with-snmp: true
        can-with-syslog: false
steps:
-   run:
        type: SSH
        file: get_system_interface.remote.1.bash
    parse:
        type: AWK
        file: get_system_interface.parser.1.awk

cross_vendor_network_port_speed_low

// Deprecation warning : Scala template-based rules are deprecated. Please use YAML format rules instead.

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

import com.indeni.ruleengine.expressions.Expression
import com.indeni.ruleengine.expressions.conditions.{Equals => RuleEquals, Or => RuleOr}
import com.indeni.ruleengine.expressions.data.SnapshotExpression
import com.indeni.server.rules.library.RuleHelper.networkInterfaceAdminState
import com.indeni.server.rules.{RemediationStepCondition, RuleCategory, RuleContext}
import com.indeni.server.rules.library.templates.SingleSnapshotValueCheckTemplateRule
import com.indeni.server.rules.library.RuleHelper

/**
  *
  */
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.",
  ruleCategories = Set(RuleCategory.HealthChecks),
  metricName = "network-interface-speed",
  applicableMetricTag = "name",
  alertAlternativeMetricTag = Some("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"))
  ),
  secondaryCondition = c => networkInterfaceAdminState(c.tsDao, expected = 1.0),
  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"
)(
  RemediationStepCondition.VENDOR_CISCO ->
    """|
       |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
)