WMI GetHotFixes randomly report 0 objects

Bug #1607273 reported by Sylvie on 2016-07-28
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OCS Inventory: Windows Agent
Undecided
Unassigned

Bug Description

Hello,

We have an issue with OCS Windows agent on Windows Vista and W7 devices (several hundreds) :
"Randomly" hotfixe are not reported in the SOFTWARES table.
In file SysInfo.log with debug level 2 activated we see :

WMI GetHotFixes: Trying to find Win32_QuickFixEngineering WMI objects...
 OK (0 objects)

Notice that the issue is not seen on Windows 8.1 and Windows 10 devices.

We first discovered the issue with devices having agent 2.1.1.1 but have the same symptoms with agent 2.1.1.3.

As recommended is the [changelog ](https://github.com/OCSInventory-NG/WindowsAgent/blob/master/CHANGELOG), we tried to install all the hotfixes of KB [2591403](http://support.microsoft.com/kb/2591403) but this didn't resolve the issue.
If we try to force an inventory on a device having reported no hotfixe, it may once report the hotfixes... or not :-)

As OCS is linked to a GLPI instance, the glpi_logs table is growing very fast.
For the impacted devices, we indeed find around 300 "software uninstallation" logs if OCS did not report the hotfixes and again around 300 "software installation" logs if this time OCS reported the hotfixes.

We discovered that if we try and run an inventory just after a windows logon, ocs agent mainly fails to report the hotfixes.

We then thought it could be a timeout of WMI and tried to run these simple commands just after Windows logon :
date
gwmi Win32_QuickFixEngineering | select Description, Hotfixid
date

The "gwmi" command answer in more than on minute on devices having this issue.

So we dived in the code and saw the following :

[Wmi.cpp](https://github.com/OCSInventory-NG/WindowsAgent/blob/master/SysInfo/Wmi.cpp) :

 AddLog( _T( "WMI GetHotFixes: Trying to find Win32_QuickFixEngineering WMI objects...\n"));
 try
 {
  CSoftware myObject;
  UINT uIndex = 0;
  CString csBuffer1, csBuffer2;

  if (m_dllWMI.BeginEnumClassObject( _T( "Win32_QuickFixEngineering")))
  {
   while (m_dllWMI.MoveNextEnumClassObject())
   {
[...]
    uIndex ++;
   }
   m_dllWMI.CloseEnumClassObject();
   AddLog( _T( "\tOK (%u objects)\n"), uIndex);
   return TRUE;
  }
  AddLog( _T( "\tFailed because no Win32_QuickFixEngineering object !\n"));
  return FALSE;
 }
 catch (CException *pEx)
 {
  pEx->Delete();
  AddLog( _T( "\tFailed because unknown exception !\n"));
  return FALSE;
 }

Conclusion : MoveNextEnumClassObject doesn't return an exception and mot probably report false, and uIndex keep it's initialization value of 0.
No timeout is found in this cpp.

Having a look at [OcsWmi.cpp](https://github.com/OCSInventory-NG/WindowsAgent/blob/master/OcsWmi/OcsWmi.cpp) :

BOOL COcsWmi::MoveNextEnumClassObject()
{
 ASSERT( m_pEnumClassObject);

 try
 {
  ULONG uReturned = 1;

  if (m_pClassObject)
   m_pClassObject->Release();
  m_pClassObject = NULL;

  // Enumerate through the resultset.
  m_hResult = m_pEnumClassObject->Next( 30000, // Timeout 30 s
             1, // Return just one storage device
             &m_pClassObject, // Pointer to storage device
             &uReturned); // Number obtained: one or zero
  if (SUCCEEDED( m_hResult) && (uReturned == 1))
   return TRUE;
  return FALSE;
 }
 catch (CException *pEx)
 {
  pEx->Delete();
  m_hResult = WBEM_E_FAILED;
  return FALSE;
 }
}

Here we find the 30 s timeout of MoveNextEnumClassObject.
If timeout reached, no exception is returned rather "FALSE".

So, maybe we are not correct but it seems to us that if wmi is too long (for example if inventory is run a short time after logon), MoveNextEnumClassObject return False and CWmi::GetHotFixes return 0 objects.

We don't have any tool or knowledge to recompile the agent with a bigger timeout value.
Could someone provide us with a test agent having a 2 minutes (120000) timeout in COcsWmi::MoveNextEnumClassObject in order to check if it resolve the issue ?

Thanks in advance.

Sylvie

Notice, this bug is also reported on github : https://github.com/OCSInventory-NG/WindowsAgent/issues/18

Philippe BEAUMONT (kapouik) wrote :

The project OCS Inventory NG is now on Github => https://github.com/OCSInventory-NG

Launchpad is not used anymore

Changed in ocsinventory-windows-agent:
status: New → Invalid
Sylvie (sylvie-cozic) wrote :

Hi Philippe,

I was unsure about launchpad usage but as stated in my first post I already have opened the bug on github : https://github.com/OCSInventory-NG/WindowsAgent/issues/18

Cheers,

Sylvie

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.