TX packets experienced collisions-checkpoint-gaia,secureplatform

TX packets experienced collisions-checkpoint-gaia,secureplatform
0

TX packets experienced collisions-checkpoint-gaia,secureplatform

Vendor: checkpoint

OS: gaia,secureplatform

Description:
Indeni tracks the number of packets that had issues and alerts if the ratio is too high.

Remediation Steps:
Packet collisions usually occur when there is a mismatch in duplex settings on two sides of a cable.

How does this work?
How many packets sent by the interface is retrieved by running “ifconfig -a”.

Why is this important?
It is useful to know how many packets have been transmitted by the interface.

Without Indeni how would you find this?
An administrator could login and manually check interface configuration, or use SNMP.

chkp-os-interfaces-novsx

#! META
name: chkp-os-interfaces-novsx
description: Get interface information
type: monitoring
monitoring_interval: 1 minute
requires:
    vendor: "checkpoint"
    and:
        -
            or:
                -
                    os.name: "gaia"
                -
                    os.name: "secureplatform"
        -
            or:
                -
                    vsx:
                        neq: "true"
                -
                    mds: "true"

#! COMMENTS
network-interface-state:
    why: |
        Interfaces in the "down" state could result in downtime or reduced redundancy.
    how: |
        The state of the interface is retrieved by running "ethtool".
    without-indeni: |
        An administrator could login and manually check interface status, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-admin-state:
    why: |
        If the interface is disabled, then it is okay for it to be down. If the interface is enabled however, it should be up.
    how: |
        Retrieve the information by parsing the Gaia database in /config/active.
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-speed:
    why: |
        If the interface speed is set to a low value, this could mean auto-negotiation is not working correctly and the interface does not utilize the full bandwidth available.
    how: |
        The speed of the interface is retrieved by running "ethtool".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-duplex:
    why: |
        If the interface has half-duplex setting, this will reduce throughput, and should be investigated.
    how: |
        The duplex of the interface is retrieved by running "ethtool".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-ipv4-address:
    why: |
        To be able to search for IP addresses in indeni, this data needs to be stored.
    how: |
        The IP address of the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP, WebUI or SmartDashboard.

network-interface-ipv4-subnet:
    why: |
        To be able to search for IP addresses in indeni, this data needs to be stored.
    how: |
        The subnet of the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP, WebUI or SmartDashboard.

network-interface-type:
    why: |
        The type of interface can be useful for administrators.
    how: |
        The type of the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface or SNMP.

network-interface-mtu:
    why: |
        The MTU sometimes needs to be adjusted. Storing this gives an administrator an easy way to view the MTU from a large number of devices, as well as identifying incorrectly set MTU.
    how: |
        The MTU of the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-mac:
    why: |
        To be able to search for MAC addresses in indeni, this data needs to be stored.
    how: |
        The MAC address of the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-description:
    why: |
        The description is an important way to identify interfaces.
    how: |
        Retrive the information by parsing the gaia database in /config/active.
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-tx-bytes:
    why: |
        It is useful to know how much data has been transmitted by the interface.
    how: |
        How many bytes sent by the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-rx-bytes:
    why: |
        It is useful to know how much data has been received by the interface.
    how: |
        How many bytes received by the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-tx-packets:
    why: |
        It is useful to know how many packets have been transmitted by the interface.
    how: |
        How many packets sent by the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-rx-packets:
    why: |
        It is useful to know how many packets have been received by the interface.
    how: |
        How many packets received by the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-tx-errors:
    why: |
        Transmit errors on an interface could indicate a problem.
    how: |
        The amount of transmit errors for the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-rx-dropped:
    why: |
        Dropped packets on an interface could indicate a problem and potential traffic loss.
    how: |
        The amount of receive drops for the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-tx-overruns:
    why: |
        Transmit overruns on an interface could indicate a problem.
    how: |
        The amount of transmit overruns for the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-rx-overruns:
    why: |
        Receive overruns on an interface could indicate a problem.
    how: |
        The amount of receive overruns for the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-tx-carrier:
    why: |
        A high carrier number could mean that the link is flapping.
    how: |
        The carrier counter for the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interface-rx-frame:
    why: |
        A high frame number means a lot of packages did not end on a 32bit/4 byte boundary.
    how: |
        The frame counter for the interface is retrieved by running "ifconfig -a".
    without-indeni: |
        An administrator could login and manually check interface configuration, or use SNMP.
    can-with-snmp: true
    can-with-syslog: false
    vendor-provided-management: |
        This is only accessible from the command line interface, SNMP or WebUI.

network-interfaces:
    skip-documentation: true

network-interface-:
    skip-documentation: true

network-interface-admin-state-logical
    skip-documentation: true

network-interface-state-logical
    skip-documentation: true

#! REMOTE::SSH



${nice-path} -n 15 ifconfig -a | grep "HWaddr" | awk {'print $1'} | while read interface; do ifconfig $interface && ${nice-path} -n 15 ethtool -i $interface && ${nice-path} -n 15 ethtool $interface ; ${nice-path} -n 15 grep -P "interface:$interface:comments" /config/active; done; ${nice-path} -n 15 ifconfig -a |grep HWaddr | awk '{print $1}' | grep  -vE "br|wrp|vpnt|bond|pppoe|sit" | awk '$1!~/[:,.]/{print $1}' | xargs echo "__PHYSICAL"




#! PARSER::AWK

###########
# Commandline Comments
# NOTE: For this commandline, avoid running clish commands due to the excessive logs in /var/log/messages that creates.
#
# Interface Types
# eth0 -- a 'regular' physical interface. Works with ethtool and should be in /config/active
# eth0.5 -- a VLAN or "sub" interface. Always contains '.'. Works with ethtool (usually?) and should be in /config/active
# eth0:1 -- an 'alias' or multi-IP interface. Always contains ':'. Works with ethtool (usually?) and will not be in /config/active (always?)
# bond -- bond interface. Always starts with the "bond". Ignored in this script -- see SSH command.
# wrp192 -- a warp interface. Always starts with the "wrp". Does not work with ethtool but should be in /config/active (always?)
# br1 -- a bridge interface. Always starts with "br" (?). Seems to return data for ethtool and should be in /config/active.
#
# 1- list all interfaces prensent into de device with "ifconfig -a"
# 2- print each interface details using "ifconfig <interface>" and "ethtool <interface>" and all info is collected from output
# 3- grep "/config/active" to collect interface comments
# 4- lspci used to list all hardware connected to the device and collect physical network interfaces, 
#    because only physical interfaces should generate alarms, diffrent metrics if interface is not physical
#
###########

function getValue(s) {
    sub(/^.+:/, "", s)
    return s
}


#eth0        Link encap:Ethernet  HWaddr 00:0C:29:FF:5B:0C
/Link encap:/ {
    interface_name = $1
    tags["name"] = interface_name
    tags["im.identity-tags"] = "name"
    interfaces[interface_name, "name"] = interface_name
    admin_states[interface_name] = 0
    link_states[interface_name] = -1   # We may not find a link state for an interface. If so, we need to know that.

    # Type
    type = getValue($3)
    writeComplexMetricString("network-interface-type", tags, type)

    # MAC
    writeComplexMetricStringWithLiveConfig("network-interface-mac", tags, $5, "Network Interfaces - MAC Address")

    next
}

#            inet addr:192.168.245.2  Bcast:192.168.245.255  Mask:255.255.255.0
/inet addr:/ {
    ip = getValue($2)
    net_mask = getValue($4)

    ip_tags["name"] = interface_name
    ip_tags["im.identity-tags"] = "name"
    ip_tags["im.dstype.displaytype"] = "string"

    writeComplexMetricStringWithLiveConfig("network-interface-ipv4-address", ip_tags, ip, "Network Interfaces - IPv4 Address")
    writeComplexMetricStringWithLiveConfig("network-interface-ipv4-subnet", ip_tags, net_mask, "Network Interfaces - IPv4 Netmask")

    next
}

#            BROADCAST MULTICAST  MTU:1500  Metric:1
#            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
/MTU/ {
    # UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
    mtu = getValue($(NF - 1))
    interfaces[interface_name, "mtu"] = mtu
    writeComplexMetricString("network-interface-mtu", tags, mtu)
    ## if admin state is "UP"  admin_state must be updated
    if ( $1 == "UP") {
        admin_states[interface_name] = 1
    }

    next
}

#       TX bytes:2096249117 packets:2975595223 errors:0 dropped:0 overruns:0 carrier:0
#       RX bytes:3891794260 packets:264187186 errors:0 dropped:0 overruns:0 frame:0
#       RX bytes:3964467449 (3.6 GiB)  TX bytes:922468769 (879.7 MiB)
#       RX packets:123982210 errors:0 dropped:0 overruns:0 frame:0
#       TX packets:61771739 errors:0 dropped:0 overruns:0 carrier:0
/(X bytes:|X packets:)/ {

    # Go over the line, field by field.
    for (i = 1; i <= NF; i++) {

        # Detect if current field contains RX or TX.
        #RX
        if ($i ~ /^(RX|TX)$/) {
            metric_prefix = tolower($i)
        }

        # Detect if the current field is data that should be stored
        #bytes:3964467449
        #errors:0
        if ($i ~ /[a-z]:[0-9]+$/) {
            split($i, stat_parts, ":")
            name = stat_parts[1]
            value = stat_parts[2]

            if (name == "bytes") {
                unit = "bytes"
            } else {
                unit = "number"
            }

            writeDoubleMetricWithLiveConfig("network-interface-" metric_prefix "-" name, tags, "gauge", "60", value, "Network Interfaces - " metric_prefix " " name, unit, "name")
        }
    }

    next
}

#driver: vmxnet3
/driver:/ {
    interfaces[interface_name, "driver"] = $2

    next
}

#Speed: 100Mb/s
/Speed:/ {
    speed = $2
    gsub(/b\/s/, "", speed)
    # speed metric need special tags for alert purpose
    speed_tags["name"] = interface_name
    speed_tags["alert-item-port-speed"] = interface_name "-" speed
    writeComplexMetricString("network-interface-speed", speed_tags, speed)

    next
}

#Duplex: Full
/Duplex:/ {
    duplex = tolower($2)
    writeComplexMetricString("network-interface-duplex", tags, duplex)

    next
}

#Link detected: yes
/Link detected:/ {
    if ($3 == "yes")
        link_states[interface_name] = 1
    else
        link_states[interface_name] = 0

    next
}

#Auto-negotiation: on
/Auto-negotiation:/ {
    interfaces[interface_name, "auto-negotiation"] = $2

    next
}



#interface:eth1:comments Private2\ lala
#interface:eth1:comments Test
/interface:.+:comments/ {
    line = $0
    sub(/interface:.+:comments\s*/, "", line)
    gsub(/(\\)/, "", line)  # If the comment is in two words or more, a backslash is inserted. We need to remove it.
    writeComplexMetricString("network-interface-description", tags, trim(line))

    next
}

#__PHYSICAL eth0 eth1 eth2
/__PHYSICAL/ {
    for (i = 2; i <= NF; i++ ) {
        phy_interfaces[$i] 
    }
}


END {
    if (arraylen(interfaces))
        writeComplexMetricObjectArray("network-interfaces", null, interfaces)

    for (_interface_name in admin_states) {
        # intentionally using a different tags array for this section. We are setting this tag in a loop -- don't
        # confuse this tag array with the one in the main AWK section -- the serve different purposes.
        state_tags["name"] = _interface_name

        # Need to check if this interface is a physical interface. In that case we return a metric that is going to be 
        # evaluated by scale rules and could generate alarms into the WebUI (only physical interfaces should generate alarms).
        if (_interface_name in phy_interfaces) {
            if (link_states[_interface_name] != -1) {
                writeDoubleMetricWithLiveConfig("network-interface-admin-state", state_tags, "gauge", 0, admin_states[_interface_name], "Network Interfaces - Enabled/Disabed", "state", "name")
                writeDoubleMetricWithLiveConfig("network-interface-state", state_tags, "gauge", 0, link_states[_interface_name], "Network Interfaces - Up/Down", "state", "name")
            # In the case that there is no link state, this is because it's a bond interface with a different name, 
            # e.g., "Sync" interface on asg devices. It's not a physical interface (even though we thought it was),
            # So we write the 'logical' metric: see comments below.
            } else {
                writeDoubleMetricWithLiveConfig("network-interface-admin-state-logical", state_tags, "gauge", 0, admin_states[_interface_name], "Network Interfaces - Enabled/Disabed", "state", "name")
            }
        } else {
            # If the interface is not physical, we use a different metric name (with "logical" as part of the name) 
            # because it shouldn't be evaluated by scala rules. I.e., we never want to alert for logical interfaces,
            # but we still want them to show up in the live config.
            # Admin state should be written always: all interfaces have admin state
            writeDoubleMetricWithLiveConfig("network-interface-admin-state-logical", state_tags, "gauge", 0, admin_states[_interface_name], "Network Interfaces - Enabled/Disabed", "state", "name")
    
            #link state is only written when the interface has link-state. bond, wrp, wrpj has no link state
            if (link_states[_interface_name] != -1) {
                writeDoubleMetricWithLiveConfig("network-interface-state-logical", state_tags, "gauge", 0, link_states[_interface_name], "Network Interfaces - Up/Down", "state", "name")
            }
        }
    }
}

CrossVendorTxCollisions

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

import com.indeni.server.rules.RuleContext
import com.indeni.server.rules.library.ConditionalRemediationSteps
import com.indeni.server.rules.library.templates.NearingCapacityWithItemsTemplateRule

/**
  *
  */
case class CrossVendorTxCollisions() extends NearingCapacityWithItemsTemplateRule(
  ruleName = "CrossVendorTxCollisions",
  ruleFriendlyName = "All Devices: TX packets experienced collisions",
  ruleDescription = "Indeni tracks the number of packets that had issues and alerts if the ratio is too high.",
  usageMetricName = "network-interface-tx-collisions",
  limitMetricName = "network-interface-tx-packets",
  applicableMetricTag = "name",
  threshold = 0.5,
  minimumValueToAlert = 100.0, // We don't want to alert if the number of packets is really low
  alertDescription = "Some network interfaces and ports are experiencing a high collision rate. Review the ports below.",
  alertItemDescriptionFormat = "%.0f collisions identified out of a total of %.0f transmitted.",
  baseRemediationText = "Packet collisions usually occur when there is a mismatch in duplex settings on two sides of a cable.",
  alertItemsHeader = "Affected Ports")(
  ConditionalRemediationSteps.VENDOR_FORTINET ->
    """
      |1. Run "diag hardware deviceinfo nic <interface>" command to display a list of hardware related error names and values. Review  the next link for more details: http://help.fortinet.com/fos50hlp/54/Content/FortiOS/fortigate-toubleshooting-54/troubleshooting_tools.htm
      |2. Run command "fnsysctl cat /proc/net/dev" to get a summary of the interface statistics.
      |3. Check for speed and duplex mismatch in the interface settings on both sides of a cable, and check for a damaged cable. Review the next link for more info: http://kb.fortinet.com/kb/documentLink.do?externalID=10653""".stripMargin 
)