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. Instance Discovery (Port Admin State, Port OperState)

Instance Discovery (Port Admin State, Port OperState)

Scheduled Pinned Locked Moved Support
7 Posts 3 Posters 20.3k 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
    mike
    wrote on last edited by
    #1

    Hi,

    I tried to get a List of my Ports. The DCI should give me the operState. But just for Port with Admin = up.

    This is what i tried:

    dci Name: Port {instance-name}
    SNMP OID: .1.3.6.1.2.1.2.2.1.8.{instance}

    Base OID: .1.3.6.1.2.1.2.2.1.8

    snmp = CreateSNMPTransport($node);
    
    value = SNMPGetValue(snmp, ".1.3.6.1.2.1.2.2.1.8." . $1);
    nam = SNMPGetValue(snmp, ".1.3.6.1.2.1.31.1.1.1.18." . $1);
    adm = SNMPGet(snmp, ".1.3.6.1.2.1.2.2.1.7." . $1);
    
    if (value != null && value != 0 && nam != null && adm->value == 1)
                    return %(true, value, nam);
    else return false;
    
    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Hi,

      you are using undefined variable "transport" here:

      adm = SNMPGet(transport, ".1.3.6.1.2.1.2.2.1.7." . $1);
      

      Best regards,
      Victor

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

        hi, thanks for reply.
        Unfortunately this was a mistake while writing the post.

        This is my last version:

        snmp = CreateSNMPTransport($node);
        
        oper = SNMPGetValue(snmp, ".1.3.6.1.2.1.2.2.1.8." . $1);
        nam = SNMPGetValue(snmp, ".1.3.6.1.2.1.31.1.1.1.18." . $1);
        adm = SNMPGetValue(snmp, ".1.3.6.1.2.1.2.2.1.7." . $1);
        dec = SNMPGetValue(snmp, ".1.3.6.1.2.1.31.1.1.1.1." . $1);
        
        if (oper != null && oper != 0 && nam != null && adm == 1)
              return %(true, oper, dec . " - " . nam);
        else return false;
        

        /edit:
        I saw that i corrected my mistake 3 seconds before your post. I was a bit too late 🙂

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

          One (or two) issues here. First of all, ensure that you are using "SNMP walk - OIDs" as discovery method (because you want instance to be interface index). Alternatively, you can change base OID to return interfaces indexes as values.
          And most important, you replace original instance value with interface operational state:

           return %(true, oper, dec . " - " . nam);
          

          effectively reducing all instances into few. Correct will be to keep interface index as instance:\

           return %(true, $1, dec . " - " . nam);
          

          Best regards,
          Victor

          1 Reply Last reply
          0
          • M
            M
            mike
            wrote on last edited by
            #5

            Thank you, the "$1" solved the Problem. I attached my configuration in case someone is interested.

            Is there a chance to check for just the first (or any) part of the description name? I have many ports named "Test_xxx". It would be nice to search for "Test" in the first 4 letters and exclude them too.


            1.PNG

            2.PNG

            1 Reply Last reply
            0
            • T
              T
              tomaskir
              wrote on last edited by
              #6

              Simply do a regex compariston

              if (someVar ~= "Test_.*") {
                println("Its a test interface!");
              }
              
              1 Reply Last reply
              0
              • M
                M
                mike
                wrote on last edited by
                #7

                That solved the problem. Thank you.

                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