Send a list of high-CPU processes on CPU overload

From CT3

Jump to: navigation, search

The applet is triggered by an Embedded Resource Manager policy that detects global (= per router) CPU overload. It displays the top-CPU processes and sends the collected output in an e-mail to the address defined in the _operator environment variable.

Contents

Usage guidelines

  • Define an ERM policy HighGlobalCPU that detects high CPU load;
  • Set the _operator EEM environment variable to the target e-mail address;
  • Enter the EEM applet into the router's configuration.

Author

Ivan Pepelnjak, © 2008 NIL Data Communications

Source code

event manager applet ReportHighCPU
 event resource policy "HighGlobalCPU"
 action 1.0 cli command "show process cpu sorted 5sec"
 action 1.1 info type routername
 action 2.0 mail server "mail-gw" →
   to "$_operator" from "$_info_routername@lab.com" →
   subject "CPU @ $_resource_current_value" →
   body "$_cli_result"

Related configuration

  • Define the SMTP gateway with the ip host command
 ip host mail-gw 10.0.0.1
  • Define the e-mail recipient with the event manager environment command
event manager environment _operator admin@lab.com
resource policy
 policy HighGlobalCPU global
  system
   cpu total
    critical rising 95 falling 70 interval 10
    major rising 75 falling 50 interval 10
 !
 user global HighGlobalCPU