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. IP/Mac Address lookup

IP/Mac Address lookup

Scheduled Pinned Locked Moved Support
6 Posts 2 Posters 84.7k 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.
  • G
    G
    gmonk63
    wrote on last edited by
    #1

    Is it possible to do IP and Mac address lookups vi nxshell or other command line tools.  I would like to be able to use a script to query where a particular mac address is connected with out having to log in using the client .  I didnt see any options listed in the nxadm  or in the nxshell api  but I could have over looked something.

    Thanks

    1 Reply Last reply
    0
    • A
      A
      Alex Kirhenshtein
      wrote on last edited by
      #2

      Yes, it's possible to do with nxshell. Some examples:

      find by mac:

      import sys
      mac = sys.argv[1].upper()
      
      for node in [o for o in s.getAllObjects() if isinstance(o, objects.Node)]:
          interfaces = node.getAllChilds(objects.GenericObject.OBJECT_INTERFACE)
          for interface in interfaces:
              if mac in interface.getMacAddress().toString().upper():
                  print "%s(%d) - %s - %s" % (node.getObjectName(),
                                              node.getObjectId(),
                                              interface.getMacAddress(),
                                              interface.getIpAddressListAsString())
      

      find by ip:

      import sys
      ip = sys.argv[1]
      
      for node in [o for o in s.getAllObjects() if isinstance(o, objects.Node)]:
          interfaces = node.getAllChilds(objects.GenericObject.OBJECT_INTERFACE)
          for interface in interfaces:
              for interface_ip in interface.getIpAddressList():
                  if ip in interface_ip.toString():
                      print "%s(%d) - %s - %s" % (node.getObjectName(),
                                                  node.getObjectId(),
                                                  interface.getMacAddress(),
                                                  interface.getIpAddressListAsString())
      

      Sample session:

      ~/Development/netxms/src/java/nxshell/target (develop|…)% java -Dnetxms.server=127.0.0.1 -Dnetxms.login=admin -Dnetxms.password=netxms -jar nxshell-2.0-RC2.jar find_by_mac.py B2:00:1C:15:BC:E0
      AirAlk.local(100) - B2:00:1C:15:BC:E0 - 0.0.0.0/0
      ~/Development/netxms/src/java/nxshell/target (develop|…)% java -Dnetxms.server=127.0.0.1 -Dnetxms.login=admin -Dnetxms.password=netxms -jar nxshell-2.0-RC2.jar find_by_ip.py 127
      AirAlk.local(100) - 00:00:00:00:00:00 - 127.0.0.1/8
      
      1 Reply Last reply
      0
      • G
        G
        gmonk63
        wrote on last edited by
        #3

        oh wow you saved me so much time ... Thank you so much

        1 Reply Last reply
        0
        • G
          G
          gmonk63
          wrote on last edited by
          #4

          Alex,

          what you provided is great ... However how would I tweak this tool to provide the same functionality as  Find Mac address tool in the managment console  which also provides the switch and port the mac is connected to..


          2015-12-02 15_43_39-NetXMS Management Console.png

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

            Try attached script.


            find_port.py

            1 Reply Last reply
            0
            • G
              G
              gmonk63
              wrote on last edited by
              #6

              Works like a charm ... Thanks

              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