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. GetSumDCIValue and 64bits integer

GetSumDCIValue and 64bits integer

Scheduled Pinned Locked Moved Support
10 Posts 2 Posters 39.8k 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
    Marco Incalcaterra
    wrote on last edited by
    #1

    Hi!

    As per subject, I have a problem with the GetSumDCIValue when the result is greater than a 32bit integer.
    This is my transformation:

    return int64(GetSumDCIValue($node, FindDCIByDescription($node, "WAN: delta in (bytes)"), time()-86400, time()));
    

    It returns 0 when the result cannot be handled by a 32 bits integer.

    I have another version of that DCI that uses a different approach to do the same computations and it works properly:

    last = int64(GetCustomAttribute($node, "WANCumulativeIn"));
    if (last == null)
    	last = 0;
    SetCustomAttribute($node, "WANCumulativeIn", 0);
    return last;
    

    The data type assigned to both DCIs is "Unsigned Integer 64 bit" (NB in the last example the custom attribute is updated by another DCI).

    Any hints?

    Best regards,
    Marco

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

      Hi!

      Could you check what is returned by underlying SQL query? Implementation of this function tries to parse value read from database as double, so there should be no limitation on 32bit integer size.

      Actual query is

      SELECT avg(coalesce(idata_value,0)) FROM idata_<node_id_here> WHERE item_id=<dci_id_here> AND (idata_timestamp BETWEEN <time1> AND <time2>);

      Best regards,
      Victor

      1 Reply Last reply
      0
      • J
        J
        Marco Incalcaterra
        wrote on last edited by
        #3

        @victor said in GetSumDCIValue and 64bits integer:

        Hi!

        Could you check what is returned by underlying SQL query? Implementation of this function tries to parse value read from database as double, so there should be no limitation on 32bit integer size.

        Actual query is

        SELECT avg(coalesce(idata_value,0)) FROM idata_<node_id_here> WHERE item_id=<dci_id_here> AND (idata_timestamp BETWEEN <time1> AND <time2>);

        Best regards,
        Victor

        I get "Arithmetic overflow error converting expression to data type int". I propose to apply the same suggestion as per this thread:

        https://www.netxms.org/forum/configuration/getxxxdcivalue-(avgmaxmin)-fails-on-floating-numbers/msg13724/#msg13724

        adding

        cast(idata_value as float),0)
        

        inside the coalesce function.

        Best regards,
        Marco

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

          Yes, that change already applied - so after upgrade to 1.2.14 you'll get this problem fixed as well.

          Best regards,
          Victor

          1 Reply Last reply
          0
          • J
            J
            Marco Incalcaterra
            wrote on last edited by
            #5

            @victor said in GetSumDCIValue and 64bits integer:

            Yes, that change already applied - so after upgrade to 1.2.14 you'll get this problem fixed as well.

            Best regards,
            Victor

            Is there a reason to get always null in return from this function:

            GetMaxDCIValue($node, $dci->id, time()-86400, time());

            I tried to run manually the query (as per the SQL syntax in this thread) and it works fine, but I'm not able to have the function working in my transformation script.

            Best regards,
            Marco

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

              Hi!

              Actually there is an error in query used in function. Query looks like

              SELECT max(coalesce(cast(idata_value as float),0)) FROM idata_%u
              WHERE item_id=? AND (idata_timestamp BETWEEN ? AND ?) AND isnumeric(idata_value)

              but isnumeric returns int, not boolean, so it should be

              isnumeric(idata_value)=1

              I've fixed it. PLease let me know if you need intermediate server build with this fix.

              Best regards,
              Victor

              1 Reply Last reply
              0
              • J
                J
                Marco Incalcaterra
                wrote on last edited by
                #7

                @victor said in GetSumDCIValue and 64bits integer:

                I've fixed it. PLease let me know if you need intermediate server build with this fix.

                Best regards,
                Victor

                It could be nice to have it, I'm using the x64 Windows version.

                Best regards,
                Marco

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

                  Hi!

                  I'm finally built an intermediate release. It is available here: https://www.netxms.org/download/1.2.15-M1/.

                  Best regards,
                  Victor

                  1 Reply Last reply
                  0
                  • J
                    J
                    Marco Incalcaterra
                    wrote on last edited by
                    #9

                    @victor said in GetSumDCIValue and 64bits integer:

                    Hi!

                    I'm finally built an intermediate release. It is available here: https://www.netxms.org/download/1.2.15-M1/.

                    Best regards,
                    Victor

                    Thank you very much for your effort, I'm downloading it, I plan to install it tonight.

                    Best regards,
                    Marco

                    1 Reply Last reply
                    0
                    • J
                      J
                      Marco Incalcaterra
                      wrote on last edited by
                      #10

                      @victor said in GetSumDCIValue and 64bits integer:

                      Hi!

                      I'm finally built an intermediate release. It is available here: https://www.netxms.org/download/1.2.15-M1/.

                      Best regards,
                      Victor

                      Is it possible to have the WebUI? You changed the protocol and the previous version is no more able to connect.

                      Best regards,
                      Marco

                      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