You can do this as well. regex is very flexible so just think of how you want to accomplish it and there will be a way.
router#show proc cpu | incl ^[ ]+([1-9] |1[1-5] ) 1 27500 16931 1624 0.00% 0.00% 0.00% 0 Chunk Manager 2 893376 326096 2739 0.14% 0.13% 0.14% 0 Load Meter 3 49816 1589441 31 0.00% 0.00% 0.00% 0 BGP Scheduler 4 0 1 0 0.00% 0.00% 0.00% 0 EDDRI_MAIN 5 6481476 334112 19399 0.00% 0.34% 0.26% 0 Check heaps 6 26788 3885 6895 0.00% 0.00% 0.00% 0 Pool Manager 7 0 2 0 0.00% 0.00% 0.00% 0 Timers 8 0 1 0 0.00% 0.00% 0.00% 0 License Client N 9 881600 303847 2901 0.00% 0.03% 0.00% 0 BGP I/O 11 0 1 0 0.00% 0.00% 0.00% 0 IPC Zone Manager 12 46240 1589462 29 0.00% 0.00% 0.00% 0 IPC Periodic Tim 13 43112 1589461 27 0.00% 0.00% 0.00% 0 IPC Deferred Por 14 0 1 0 0.00% 0.00% 0.00% 0 IPC Seat Manager 15 0 1 0 0.00% 0.00% 0.00% 0 IPC BackPressure router# Regards, Tyson Scott - CCIE #13513 R&S, Security, and SP Managing Partner / Sr. Instructor - IPexpert, Inc. Mailto: [email protected] Telephone: +1.810.326.1444, ext. 208 Live Assistance, Please visit: www.ipexpert.com/chat eFax: +1.810.454.0130 IPexpert is a premier provider of Self-Study Workbooks, Video on Demand, Audio Tools, Online Hardware Rental and Classroom Training for the Cisco CCIE (R&S, Voice, Security & Service Provider) certification(s) with training locations throughout the United States, Europe, South Asia and Australia. Be sure to visit our online communities at www.ipexpert.com/communities and our public website at www.ipexpert.com -----Original Message----- From: Jason Maynard [mailto:[email protected]] Sent: Monday, February 21, 2011 5:55 PM To: 'Tyson Scott'; 'Nicolas Bellenbaum'; 'Michal Styszynski' Cc: [email protected] Subject: RE: [OSL | CCIE_RS] EEM applet show proc cpu | inclu ^ [1-9]|^ 1[1-5] (Tyson Version and Works) vs show proc cpu | inclu ^ [1-9]|^ 1[1-5] (does not work - The number of spaces are shorter between ^ [1-9]) Can someone quickly break this regexp up and explain it Sorry as it seems if you leave things for a bit you forget them :( Back to reading "TCL Scripting for Cisco IOS" -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Tyson Scott Sent: February-21-11 3:58 PM To: 'Nicolas Bellenbaum'; 'Michal Styszynski' Cc: [email protected] Subject: Re: [OSL | CCIE_RS] EEM applet router#show proc cpu | incl ^ [1-9]|^ 1[1-5] 1 27388 16880 1622 0.00% 0.00% 0.00% 0 Chunk Manager 2 879884 324378 2712 0.39% 0.20% 0.22% 0 Load Meter 3 48928 1581122 30 0.00% 0.00% 0.00% 0 BGP Scheduler 4 0 1 0 0.00% 0.00% 0.00% 0 EDDRI_MAIN 5 6423764 331312 19388 0.00% 0.36% 0.27% 0 Check heaps 6 25976 3772 6886 0.00% 0.00% 0.00% 0 Pool Manager 7 0 2 0 0.00% 0.00% 0.00% 0 Timers 8 0 1 0 0.00% 0.00% 0.00% 0 License Client N 9 873336 302072 2891 0.00% 0.02% 0.00% 0 BGP I/O 11 0 1 0 0.00% 0.00% 0.00% 0 IPC Zone Manager 12 45436 1581143 28 0.00% 0.00% 0.00% 0 IPC Periodic Tim 13 42392 1581141 26 0.00% 0.00% 0.00% 0 IPC Deferred Por 14 0 1 0 0.00% 0.00% 0.00% 0 IPC Seat Manager 15 0 1 0 0.00% 0.00% 0.00% 0 IPC BackPressure router# Regards, Tyson Scott - CCIE #13513 R&S, Security, and SP Managing Partner / Sr. Instructor - IPexpert, Inc. Mailto: [email protected] Telephone: +1.810.326.1444, ext. 208 Live Assistance, Please visit: www.ipexpert.com/chat eFax: +1.810.454.0130 IPexpert is a premier provider of Self-Study Workbooks, Video on Demand, Audio Tools, Online Hardware Rental and Classroom Training for the Cisco CCIE (R&S, Voice, Security & Service Provider) certification(s) with training locations throughout the United States, Europe, South Asia and Australia. Be sure to visit our online communities at www.ipexpert.com/communities and our public website at www.ipexpert.com -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Nicolas Bellenbaum Sent: Monday, February 21, 2011 2:02 PM To: Michal Styszynski Cc: [email protected] Subject: Re: [OSL | CCIE_RS] EEM applet To satisfy my curiosity on how to get this to work, i would do something like this: event manager applet SHOW event none sync yes action 10 cli command "show proc cpu | incl ^ [1-5]" action 20 set SHOW "none" action 30 regexp ".*" "$_cli_result" SHOW action 90 puts "$SHOW" The hard part on something like this is figuring out what pipe options to specify to get just the output you need (this is where Tyson's post helped me). I guess you could do this solely with the regexp you're matching on, but i haven't had much luck with that. I tried stuff like this and i was not having any luck: event manager applet SHOW event none sync yes action 10 cli command "show proc cpu" action 20 set SHOW "none" action 30 regexp " ^[1-5]" "$_cli_result" SHOW action 90 puts "$SHOW" Like you, I'm still struggling with EEM REGEX matching and how to correctly define the string you are matching on. I also am not sure how i would use this to match on PIDs 1-15 or 10-15, as using the same concept above gets me PIDs 1 and 5 instead of the whole range. Needless to say i'm still working on my GREP skills. Nick On Feb 21, 2011, at 9:31 AM, Michal Styszynski wrote: > Hi Nick , thanks for the follow-up . Did you try these scripts , I copied it > into the 12.4.24.T2 with the event none and it doesn't work. > > cheers , > Michal > > > > > ________________________________ > From: Nicolas Bellenbaum <[email protected]> > To: Michal Styszynski <[email protected]> > Cc: [email protected] > Sent: Mon, February 21, 2011 3:56:38 PM > Subject: Re: [OSL | CCIE_RS] EEM applet > > Michal, > > There's a post Tyson responded to in the archives referencing this exact > question (title is EEM applet). I think this is the answer you're looking for. > > Nick > > > On Feb 21, 2011, at 7:49 AM, Michal Styszynski wrote: > >> hello Marko , Tyson and all , >> I was re-listening the audio track on EEM done by Marko and so he was talking >> about the part CLI outputsfiltering at the very end of the lesson. >> >> Please , if you know any nice generic best practice on how to filter the cli >> show commands for just a couple of firstlinesor for lines for ex. between 10 >> and 15 , it would be very helpful. >> I used different regular expression combinations regarding the per line >> filtering but honestly the task is not easyor is getting hard to come up within >> >> the time we can dedicate during the real exam. >> >> Thanks for any best practice hints or additional examples are very welcome. >> I tries the foreach action but it doesn't really work as should. >> Thanks in advance for any help on that. >> >> Kind regards , >> Michal >> >> >> >> _______________________________________________ >> For more information regarding industry leading CCIE Lab training, please visit >> www.ipexpert.com > > > > _______________________________________________ > For more information regarding industry leading CCIE Lab training, please visit www.ipexpert.com _______________________________________________ For more information regarding industry leading CCIE Lab training, please visit www.ipexpert.com _______________________________________________ For more information regarding industry leading CCIE Lab training, please visit www.ipexpert.com _______________________________________________ For more information regarding industry leading CCIE Lab training, please visit www.ipexpert.com
