ExternalParameters, some parse some don't

Started by danieljdoughty, October 02, 2008, 12:42:59 AM

Previous topic - Next topic

danieljdoughty

I have one that parses just fine:

ExternalParameter = pserver:/bin/ps -ef | /usr/local/bin/grep pserver | /usr/local/bin/grep -v grep | /bin/wc -l | /usr/local/bin/awk '{print $1}'

This will output an integer that I can parse on.

This one doesn't seem to parse right:

ExternalParameter = rootInodes:/usr/sbin/df -F ufs -o i / | /bin/tail -1 | /usr/local/bin/awk '{print $4}' | /bin/sed -e 's/%//g'

Instead I get something like this:
/dev/md/dsk/d4 38901 220171 15 /var

due to all the awk and sed work, I should only see the 15.  Interestingly enough, it seems that the sed worked to strip the % off, but the awk fails in the second example.  However it works in the first example.

Thanks,
Dan

Victor Kirhenshtein

Hello!

This is because $1 .. $9 is a macros substituted by NetXMS agent itself - they represent arguments for a parameter. If you need to pass $ sign as part of a command, you should use $$.
So your command should looks like:
ExternalParameter = rootInodes:/usr/sbin/df -F ufs -o i / | /bin/tail -1 | /usr/local/bin/awk '{print $$4}' | /bin/sed -e 's/%//g'

First example works, because wc -l gives you only one word, so { print $1 } transformed to { print } doesn't actually affect anything.

Best regards,
Victor