Re: Match Expression to fetch dynamic string (250 Views)
Reply
Frequent Advisor
Utkarshpatel
Posts: 57
Registered: ‎02-15-2012
Message 1 of 6 (331 Views)
Accepted Solution

Match Expression to fetch dynamic string

Hello Experts,

Need help in writing the match expression that can fetch a particluar word/string from the output.
For eg: The output of one script monitor is :
value=tcp4    0    0    *.39606        *.*    LISTEN

I want to capture just the end string "LISTEN".

This output can change and instead of LISTEN it could be "MOUNTED" or something else.
So how do i capture this using the Match Expression.

Please guide.

Thanks and Regards
Utkarsh

Please use plain text.
HP Expert
kenneth.gonzalez
Posts: 1,520
Registered: ‎04-28-2011
Message 2 of 6 (296 Views)

Re: Match Expression to fetch dynamic string

Hi Utkarsh,

The simple regex /(LISTEN)/ will always match "LISTEN" if it is found in the line. If it's not in the output then there will be a content match error because it is not found.
Kenneth Gonzalez
HP Support

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.

If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums
Please use plain text.
Respected Contributor
Konstantin.Kornienko
Posts: 250
Registered: ‎12-25-2005
Message 3 of 6 (290 Views)

Re: Match Expression to fetch dynamic string

Try something like

 

/(\w+)$/

 

It will capture last word in line - LISTEN, MOUNTED or whatever

Please use plain text.
HP Expert
kenneth.gonzalez
Posts: 1,520
Registered: ‎04-28-2011
Message 4 of 6 (288 Views)

Re: Match Expression to fetch dynamic string

I agree with Konstantin, I think I misunderstood your request.
Kenneth Gonzalez
HP Support

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.

If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums
Please use plain text.
Frequent Advisor
Utkarshpatel
Posts: 57
Registered: ‎02-15-2012
Message 5 of 6 (250 Views)

Re: Match Expression to fetch dynamic string

Hello Konstantin,

 

The suggestion that you gave worked.

 

I created a script that would egrep two ports and using your pattern match i was able to display the end result of both the greps.

I later used a calculated metric to set a threshold to the values.

 

Thanks a lot...!!

 

-Utkarsh

Please use plain text.
Respected Contributor
Konstantin.Kornienko
Posts: 250
Registered: ‎12-25-2005
Message 6 of 6 (93 Views)

Re: Match Expression to fetch dynamic string

Utkarsh, you are welcome!

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation