ExternalParameters, some parse some don't
-
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 /vardue 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 -
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login