Single OData query to retrieve the Interface Name and Host Name based on an IP address
search cancel

Single OData query to retrieve the Interface Name and Host Name based on an IP address

book

Article ID: 230898

calendar_today

Updated On:

Products

CA Performance Management - Usage and Administration DX NetOps

Issue/Introduction

Below is a request from our automation engineer in regards to API capabilities.

I'm wondering if I can get the same level of information from the API that I get from Inventory > Items > Interface Addresses > Quick Filter

I figured out how to do it in two steps by searching for an interface with the IP, and then searching for the device ID the response returns

This returns an interface name and the device id 25503019
http://DA:8581/odata/api/interfaces?$select=IPAddresses,DisplayName,DeviceItemID,Name&$filter=((substringof('10.0.0.1', IPAddresses) eq true))

This searches for the hostname of the device ID
http://DA:8581/odata/api/devices?$select=HostName&$filter=((components/DeviceItemID eq 25503019))

Environment

Release : 21.2

Component : IM Data Aggregator

Resolution

Here is an example of a single OData query to retrieve the Interface name and Host Name based on an IP address:

http://DA:8581/odata/api/interfaces?$expand=device&$select=ID,Name,IPAddresses,device/ID,device/Name,device/HostName&$filter=((substringof('<ip>', IPAddresses) eq true))

http://DA:8581/odata/api/interfaces?$expand=device&$select=ID,Name,IPAddresses,device/ID,device/Name,device/HostName&$filter=((substringof('10.0.0.1', IPAddresses) eq true))

Note: These will be DA item_ids, not PC.