Example: LookupIp.stch stitcher

Use this topic to understand how topology lookup stitchers work.

The LookupIp.stch stitcher looks up an entity using an IP address or DNS name. The entity that the stitcher finds can be an interface or a main node. The following table describes the key elements of the stitcher.
Table 1. Line-by-line description of the LookupIp.stch stitcher
Line numbers Description
3-7 There is no trigger for this stitcher. The stitcher is automatically called by the PollFailure and EntityFailure event maps. When calling the stitcher, these event maps provide the associated event as the in-scope record.
11 Create a record named entity to store the topology data associated with the event (the in-scope record).
13 Access the NmosEntityId field within the event and load the value of this field into the nmosEntityId variable.
14 Use the GwEntityData() stitcher rule to look up the entity details in NCIM cache, based on the value of the nmosEntityId variable.
16-19 If the NmosEntityId field is NULL, this means that this is the first occurrence of this event. Consequently, the event has never been through the Event Gateway and has never been enriched. As an alternative to the NmosEntityId, determine the identity of the affected entity using the LocalNodeAlias field in the event record. Then use the GwIpLookup() stitcher rule to look up the entity details in NCIM cache, based on the value of the LocalNodeAlias variable.
21 Set the return value of the stitcher using the foundEntity variable. Initially set the value of this variable to 0; this assumes that no entity has been found.
22-25 If an entity has been found, call the StandardEventEnrichment.stch stitcher to perform event enrichment on the event using the entity data retrieved using the lookup. Set the return value of the stitcher to 1.
27 Pass the return value to the Event Gateway.
UserDefinedStitcher
{
    StitcherTrigger
    {
        // There is no trigger, as the eventMaps will automatically
        // call this with the event as the in-scope record
    }

    StitcherRules
    {
        Record entity;

        int nmosEntityId = eval(int, '&NmosEntityId');
        entity = GwEntityData( nmosEntityId );

        if ( entity == NULL )
        {
            entity = GwIpLookupUsing( "LocalNodeAlias" );
        }

        int foundEntity = 0;
        if ( entity <> NULL )
        {   ExecuteStitcher( "StandardEventEnrichment", entity );
            foundEntity = 1;
        }

        SetReturnValue( foundEntity );
    }
}