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. Tranform and Condition Scripts

Tranform and Condition Scripts

Scheduled Pinned Locked Moved Support
5 Posts 3 Posters 25.0k 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.
  • J
    J
    jdlds
    wrote on last edited by
    #1

    Hi Guys,

    I was wondering if anyone could share a non-trivial script for the DCI transform or the condition.
    Based on the formal declaration of NXSL i can only get basic expressions and function calls to work.  If i define a function or use any if, switch statements the script seems to not function.

    I imagine that i must be doing something wrong but any help would be appreciated.

    For example in the condition script i'm trying to do something like:

    if ($1>5) return min($2, $3);

    Another issue i've encountered is using the PDH.countervalue for data collection.  This seems to work fine for some counters but not others.

    I tried: '\Memory\Committed Bytes' and this seems to work just fine
    but when i tried
    '\PhysicalDisk(_Total)\Disk Write Bytes/sec' this always returns 0.

    if anyone can shed some light on this, that would great.

    -mike

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

      Hello!

      If you write non-trivial scripts (i.e. something more than single expression like $1/1024) you should define main() function. So you script should looks like this:

      sub main()
      {
        if ($1>5) return min($2, $3);
      }

      btw, you should return something also in case  when $1>5 is false, so final form will be

      sub main()
      {
        if ($1>5)
            return min($2, $3);
        return 0; // Or any other default value
      }

      Best regars,
      Victor

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

        @jdlds said in Tranform and Condition Scripts:

        Another issue i've encountered is using the PDH.countervalue for data collection.  This seems to work fine for some counters but not others.

        I tried: '\Memory\Committed Bytes' and this seems to work just fine
        but when i tried
        '\PhysicalDisk(_Total)\Disk Write Bytes/sec' this always returns 0.

        if anyone can shed some light on this, that would great.

        Some counters (like physical disk counter you mention or CPU utilization counters) requires at least two samples to be taken to calculate value. Such counters should be polled in background by agent. To configure agent to do so, use Counter parameter in WinPerf section, like below:

        *WinPerf
        Counter = DiskWriteBytes:"\PhysicalDisk(_Total)\Disk Write Bytes/sec":60:A:INT:Average number of bytes per second written to disk for last minute

        There are several fields separated by colons (:). First is the name for new parameter (DiskWriteBytes in our example); second is counter path; third is number of samples to calculate average value - minimum is 2, and in our example it's 60 (because we need average value for last minute); fourth field is a collection class - it can be either A (collect values every second), B (collect values every 5 seconds), or C (collect values every 30 seconds); fifth field is a data type - it's only a hint for "select parameter" dialog in console and is not used by agent; and sixth field is a parameter description which will be shown in parameter selection dialog.

        After you define your new counter, you can access new parameter on agent by using name specified in the first field.

        Best regards,
        Victor

        1 Reply Last reply
        0
        • A
          A
          Anth0ny
          wrote on last edited by
          #4

          Is it possible to use other multi-sample counters (like "\PhysicalDisk(_Total)\Disk Write Bytes/sec") via interface, not via client's config?

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

            Yes, you can use extended form of PDH.CounterValue:

            PDH.CounterValue("counter name",1)

            If second argument is present in PDH.CounterValue and set to non-zero, then agent will get two samples with 1 second interval, and use them to calculate resulting value.

            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