High Memory Usage per Chassis and Blade-cisco-asa

High Memory Usage per Chassis and Blade-cisco-asa

Vendor: cisco

OS: asa

Description:
Alert when Memory usage is high

Remediation Steps:
Review the load on this thread to see if the memory utilization is valid.
||1. Check from the Indeni the memory utilization history graph for this device an review the pattern. Correlate any change to the pattern with any configuration change.
|2. The next NX-OS commands output can inform whether the platform memory utilization is normal or un-expected:
| a. “show system resources”
| b. “show processes memory”
|3. For more information, please review: Troubleshooting Guide For High Memory Utilization.

How does this work?
This script polls the ciscoMemoryPoolTable via SNMP to calculate memory utilization.

Why is this important?
Capture the total utilization of the system’s memory (RAM) resources. This information is critical for monitoring the system’s health and make sure memory is not over utilized. If memory utilization goes beyond a certain threshold an alert will be triggered.

Without Indeni how would you find this?
User will have to manually CLI into the device to look at memory utilization periodically or calcualte utilization by polling SNMP.

cisco-asa-memory-usage

name: cisco-asa-memory-usage
description: Fetch memory usage for ASA device
type: monitoring
monitoring_interval: 1 minute
includes_resource_data: true
requires:
  vendor: cisco
  os.name: asa
  snmp: true
comments:
  memory-usage:
    why: |
      Capture the total utilization of the system's memory (RAM) resources. This information is critical for monitoring the system's health and make sure memory is not over utilized. If memory utilization goes beyond a certain threshold an alert will be triggered.
    how: |
      This script polls the ciscoMemoryPoolTable via SNMP to calculate memory utilization.
    can-with-snmp: true
    can-with-syslog: false
  memory-free-kbytes:
    why: |
      Capture the free amount of the system's memory (RAM) resources. This information is critical for monitoring the system's health and make sure memory is not over utilized. If memory utilization goes beyond a certain threshold an alert is triggered.
    how: |
      This script polls the ciscoMemoryPoolTable via SNMP to calculate the free kbytes of the memory. This metric indicates the number of bytes from the memory pool that are currently available on the managed device.
    can-with-snmp: true
    can-with-syslog: false
  memory-total-kbytes:
    why: |
      Capture the total amount of the system's memory (RAM) resources. This information is critical for monitoring the system's health and make sure memory is not over utilized. If memory utilization goes beyond a certain threshold an alert is triggered.
    how: |
      This script polls the ciscoMemoryPoolTable via SNMP to calculate the total kbytes of the memory. The sum of ciscoMemoryPoolUsed and ciscoMemoryPoolFree is the total amount of memory in the pool.
    can-with-snmp: true
    can-with-syslog: false
  memory-used-kbytes:
    why: |
      Capture the used amount of the system's memory (RAM) resources. This information is critical for monitoring the system's health and make sure memory is not over utilized. If memory utilization goes beyond a certain threshold an alert is triggered.
    how: |
      This script polls the ciscoMemoryPoolTable via SNMP to calculate the used kbytes of the memory. This metric indicates the number of bytes from the memory pool that are currently in use on the managed device.
    can-with-snmp: true
    can-with-syslog: false
steps:
-   run:
      type: SNMP
      command: GETBULK --columns 1.3.6.1.4.1.9.9.48.1.1.1.2 1.3.6.1.4.1.9.9.48.1.1.1.5 1.3.6.1.4.1.9.9.48.1.1.1.6
    parse:
      type: AWK
      file: asa-memory-usage.parser.1.awk

high_per_chassis_blade_memory_usage

package com.indeni.server.rules.library.core
import com.indeni.ruleengine.Scope.{Scope, ScopeValueHelper}
import com.indeni.ruleengine.expressions.Expression
import com.indeni.ruleengine.expressions.conditions.GreaterThanOrEqual
import com.indeni.ruleengine.expressions.core.{StatusTreeExpression, _}
import com.indeni.ruleengine.expressions.data.{SelectTagsExpression, SelectTimeSeriesExpression, TimeSeriesExpression}
import com.indeni.ruleengine.expressions.math.AverageExpression
import com.indeni.ruleengine.expressions.scope.ScopableExpression
import com.indeni.server.common.ParameterValue
import com.indeni.server.common.data.conditions.{Equals, True}
import com.indeni.server.params.ParameterDefinition
import com.indeni.server.params.ParameterDefinition.UIType
import com.indeni.server.rules._
import com.indeni.server.rules.config.expressions.DynamicParameterExpression
import com.indeni.server.rules.library.{ConditionalRemediationSteps, PerDeviceRule}
import com.indeni.server.sensor.models.managementprocess.alerts.dto.AlertSeverity


/**
  * Created by amir on 04/02/2016.
  */
case class HighPerChassisBladeMemoryUsageRule() extends PerDeviceRule {

  private val highThresholdParameterName: String = "High_Threshold_of_Memory_Usage"

  private val highThresholdParameter = new ParameterDefinition(highThresholdParameterName,
    "",
    "High Threshold of Memory Usage",
    "What is the threshold for the memory usage for which once it is crossed an issue will be triggered.",
    UIType.DOUBLE,
    new ParameterValue((85.0).asInstanceOf[Object])
  )

  override val metadata: RuleMetadata =
    RuleMetadata.builder(
      "high_per_chassis_blade_memory_usage",
      "High Memory Usage per Chassis and Blade",
      "Alert when Memory usage is high",
      AlertSeverity.ERROR,
      Set(RuleCategory.HealthChecks),
      deviceCategory = DeviceCategory.AllDevices).configParameter(highThresholdParameter).build()

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

    val usagePercentage = AverageExpression(TimeSeriesExpression[Double]("memory-usage"))
    val usagePercentageThreshold = DynamicParameterExpression.withConstantDefault(highThresholdParameter.getName, highThresholdParameter.getDefaultValue.asDouble.toDouble).noneable
    val isUsagePercentageAboveThreshold = GreaterThanOrEqual(usagePercentage, usagePercentageThreshold)

    val mountSpaceFailDescription = new ScopableExpression[String] {
      override protected def evalWithScope(time: Long, scope: Scope): String =
        "Memory usage (" + usagePercentage.eval(time) + "%) above threshold (" + usagePercentageThreshold.eval(time) + "%) " +
          "for chassis: " + scope.getVisible("Chassis").get + ", blade: " + scope.getVisible("Blade").get

      override def args: Set[Expression[_]] = Set(usagePercentage, usagePercentageThreshold)
    }
    val mountSpaceFailHeadline = new ScopableExpression[String] {
      override protected def evalWithScope(time: Long, scope: Scope): String = "chassis: " + scope.getVisible("Chassis").get + ", blade: " + scope.getVisible("Blade").get

      override def args: Set[Expression[_]] = Set()
    }
    val tsQuery = SelectTimeSeriesExpression[Double](context.tsDao, Set("memory-usage"), denseOnly = false)
    val forTsCondition = StatusTreeExpression(tsQuery, isUsagePercentageAboveThreshold).withSecondaryInfo(
      mountSpaceFailHeadline, mountSpaceFailDescription, title = "Problematic Blades"
    ).asCondition()

    val chassisBladeQuery = SelectTagsExpression(context.tsDao, Set("Chassis", "Blade"), True)
    val highMemoryUsagePerDevicePerChassisBladeLogic = StatusTreeExpression(chassisBladeQuery, forTsCondition)
      .withoutInfo().asCondition()

    val headline = ConstantExpression("High memory usage")
    val description = ConstantExpression("The memory usage in the operating system is higher than the high threshold.")
    val remediation = ConditionalRemediationSteps("Review the load on this thread to see if the memory utilization is valid.",
      RemediationStepCondition.VENDOR_CISCO ->
        """1. Check from the Indeni  the memory utilization history graph for this device an review the pattern. Correlate any change to the pattern with any configuration change.
          |2. The next NX-OS commands output can inform whether the platform memory utilization is normal or un-expected:
          | a. "show system resources"
          | b. "show processes memory"
          |3. For more information, please review: <a target="_blank" href="http://docwiki.cisco.com/wiki/Cisco_Nexus_7000_Series_NX-OS_Troubleshooting_Guide_--_Troubleshooting_Memory">Troubleshooting Guide For High Memory Utilization</a>.""".stripMargin,
      RemediationStepCondition.VENDOR_JUNIPER ->
        """|1. On the device command line interface execute "show chassis routing-engine" command to check overall routing engine memory usage.
           |2. Run "show system processes extensive" command to review the memory allocation status for processes.
           |3. Identify the processes which are consuming too much memory.
           |4. Consider turning off some processes which are not vital to ensure bigger memory space allocation for other sessions and processes.
           |5. Review the following article on Juniper tech support site: <a target="_blank" href="https://www.juniper.net/documentation/en_US/release-independent/nce/topics/task/operational/security-policy-memory-testing.html">Checking Memory Status</a>.""".stripMargin
    )

    val devicesFilter = Equals("model", "CheckPoint61k")
    val devicesQuery = SelectTagsExpression(context.metaDao, Set(DeviceKey), devicesFilter)

    StatusTreeExpression(devicesQuery, highMemoryUsagePerDevicePerChassisBladeLogic).withRootInfo(
      headline, description, remediation
    )
  }
}