32 views

Issue


Software Counters can sometimes show incorrect values due to corruption in the SAM cache. 

Solution


There is a manual fix where you can go to an affected Software Counter, and on that page, there is a UI Action called 'Count licenses':
 
https://docs.servicenow.com/bundle/istanbul-it-service-management/page/product/asset-management/task/t_CreateASoftwareCounter.html. 
 
If you click that, a script include will be triggered which will force a recount of the licenses. 
 
If 'Count licenses' fails to fix the issue, there is also a second option which will completely rebuild the SAM cache for the chosen Software Counter (also see screenshot), if the suggestion above does not fix it, rebuild the SAM cache and do a recount to see if the numbers now match up:
 
https://docs.servicenow.com/bundle/istanbul-it-service-management/page/product/asset-management/task/t_ScheduleASoftwareCount.html
 
In instances with many hundreds or thousands of Software counters, it may preferable to run a script to trigger a rebuild of the SAM cache for each software counter. Run the below background script out of hours to minimize any performance impact. To run a background script, navigate to "Scripts - Background" into the left hand application search field, then paste in the below script, and choose run. 
 
 
-------------------------------
var gr = new GlideRecord('sam_sw_counter'); 
gr.query(); 
while (gr.next()) { 
gr.cached = false; 
gr.update(); 
 
var script = 'var SAMCounter = new SncSAMCounter();SAMCounter.doSingleCounter("'+gr.sys_id.toString()+'");'; 
var sched = new ScheduleOnce(); 
sched.script = script; 
sched.setTime(gs.nowNoTZ()); 
sched.setLabel('SAM:' + gr.name); 
sched.schedule(); 
}
-------------------------------
 
You can then go and check all Scheduled Jobs running beginning with the name "SAM:": https://<INSTANCE_NAME>.service-now.com/sys_trigger_list.do?sysparm_query=nameSTARTSWITHSAM%3A
 
At first you'll see many jobs created, but they will be processed quickly and will disappear from your view upon subsequent page refreshes.
 
You will also notice that each software counter will have a count in progress message at the top of the page. 
 
After this, all software counters should be updated. 

Article Information

Last Updated:2018-03-20 18:31:33
Published:2018-03-21