How to Write Script

Answered Question
Aug 22nd, 2010
User Badges:

Hi Guys...



I want to write script which will check CPU and Memory Utilization every 2 hours and send a mail to monitoring team and when utilization reaches to a  certain level.




regards

Dbn

Correct Answer by Joe Clarke about 6 years 11 months ago

This applet assumes that your device only has one CPU:


event manager applet watch-cpu

event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.11.1 entry-op ge entry-val 70 poll-interval 7200 get-type exact

action 1.0 mail to [email protected] from [email protected] subject "High CPU" server 10.1.1.1 body "CPU is currently at $_snmp_oid_val %"


This will send an email to [email protected] if the CPU utilization reachs 70%.


For memory, you could use:


event manager applet watch-mem

event snmp oid 1.3.6.1.4.1.9.9.48.1.1.1.6.1 entry-op le entry-val 4194304 poll-interval 7200 get-type exact

action 1.0 mail to [email protected] from [email protected] subject "Low Free Memory" server 10.1.1.1 body "Free memory is currently at $_snmp_oid_val bytes"


This will send an email if free memory dips below 4 MB.


For external scripting, I suggest you look into the Expect programming language.  You can use this to wrap programs like telnet and SSH to connect to devices and run arbitrary CLI commands.

Correct Answer by Joe Clarke about 6 years 11 months ago

Are you looking to do with with the Embedded Event Manager (i.e. on-box) or do you need to have an external script to collect this information?

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (3 ratings)
Loading.
Correct Answer
Joe Clarke Sun, 08/22/2010 - 19:57
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Are you looking to do with with the Embedded Event Manager (i.e. on-box) or do you need to have an external script to collect this information?

Deben Bhattarai Sun, 08/22/2010 - 23:52
User Badges:

Hi ,


I want to do with EEM. Please also guide for external scripts.



thanks in adv

Deben

Correct Answer
Joe Clarke Mon, 08/23/2010 - 00:06
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

This applet assumes that your device only has one CPU:


event manager applet watch-cpu

event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.11.1 entry-op ge entry-val 70 poll-interval 7200 get-type exact

action 1.0 mail to [email protected] from [email protected] subject "High CPU" server 10.1.1.1 body "CPU is currently at $_snmp_oid_val %"


This will send an email to [email protected] if the CPU utilization reachs 70%.


For memory, you could use:


event manager applet watch-mem

event snmp oid 1.3.6.1.4.1.9.9.48.1.1.1.6.1 entry-op le entry-val 4194304 poll-interval 7200 get-type exact

action 1.0 mail to [email protected] from [email protected] subject "Low Free Memory" server 10.1.1.1 body "Free memory is currently at $_snmp_oid_val bytes"


This will send an email if free memory dips below 4 MB.


For external scripting, I suggest you look into the Expect programming language.  You can use this to wrap programs like telnet and SSH to connect to devices and run arbitrary CLI commands.

Actions

This Discussion