As an administrator, you can automate the removal of retired components from your network. Understand how to use the script that is included with Data Aggregator to delete retired components before you write a script to automate the process. For example, you can set up a weekly cron job to delete retired components that are a month old.
The remove_retired_items script that is included with Data Aggregator is comprised of two parts. The first part of the script identifies and returns data about retired components, which is based on the filter that you set. The second part of the script issues the delete of the retired component list. To automate the process, understand how this script was built.
Note: For information about using the remove_retired_items script, see the Data Aggregator Administrator Guide.
Example: Filter the List of Retired Components By a Device IP Address
In this example, you want to find all of the retired components for a device that has a primary IP address of 10.252.1.1. Filtering by IP address is a two-step process because no direct component filter by IP address is available. To filter retired components, first make note of the IP address for the device that the components are associated with. With the IP address information, you will determine the device item ID for the device. Then, using the device item ID, you will determine what the retired components are. Finally, you will delete the retired components.
Note: This example uses the curl command, but you can use any command that you are familiar with.
<FilterSelect xsi:noNamespaceSchemaLocation="filter.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Filter>
<And>
<Device.PrimaryIPAddress type="EQUAL">10.252.1.1</Device.PrimaryIPAddress>
</And>
</Filter>
</FilterSelect>
curl -X http://hostname:port/rest/devices/filtered -H "Content-Type: application/xml" -T "filterDeviceIP.xml" > returnedDeviceID.xml
Creates the filter that you indicate.
Specifies the Data Aggregator host name and the port number.
Default port: 8581
Indicates the content type of the file that you are posting.
Indicates the file that you are posting.
The following result is returned as an HTTP response:
<?xml version="1.0"?>
<DeviceList>
<Device version="1.0.0">
<ID>107881</ID>
<PrimaryIPAddress>10.252.1.1</PrimaryIPAddress>
<supportsOnDemandMFDiscovery>true</supportsOnDemandMFDiscovery>
<SupportedProtocolsList>
<SupportedProtocols>ICMP</SupportedProtocols>
</SupportedProtocolsList>
<DiscProfileID>107503</DiscProfileID>
<HostName>rtp003723rts.ca.com</HostName>
<RelatesTo>
<MonitoredGroupIDList relatesURL="relatesto/monitoredgroups" rootURL="monitoredgroups">
<ID>509</ID>
</MonitoredGroupIDList>
<GroupIDList relatesURL="relatesto/groups" rootURL="groups">
<ID>547</ID>
<ID>530</ID>
<ID>509</ID>
</GroupIDList>
</RelatesTo>
<IsAlso>
<IsA name="MetricFamilyDiscoveryHistory" rootURL="devices/mfdiscoveryhistory"/>
<IsA name="AccessibleDevice" rootURL="devices/accessible"/>
<IsA name="Syncable" rootURL="syncable"/>
<IsA name="IPDomainMember" rootURL="ipdomainmember"/>
</IsAlso>
<DataCoectionMgrId version="1.0.0">
<DcmID>dcname.ca.com:8f53bc55-f442-42fc-9bd5-a907d0261421</DcmID>
</DataCollectionMgrId>
<Syncable version="1.0.0">
<SyncID>-1</SyncID>
</Syncable>
<Item version="1.0.0">
<DisplayName>router.ca.com</DisplayName>
<CreateTime>Wed Feb 05 10:20:26 EST 2014</CreateTime>
<Name>router.ca.com</Name>
</Item>
<IPDomainMember version="1.0.0">
<IPDomainID>2</IPDomainID>
</IPDomainMember>
<DeviceMonitoringProfile version="1.0.0">
<ConsolidatedMonitoringProfile>2509</ConsolidatedMonitoringProfile>
</DeviceMonitoringProfile>
</Device>
</DeviceList>
Device item ID 107881 is returned. The results also display detailed information about the device.
<FilterSelect xsi:noNamespaceSchemaLocation="filter.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Filter>
<And>
<DeviceComponent.DeviceItemID type="EQUAL">107881</DeviceComponent.DeviceItemID>
</And>
</Filter>
<Select use="exclude">
<Item use="exclude">
<DisplayName use="include"/>
</Item>
</Select>
</FilterSelect>
curl -X post http://hostname:port/rest/retired/filtered -H "Content-Type: application/xml" -T "filterRetired.xml" > returnedRetireItems.xml
The following result is returned as an HTTP response:
<?xml version="1.0"?>
<RetiredList>
<Retired version="1.0.0">
<ID>128452</ID>
<Item version="1.0.0">
<DisplayName>GigabitEthernet0/239 - GigabitEthernet0/239</DisplayName>
</Item>
</Retired>
<Retired version="1.0.0">
<ID>128451</ID>
<Item version="1.0.0">
<DisplayName>GigabitEthernet0/238 - GigabitEthernet0/238</DisplayName>
</Item>
</Retired>
</RetiredList>
Two retired components that fit the filter criteria are returned. The item IDs for the components are 128452 and 128451.
<DeleteList> <ID>128452</ID> <ID>128451</ID> </DeleteList>
curl -X post http://hostname:port/rest/retired/deletelist -H "Content-Type: application/xml" -T "deleteRetiredList.xml" > deletelistreponse.xml
The following result is returned as an HTTP response:
<?xml version="1.0"?>
<DeleteListResult>
<DeleteResult>
<ID>128452</ID>
<Error>SUCCESS</Error>
</DeleteResult>
<DeleteResult>
<ID>128451</ID>
<Error>SUCCESS</Error>
</DeleteResult>
</DeleteListResult>
The retired components are successfully removed.
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|