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. Two snmp requests in one dci

Two snmp requests in one dci

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

    Hello

    What is the best approach to make dci that queries 2 separate snmp oids, does some math with them and then returns the output. is it possible to do in one dci, or is multiple required?

    Example:
    .1.3.6.1.2.1.25.2.3.1.6.131072 - returns 11320 (/1024 = 11mb)
    .1.3.6.1.2.1.25.2.3.1.5.131072 - returns 16384 (/1024 = 16mb)
    Output = 16-11 = 4mb

    Its Mikrotik disk usage.

    1 Reply Last reply
    0
    • F
      F
      Filipp Sudanov
      wrote on last edited by
      #2

      It's possible to make script DCI that would take values from other DCIs and do the calculation. But if you don't need to keep the intermediary values, they you can do everything just in one DCI.

      Create s script in script library and Script DCI that uses that script. Check this example for script contents: https://www.netxms.org/documentation/nxsl-latest/#func-snmpgetvalue

      1 Reply Last reply
      0
      • E
        E
        Egert143
        wrote on last edited by
        #3

        I hacked together something like this: 

        transport = CreateSNMPTransport($node);
        if (transport == null) { return null; }
        
        diskSize = SNMPGetValue(transport,".1.3.6.1.2.1.25.2.3.1.5.131072");
        diskUsed = SNMPGetValue(transport,".1.3.6.1.2.1.25.2.3.1.6.131072");
        
        if(diskSize == null || diskUsed == null) { return null; }
        
        free = diskSize - diskUsed;
        free = free * 1024;
        
        
        return free;
        

        " free = free * 1024; " is because otherwise unit b(IEC) was showing incorrectly.

        is there anything that could be improved on this script?

        1 Reply Last reply
        0
        • F
          F
          Filipp Sudanov
          wrote on last edited by
          #4

          Looks good. There's a small chance that SNMPGetValue may return null (e.g. communication gets broken exactly when these requests are made), so you may want to check diskSize and diskUsed for null.

          1 Reply Last reply
          0
          • E
            E
            Egert143
            wrote on last edited by
            #5

            is that not good?

            if(diskSize == null || diskUsed == null) { return null; }
            
            1 Reply Last reply
            0
            • F
              F
              Filipp Sudanov
              wrote on last edited by
              #6

              Ups, i missed that line 🙂

              Yes, it's correct

              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