cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
827
Views
5
Helpful
4
Replies

How to Write Script

Deben Bhattarai
Level 1
Level 1

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

2 Accepted Solutions

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

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?

View solution in original post

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 addr@company.com from addr@company.com subject "High CPU" server 10.1.1.1 body "CPU is currently at $_snmp_oid_val %"

This will send an email to addr@company.com 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 addr@company.com from addr@company.com 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.

View solution in original post

4 Replies 4

Joe Clarke
Cisco Employee
Cisco Employee

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?

Hi ,

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

thanks in adv

Deben

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 addr@company.com from addr@company.com subject "High CPU" server 10.1.1.1 body "CPU is currently at $_snmp_oid_val %"

This will send an email to addr@company.com 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 addr@company.com from addr@company.com 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.

HI Joseph,

Thanks a lot.

RGDS

Deben