Embedded Diagnostics and Management in Cisco IOS: TCL, EEM Scripting and Service Diagnostics
Embedded Diagnostics and Management in Cisco IOS: TCL, EEM Scripting and Service Diagnostics
Embedded Diagnostics and Management in Cisco IOS: TCL, EEM Scripting and Service Diagnostics
BRKDEV-1191
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 2
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 5
Context or Domain
High dependence means Network
higher availability Management
Si Si
requirements
Reaction times are shorter Onboard
Device
Management
Continuous cost pressures
More “intelligence” in the net
All driving need for automation
and distributed/cooperative
network management
Devices play an active
¼ Embedded Management
role in management
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 6
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 7
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 8
EEM Server
The “brains” of the system
Event Detectors
“watch for events of interest”
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 9
ED notifies EEM
Think of a policy as Server; which
an action registered triggers interested
to an event policies
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 10
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 11
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 12
Define applet
named
CFGMSG
iin-rtr1(config-applet)#event syslog
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 13
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 14
Label—used to
sort actions
Alphabetic sort
on the label
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 15
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 16
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 18
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 19
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 20
Getting Started:
Create Policy Directory
ashcroft#mkdir ABCCoTclPol
Create directory filename [ABCCoTclPol]?
Created dir disk0:ABCCoTclPol
ashcroft#dir
Directory of disk0:/
1 drw- 1 Oct 26 2003 13:37:42 +00:00 sys
6 drw- 1 Oct 30 2003 12:56:04 +00:00 ABCCoTclPol
47843328 bytes total (29356032 bytes free)
ashcroft#conf t
Enter configuration commands, one per line. End with CNTL/Z.
ashcroft(config)#event manager directory user policy disk0:/ABCCoTclPol
ashcroft(config)#^Z
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 22
ashcroft#dir
Directory of disk0:/
1 drw- 1 Oct 26 2003 13:37:42 +00:00 sys
6 drw- 1 Oct 30 2003 12:56:04 +00:00 ABCCoTclPol
47843328 bytes total (29351936 bytes free)
ashcroft#cd ABCCoTclPol
ashcroft#dir
Directory of disk0:/ABCCoTclPol/
8 -rw- 1232 Oct 30 2003 14:14:58 +00:00 sl_cfgSaveRemT.tcl
47843328 bytes total (29351936 bytes free)
ashcroft#
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 23
Getting Started:
Register the Policy
ashcroft#conf t
Enter configuration commands, one per line. End with CNTL/Z.
ashcroft(config)#event manager policy sl_cfgSaveRemT.tcl type user
ashcroft(config)#
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 24
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 25
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 26
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 27
Required
Next is any input variables or
required environment variables
to control the script
Names space imports
Entry criteria for the policy
Required
Body (logic of the script)
Exit status
Required
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 28
Body
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 29
Suppose we want the in and out ‘numbers’ from the above output
tclsh
% set t "sh int fa5/0 | inc put,
2901 packets input, 1605860 bytes
3165 packets output, 189978 bytes, 0 underruns
remote-pe#"
% regexp {(\d+) packets input.+?(\d+) bytes.+?(\d+) packets output.+?(\d+) bytes} $t match pin bin pout bout
1
% set pin % set pout
2901 3165
% set bin % set bout
1605860 189978
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 30
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 31
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 33
Configuration
remote-pe#conf t
Enter configuration com mands, one perline. End with CNTL/Z.
remote-pe(config)#event manager environment u_cfgSave_on 1
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 34
Do some stuff
if { $bool_val } {
incr bw_counter
#
# Code for sending a syslog message would go here....
#
context_save ctx1 bw_counter
return
}
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 37
#
# write to a file
#
#
if [file exists $_ofilename] {
puts "file $_ofilename being overwritten"
}
set myfileid [open $_ofilename w+]
foreach outs $cliout {
puts $myfileid $outs
}
close $myfileid
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 38
Policy B
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 39
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 43
Benefit
More flexibility, provides unique
troubleshooting capability
Goes beyond today’s one event per policy
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 45
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 47
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 49
EEM
EEM
EEM
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 51
Cisco IOS
Embedded Event Manager v3.0
Theme: 3.0—EEM for Power Users
This development will enhance the performance, increase feature
integration, add new capabilities, and increase the flexibility so that EEM
can be used in new and exciting ways
Major new customer facing function:
Increased performance—up to 150 events per second*
New Event Detectors
Routing ED,
Flexible NetFlow ED,
IP SLA ED,
Enhanced CLI Command ED
User interface enhancements
SNMP library extensions
Get, Set and Notify for local and remote hosts
Ease of use items
… and More
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 53
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 55
Ethernet 0/0
BRKDEV-1191
X Ethernet 0/1
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 56
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 57
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 58
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 59
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 60
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 61
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 62
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 63
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 65
Recommended Reading
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 67
BRKDEV-1191
14596_04_2008_c2 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 68