Application Perf Mgmt (BAC / BSM) Practitioners Forum
Showing results for 
Search instead for 
Do you mean 

Match Expression to fetch dynamic string

SOLVED
Go to Solution
Frequent Advisor

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

5 REPLIES
HPE Expert

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
Respected Contributor [Founder]

Re: Match Expression to fetch dynamic string

Try something like

 

/(\w+)$/

 

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

HPE Expert

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
Highlighted
Frequent Advisor

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

Respected Contributor [Founder]

Re: Match Expression to fetch dynamic string

Utkarsh, you are welcome!