Here the number of spaces in front of the number are being used to
tell the difference between single digits and double digits.

^ = start of the line
Then for digits 1-9 there is 3 spaces from the beginning to the digit.
You have to have 3 spaces otherwise you will match other items. For
example if you only have two spaces you will match items with a digit
between 10 - 99. One space will match items 100 - 199. This is because
the number is one space closer to the beginning of the line.

The next item is the [1-9] this is telling regex to match any diget
between the two numbers, and including the two numbers.

Next you have the pipe "|" this is the "or" statement. This will cause
the expression to return true (include the line) if either of the
expressions return true(or match).

The second part of the regex differed from the first because it is one
space closer and we are telling it we want the number to begin with 1,
then followed by the set [1-5].

Here is the location of Regex in the documentation.

http://www.cisco.com/en/US/docs/ios/termserv/configuration/guide/tsv_reg_express_ps6441_TSD_Products_Configuration_Guide_Chapter.html

Hope I am correct and I hope this helps!

Thanks,

Dan




On Mon, Feb 21, 2011 at 5:55 PM, Jason Maynard <[email protected]> wrote:
> 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
>
_______________________________________________
For more information regarding industry leading CCIE Lab training, please visit 
www.ipexpert.com

Reply via email to