Re: Match Expression to fetch dynamic string (371 Views)
Reply
Frequent Advisor
Utkarshpatel
Posts: 60
Registered: ‎02-15-2012
Message 1 of 6 (452 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

HP Expert
kenneth.gonzalez
Posts: 1,769
Registered: ‎04-28-2011
Message 2 of 6 (417 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
Respected Contributor
Konstantin.Kornienko
Posts: 253
Registered: ‎12-25-2005
Message 3 of 6 (411 Views)

Re: Match Expression to fetch dynamic string

Try something like

 

/(\w+)$/

 

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

HP Expert
kenneth.gonzalez
Posts: 1,769
Registered: ‎04-28-2011
Message 4 of 6 (409 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
Frequent Advisor
Utkarshpatel
Posts: 60
Registered: ‎02-15-2012
Message 5 of 6 (371 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

Respected Contributor
Konstantin.Kornienko
Posts: 253
Registered: ‎12-25-2005
Message 6 of 6 (214 Views)

Re: Match Expression to fetch dynamic string

Utkarsh, you are welcome!

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.