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. Transformation: Add previous DCI value to current DCI value?

Transformation: Add previous DCI value to current DCI value?

Scheduled Pinned Locked Moved Support
7 Posts 3 Posters 53.2k 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.
  • M
    M
    Millenium7
    wrote on last edited by
    #1

    I'm trying to create a usage graph in netXMS and having trouble with the formulas to do so

    At the moment i'm polling an interface for the traffic, then using simple delta transformation with "return max($1, 0);" (to avoid negative numbers if i.e. router restarts)
    What I need now is a way to read the last dci value and add it to the current result, so that it continually increments

    i.e. currently it returns
    6pm - 53mb
    (router restarts)
    7pm - 0mb
    8pm - 155mb
    9pm - 110mb

    I need to add each previous value together so that it shows a running total
    i.e.
    6pm - 53mb
    7pm - (0mb + 53mb) = 53mb
    8pm - (53mb + 155mb) = 208mb
    9pm - (208mb + 110mb) = 318mb

    1 Reply Last reply
    0
    • T
      T
      Tursiops
      wrote on last edited by
      #2

      https://wiki.netxms.org/wiki/NXSL:GetDCIValue might work.
      As you are in the transform stage, the value that you just collected can't be returned as a result yet, which means it should return the previous one?

      1 Reply Last reply
      0
      • M
        M
        Millenium7
        wrote on last edited by
        #3

        I think that will do it. I've tested with
        t = GetDCIValue($node,8347);
        return t;

        And it does return the previous value. But i'm having trouble with the syntax for the DCI id (since I dont want to type it in manually)
        I've tried
        t = GetDCIValue($node,$dci->id);
        return t;

        And its giving my an error. I can't find the syntax I need to return the ID number of the current DCI

        While i'm at it, is there a better way for troubleshooting and finding out the correct syntax? I struggle with this all the time because its very difficult to know if i'm typing syntax correctly, or wht values are being returned. Is there a console I can open and type these sorts of commands in and get some realtime help on syntax and output, similar to a SSH terminal i.e. type GetDCI<tab> and it will me all the available commands. As well as manually type those in i.e. "echo GetDCIValue(230,123)" and see the output

        1 Reply Last reply
        0
        • M
          M
          Millenium7
          wrote on last edited by
          #4

          Ok I found reference that there's a bug with read access from a forum post back in 2014

          https://www.netxms.org/forum/general-support/transformation-script-and-$dci-object/

          It seems that bug is still present, test will show an error but $dci->id does work when actually polling the DCI. So this is what I have come up with so far

          t = GetDCIValue($node,$dci->id);
          if (t != null)
          return t + $1;
          else
          return $1 - $1;
          

          Transformation set to simple delta. The first result will always return 0, after that it counts up usage continuously

          The next question is then how do I handle resetting the value back to 0 after a day/week/month?
          Is there a scripting command to clear all old data? Then I can simply add some code to check the date/time and clear the values accordingly
          Alternatively I could do the same but manually reset the value to 0 which would work fine I suppose. The graph would show a saw-tooth pattern over time
          The ultimate solution would be to sum all previous DCI values between the last '0', delete all those entries and replace it with a single sum entry. That would drastically reduce the amount of stored data and let me see a single spike per day/week/month on a history graph separated by a single 0 entry

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

            Hi,

            it is not possible to delete data from within script. Reset to 0 will work (you can check current date and time in script and return 0 if it is first poll after midnight).

            Another possible option is to create two DCIs - one short term and one long term. Long term DCI will have custom schedule to collect it once per day/week/month/etc. and it will get get sum of values from short term DCI for required period. Retention time for short term DCI can be set to desired time interval plus some extra time to allow long term DCI collector script to run.

            Best regards,
            Victor

            1 Reply Last reply
            0
            • M
              M
              Millenium7
              wrote on last edited by
              #6

              Ok next question

              I was considering creating a table instead of lots of individual DCI's. That way I can have daily/weekly/monthly usage as well as other information like number of reconnects etc all on a single line for an interface without dozens/hundreds of DCI entries

              Is it possible to do simple delta calculation in table columns yet? I can't see a drop down option for it, can I do it manually somehow?

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

                Delta calculation for tables is not implemented yet.

                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