2 Replies Latest reply on Aug 22, 2019 2:03 AM by Fang Huei Sim

    Query to search host start from MAC Address

    Fang Huei Sim
      Share This:

      I have been writing query to get host's mac address where the query will start from example "search Host show name, #DevideWithInterface:DeviceInterface:InterfaceOfDevice:NetworkInterface.mac_address as 'Mac Address'.

      I would like to know if we can write a query that start backward, where we start from Mac Address and then get the corresponding host?

      The answer should be No right?

        • 1. Re: Query to search host start from MAC Address
          Saurabh Thuse

          In Discovery, we have relationships from both sides of the nodes. So the way you can traverse from Host to NetworkInterface, you will be able to traverse from NetworkInterface to Host.

           

          If you want to get Host MAC address then I will suggest you to start from Host only to be efficient i.e you first approach.

           

          Remember NetworkInterface node is also present on other root nodes like NetworkDevice, StorageDevice, Printer etc. So number of NetworkInterface nodes present might be much higher than number of Hosts and hence will not be efficient.

           

          Just in case you are keen on getting query to start from NetworkInterface then you can consider below queries.

           

          If you want list of Host:

          search NetworkInterface traverse InterfaceOfDevice:DeviceInterface:DeviceWithInterface:Host show hostname as 'Hostname', #DeviceWithInterface:DeviceInterface:InterfaceOfDevice:NetworkInterface.interface_name as 'Interface Name', #DeviceWithInterface:DeviceInterface:InterfaceOfDevice:NetworkInterface.mac_addr as 'MAC Address', #DeviceWithInterface:DeviceInterface:InterfaceOfDevice:NetworkInterface.name as 'Name'

           

          If you want list of Network Interfaces then you can run :

          search NetworkInterface show interface_name, mac_addr, name as 'Interface Name with Host Name', #InterfaceOfDevice:DeviceInterface:DeviceWithInterface:Host.hostname as 'Hostname'

           

          Thanks,

          Saurabh Thuse

          2 of 2 people found this helpful
          • 2. Re: Query to search host start from MAC Address
            Fang Huei Sim

            Thanks Saurabh, your explaination is very clear and percise.