Why the install count is 0 in cmdb_ci_spkg table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2022 02:17 AM
why I am getting install count is 0 and status is installed in software package table cmdb_ci_spkg.
I got this script in system UI > script include > SoftwareLicenseManager
/**
* Install counts / License count management of the following three tables
* - cmdb_ci_spkg
* - ast_license_base
* - ast_software_license
*
* Originally written by Pat Casey, but has been heavily modified by Aleck Lin aleck.lin@service-now.com
*/
var SoftwareLicenseManager = Class.create();
SoftwareLicenseManager.prototype = {
initialize : function() {
},
countAll : function() {
this.refreshSWInstallCount();
this.refreshASTInstallCount();
this.refreshSWLicenseCount();
this.refreshLicenseTableInstallCount();
},
/*
* Calculates the install count field of each software package (cmdb_ci_spkg).
*/
refreshSWInstallCount: function() {
new SoftwarePackage().calcInstallCount();
},
/*
* Calculates the install count field of AST licenses.
*/
refreshASTInstallCount: function() {
new ASTLicense().calcInstallCount();
},
/*
* Calculates the license count field of software packages
*/
refreshSWLicenseCount: function() {
new SoftwarePackage().calcLicenseCount();
},
/*
* Calculates the total install count and license count of the license bundle (ast_software_license)
* The scenario is that a license bundle may contain multiple licenses (such as adobe 3.0, adobe 4.0 and adobe 5.0)
*/
refreshLicenseTableInstallCount: function() {
var gr = new GlideRecord("ast_software_license");
gr.query();
while(gr.next())
this._refreshLicenseTableInstallCount(gr);
},
_refreshLicenseTableInstallCount: function(gr) {
var purchasedCnt = 0;
var installedCnt = 0;
var astGr = new GlideRecord('ast_license_base');
astGr.addQuery('parent', gr.sys_id);
astGr.query();
while(astGr.next()) {
purchasedCnt += astGr.license_count;
installedCnt += astGr.install_count;
}
gr.license_count = purchasedCnt;
gr.install_count = installedCnt;
gr.update();
},
}
- Labels:
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2022 06:57 AM
Since cmdb_ci_spkg tracks software packages it is possible that these are older versions that are no longer installed. The Service Graph Connector for SCCM has a Remove Software data source that will remove software that is no longer installed on computers. In the situations you have shown above I am guessing that a newer version is installed on those machines and the old version was removed from cmdb_software_instance (where cmdb_ci_spkg get the install count from). This would be expected behaviour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 02:17 AM
Service Graph Connector for Microsoft SCCM - 3.0.4 version is installed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 05:44 AM
This is working as expected. The cmdb_ci_spkg table is not expected to be cleared out if there are no longer any computers with the software package installed on it. This is useful information for auditing upgrades so I would not recommend deleting these records either.