Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. ExternalParameters, some parse some don't

ExternalParameters, some parse some don't

Scheduled Pinned Locked Moved Support
2 Posts 2 Posters 12.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    D
    danieljdoughty
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0

      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
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      Powered by NodeBB Contributors
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups