Quantcast
Channel: THWACK: All Content - Network Configuration Manager
Viewing all articles
Browse latest Browse all 6057

Working SQL trigger to update Orion NPM custom properties to Solarwinds NCM/Cirrus

$
0
0

After battling two 'custom property' locations, causing issues for my automated scripts setting banners, I've created a sql trigger to automatically sync the Cirrus database to any Orion custom property changes.

Some custom properties will not be used by your shop - Remove those, add the ones that you like.

The query will bind on Node Caption/System Name/IP Address, whatever is available. 

My next revision may just create nodes if they don't exist in Cirrus =)

Woo

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER trigger [dbo].[CustomPropertyUpdate] on [dbo].[Nodes] for update,insert as
-- We only want to check our custom property columns.

if NOT ( UPDATE(TBS_ID)
   OR UPDATE (CLLI)
   OR UPDATE (City)
   OR UPDATE (Country)
   OR UPDATE (Building)
   OR UPDATE (StreetAddress)
   OR UPDATE (Floor)
   OR UPDATE (Rack)
   OR UPDATE (PostalCode)
   OR UPDATE (LogicalDescription)
   OR UPDATE (Room)
   OR UPDATE (Province)
   OR UPDATE (Unit)
   OR UPDATE (SerialNumber)
   OR UPDATE (DeviceType)
   OR UPDATE (Critical)
  )
RETURN

 begin
 set NOCOUNT on
  --Stored procedure--
update Cirrus.dbo.Nodes
set Cirrus.dbo.Nodes.TBS_ID = NetPerfMon.dbo.Nodes.TBS_ID,
    Cirrus.dbo.Nodes.CLLI = NetPerfMon.dbo.Nodes.CLLI,
    Cirrus.dbo.Nodes.City = NetPerfMon.dbo.Nodes.City,
    Cirrus.dbo.Nodes.Country = NetPerfMon.dbo.Nodes.Country,
    Cirrus.dbo.Nodes.Building = NetPerfMon.dbo.Nodes.Building,
    Cirrus.dbo.Nodes.StreetAddress = NetPerfMon.dbo.Nodes.StreetAddress,
    Cirrus.dbo.Nodes.Floor = NetPerfMon.dbo.Nodes.Floor,
    Cirrus.dbo.Nodes.Rack = NetPerfMon.dbo.Nodes.Rack,
    Cirrus.dbo.Nodes.PostalCode = NetPerfMon.dbo.Nodes.PostalCode,
    Cirrus.dbo.Nodes.LogicalDescription = NetPerfMon.dbo.Nodes.LogicalDescription,
    Cirrus.dbo.Nodes.Room = NetPerfMon.dbo.Nodes.Room,
    Cirrus.dbo.Nodes.Province = NetPerfMon.dbo.Nodes.Province,
    Cirrus.dbo.Nodes.Unit = NetPerfMon.dbo.Nodes.Unit,
    Cirrus.dbo.Nodes.SerialNumber = NetPerfMon.dbo.Nodes.SerialNumber,
 Cirrus.dbo.Nodes.NodeGroup = NetPerfMon.dbo.Nodes.DeviceType,
    Cirrus.dbo.Nodes.Critical = NetPerfMon.dbo.Nodes.Critical
 
FROM NetPerfMon.dbo.Nodes
WHERE NetPerfMon.dbo.Nodes.Caption COLLATE DATABASE_DEFAULT = Cirrus.dbo.Nodes.SysName COLLATE DATABASE_DEFAULT
OR NetPerfMon.dbo.Nodes.Caption COLLATE DATABASE_DEFAULT = Cirrus.dbo.Nodes.NodeCaption COLLATE DATABASE_DEFAULT
OR NetPerfMon.dbo.Nodes.IP_Address COLLATE DATABASE_DEFAULT = Cirrus.dbo.Nodes.AgentIP COLLATE DATABASE_DEFAULT
end


Viewing all articles
Browse latest Browse all 6057

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>