Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

How to Write Script

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
Cisco Employee

Re: How to Write Script

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?

Cisco Employee

Re: How to Write Script

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.

4 REPLIES
Cisco Employee

Re: How to Write Script

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?

New Member

Re: How to Write Script

Hi ,

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

thanks in adv

Deben

Cisco Employee

Re: How to Write Script

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.

New Member

Re: How to Write Script

HI Joseph,

Thanks a lot.

RGDS

Deben

451
Views
5
Helpful
4
Replies
CreatePlease to create content