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. [SOLVED] format string in DCI Container not working

[SOLVED] format string in DCI Container not working

Scheduled Pinned Locked Moved Support
6 Posts 2 Posters 22.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.
  • A
    A
    alexrhyshurn
    wrote on last edited by
    #1

    Hello,

    This is my first post, so I hope I am clear.

    I having problems with formatting the DCI Containers on a network map. Running NetXMS 2.2.10 on Ubuntu.

    I am reading these:

    1. https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
    2. https://track.radensolutions.com/issue/NX-501
    3. https://www.netxms.org/documentation/adminguide/visualisation.html?highlight=visual

    It seems that most common formatters would include:
        %s - insert a string
        %d - insert a signed integer (decimal)
        %f - insert a real number, standard notation

    And we can see from the documentation:

    For each Data Source can be configured: Data collection item, name, format string(like “Text: %.4f”), in case of table DCI also column and instance

    So, my problem is that if I select a DCI, the Map displays the integer with 6 decimal places, and I want to reduce that to two. However ANY format string items do not work.

    E.g. putting the suggested %.4f returns an <INVALID FORMAT> (%.4f), using %d returns the same. Switching the DCI itself between string and integer makes no difference.

    Please can somebody help me understand what I an doing wrong?

    Many thanks.

    Alex

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

      Hi,

      could you post your DCI configuration and some actual values?

      Best regards,
      Victor

      1 Reply Last reply
      0
      • A
        A
        alexrhyshurn
        wrote on last edited by
        #3

        Hi,

        Thanks for the response.

        The DCI is a simple query an SNMP value (no transformations or anything) from a Schneider Powerlogic ION Power Meter, and the Map is a DCI Container, I have shown the raw value as well as some others with format string. I am aiming to get 2 deminal places precision.

        I should add, that the DCI containers shown with data are using %s

        Thanks,

        Alex


        LV0_Power_meter_DCI_Forum.png

        network_map_forum.png

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

          Hi,

          am I understood correctly that actual returned value contains floating point number and text "kW"? If yes, Java consider it as string and do not allow numeric formatting. You can change DCI data type to floating point number and use transformation script to remove unit indicator, like this:

          if ($1 ~= "([0-9.]+) kW")
             return $1;
          return $1;
          

          Best regards,
          Victor

          1 Reply Last reply
          0
          • A
            A
            alexrhyshurn
            wrote on last edited by
            #5

            Hi,

            I am sorry I was not clear.

            The returned value for %s is, for example, 109.794250 plain and simple.

            In the format string I have put %s kW so giving the result of 109.794250 kW

            If I create a new DCI COntainer and leave the format string blank it returns: 109.794250
            If I create a new DCI COntainer and put %s in the format string it returns: 109.794250

            I can use any text around the %s such as Total Grid Power: %s kW which returns: Total Grid Power: 109.794250 kW

            What I want to do is take the result from %s and reduce it to two decimal places.

            So I don't think that its a string.

            Best regards,

            Alex

            1 Reply Last reply
            0
            • A
              A
              alexrhyshurn
              wrote on last edited by
              #6

              Hello,

              Thanks for all the feedback.

              My problem was (of course) entirely my mistake.

              I did not understand the difference between integer and Floating Point data type. An integer is just that, a whole number and so cannot get decimal places.

              So trying to use %.2f format string with integer cant work. I Changed my DCIs to Floating point, and now %.2f for 2 decimal places is working fine.

              Apologies to all.

              Alex

              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