Today I was working with a customer on the quality of their inventory data in the CMDB. They have some questions about the data refresh, related to the (still on-going?) datahash problem [1].
I'm honestly thinking that we should take some serious resolution to resolve the datahash problem outside of the product.
Now this is not what was interesting today. Rather I was saying to the customer that it would be great to have a dashboard where we could review the data quality quickly. After voicing this I went directly into SQL and crafted the query you can find below.
The result-set contains the following columns:
- Data Class Guid
- Data Class Name
- Computer Count
- Modified in the last 4 weeks
- Not modified in the last 4 week
- % up-to-date
The query tries to provide a clean result set (not returning internal data that doesn't relate to computer inventory). To achieve this result we only return data classes from the NS, Patch, Inventory and Software Management Solutions that have a dataclass table name starting with 'Inv'.
Now I need to work out how to get the '% up-to-date' results to show in a visual manner, so you could see at a glance which inventory classes are broadly out of synch and need urgent attention.
select i1.InventoryClassGuid, dc.Name, i1.Computers as 'Resource #', i2.Computers 'Modified in last 4 weeks', i1.Computers - i2.Computers as 'Not modified in last 4 weeks', cast(cast(i2.Comp uters as float)/ cast(i1.Computers as float) * 100 as money) as '% up-to-date' from ( select InventoryClassGuid, COUNT(distinct(ResourceGuid)) as 'Computers' from ResourceUpdateSummary rus group by rus.InventoryClassGuid ) i1 join ( select InventoryClassGuid, COUNT(distinct(ResourceGuid)) as 'Computers' from ResourceUpdateSummary rus where rus.ModifiedDate < GETDATE () - 28 group by InventoryClassGuid ) i2 on i1.InventoryClassGuid = i2.InventoryClassGuid join DataClass dc on i1.InventoryClassGuid = dc.guid left join Item i on dc.Guid = i.guid left join vProduct p on i.ProductGuid = p.Guid where dc.DataTableName like 'Inv%' and p.Name in ('Inventory Solution', 'Altiris Patch Management Solution for Windows', 'Notification Server', 'Software Management') order by dc.name