Reply
Accepted Solution

Trigger templates and percent sign in text

adomeit
Techie
Posts: 7
2888     0

Hi....This one has been driving me a little crazy for a day or so now and I'm just not able to get this to work.  I'm writing a CCS script that will check if there is enough space free on a Juniper switch and then copy out files needed for code upgrades.  Here's an example of the output from the switch of a line that I want NetMRI to process:

 

/dev/da0s3d             887M        32K       816M        0%  /var/tmp

 

The parts are the device, partition size, how much is used, how much is free, capacity in percent and the mount location.  So far, nothing too hard to deal with.  What I want to do is just break the fields apart and then set variables to them.  So I set up a Trigger like this:

 

Trigger-Variables:

$size word
$used word
$available word
$capacity word
$mountpoint word

 

Trigger-Template:

\/dev\/[a-z0-9]+\s+[[$size]]\s+[[$used]]\s+[[$available]]\s+[[$capacity]]\s+[[$mountpoint]]

 

There's some other output so the first bit of matching /dev/blah-blah/blah just filters out the lines that are not interesting at all.

 

This just fails to match anything.  So if I start backing things out and just go up to capacity (skipping mountpoint), it works BUT capacity is set to 0 and not 0%.  

 

I've tried several different things like changing $capacity from word to string or integer.  With string or integer, I can get it to populate but just with "0" and not "0%" but the real problem is that no matter what I do, I can't get the remainder of the line that has the mount point to ever match no matter what.   

 

So again, looking at this line below, the trigger stuff works all the way up to and including the 0 in the 0% but I can't get anything to match the mount point after that.

/dev/da0s3d 887M 32K 816M 0% /var/tmp

 

As a total punt, I tested just setting the trigger-variable to "$helpme /(\/var\/tmp)/" and set the trigger-template to [[$helpme]] and it successfully returned /var/tmp so I'm just not doing something right trying to deal with that percent sign.  I've tried to escape it out with the \ and tried to wildcard it as well but I just can't get it to work.  

 

I don't care if the variable has 0 or 0% in it, I can handle it either way but it needs to keep going and also grap the mount point so I'm stuck.  

 

Does anyone have any ideas?

 

 

 

Re: Trigger templates and percent sign in text

Adviser
Posts: 411
2889     0

Here you go buddy Smiley Happy

 

Variables:

$size word
$used word
$available word
$capacity /\d+\%/
$mountpoint /\/\w+\/\w+/

 

Template:

\/dev\/[a-z0-9]+\s+[[$size]]\s+[[$used]]\s+[[$available]]\s+[[$capacity]]\s+[[$mountpoint]]

 

Matches:

 14:49:48   Trigger-Variables 
 14:49:48     $size = '887M' 
 14:49:48     $used = '32K' 
 14:49:48     $available = '816M' 
 14:49:48     $capacity = '0%' 
 14:49:48     $mountpoint = '/var/tmp' 
 14:49:48   

 

 

Also remember you can use NetMRI RegEx Test Tool - http://ipaddress/netmri/ccs/tx/regex_test/index.tdf

 

Sif

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

Re: Trigger templates and percent sign in text

adomeit
Techie
Posts: 7
2889     0

Sif, we have a winner ha!  I swapped out all the \s+ stuff for [ ]{1,} because I forgot that \s not only matches space and tab but also line breaks and that just causes me all kinds of problems.  Thanks and you still maintain the title of "The Best".  :-)

-p

Re: Trigger templates and percent sign in text

Adviser
Posts: 411
2889     0

Thank you @adomeit, I do appriciate that Smiley Happy

 

Sif

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh
Showing results for 
Search instead for 
Do you mean 

Recommended for You