Reference Material | Integrating External Data
The Specops Inventory database and reporting solution is designed with external connections in mind. External data can be imported to the Specops Inventory data and made available to the reporting engine. This information can then be combined with all the other inventory information when creating new or editing the default reports.
The only requirement for the external data is that it can be connected to computer- or user names. Alternatively the Active Directory computer- or user GUIDs can be used to make the connection. Importing external data also requires some SQL server and SQL knowledge and possibly scripting experience.
Note: Many properties from the Active Directory computer and user objects are by default inventoried by Specops Inventory. If you can get your data into one of those fields you are done.
The most central table in the Specops Inventory database is called soPrinicpal. This table contains all the computers and users that have been inventoried. The important columns for this document are:
|ID||The internal Specops Inventory key for the computer or user. This is a generated value and all connections to computers or users in the database use this key.|
|Name||The name of the computer or user. This is the NETBios name of the object, the domain name is not included.|
|Domain||The name of the computer’s or user’s domain. This is the NETBios name of the domain. Such as “Specopssoft” or “OurEnterprise.”|
|Guid||The unique identifer for the object in Active Directory.|
|Type||This is a flag indicating what type of object the row holds. 0 means its a computer, 1 means its a user.|
The following table depicts some sample data from the soPrincipal table:
All information used for reporting in the database is connected to the soPrincipal table by the Id column. For example the computer hardware table looks something like this:
|3||HP||HP whatever ABC|
For each row in this table the PrincipalId field connects the row to the corresponding computer in the soPrincipal table.
Getting the external data into the database
In order to get the external data into the Specops Inventory database a new table must be created in the database and then populated with the external data. For example we could create the following table:
|Column name||Data type|
Note: There must be a column called PrincipalId in the table. This is the column that will be used to match the rows with the corresponding computer when generating the reports.
It is also recommended to create a foreign key constraint between the PrincipalId column in the new table and the Id column in soPrincipal.
When the table has been created we could then manually fill it with purchase dates, and the corresponding computer in the soPrincipal table. Lets assume we create a table called soInvComputerPurchaseDate.
We could now add this information to our existing reports. However in the real world this manual lookup is usually not feasible nor recommended. How do we automate this? Well that all depends on what kind of data you are importing and in what format it is available. The following must be done:
Get the data into a table in a SQL server database, this can be in a separate database, doesn’t have to be the Specops Inventory database. This table will serve as a staging table from where the data is moved into the actual Specops Inventory table (the one we created above.) To get the data into the staging table you can set up a data source and use the SQL server data import engine (the datasource could be an Oracle database an Excel document or any other type of ODBC source). You can then set this up as a scheduled job to be performed regularly, if the source data is likely to change. Lets assume the staging table is called ComputerPurchaseDateStaging and looks like this:
In this table we have the computer names which can now be matched to the computer names in the soPrincipal table. This is the crucial part, we must have computer names that can be matched with the computers in the soPrincipal table. Now, to get the data from this staging table we would have to execute the following SQL statement:
INSERT INTO soInvComputerPurchaseDate SELECT p.Id, s.TimeOfPurchase FROM soPrincipal p, ComputerPurchaseDateStaging s WHERE s.ComputerName = p.Name AND p.Type = 0
This will insert data into the soInvComputerPurchase table just like we did in the manual example above. The execution of this SQL statement should also be scheduled to run after the import job runs.
Adding the new table as a report source
Now when we have the data in the Specops Inventory database there is one final step before the data becomes available as a reporting source. There is a table in the database that contains the names of all the tables (or views) that are allowed to use in reports. The table is called soRepReportView. Insert a row like the following into this table:
|Id||Name||Join Type||Display Name|
|(generated)||soInvComputerPurchaseDate||Principal||Computer purchase date|
Note: You should not enter a number in the Id field, this value will be generated automatically.
You can now edit the existing reports to add the new information or create new reports combining the new information with any other inventory data.