Looking up device information
The first task that you want the policy to perform is to look up device information that is related to the alert in the network inventory database.
About this task
Specifically, you want the policy to retrieve technical specifications for the device that is causing the alert, and information about the facility and the rack number where the device is located.
To
do this, the policy must perform a SELECT at the
database level on the table that contains the device data and return
those rows that are related to the incoming alert. Viewed from the
data model perspective, the policy must get data items from the Device data
type where the value of the Hostname field is the
same as the value of the Node field in the alert.
To retrieve the data items, you type the following code into the Netcool®/Impact policy editor tab:
DataType = "Device";
Filter = "Hostname = '" + @Node + "'";
CountOnly = False;
MyDevices = GetByFilter(DataType, Filter, CountOnly);
MyDevice = MyDevices[0];
If (Length(MyDevices) < 1) { Log("No matching device found."); }
If (Length(MyDevices) > 1) { Log("More than one matching device found."); }Here, GetByFilter is
retrieving data items from the Device data type where
the value of the Hostname field is equal to the value
of the Node field in the incoming alert. The data items are stored
in an array named MyDevices.
Although GetByFilter is
able to return more than one data item in the array, you only expect
the array to contain one data item in this situation, as each device
in the database has a unique Hostname. The first
element of the MyDevices array is assigned to the MyDevice variable
so that MyDevice can be used as shorthand later in
the policy.
Because you want to retrieve only
one data item from the data type, the policy also prints error messages
to the policy log if GetByFilter retrieves less than
or more than one.