OCSInventory-NG / WindowsAgent

OCS Inventory NG Agent for Windows
http://www.ocsinventory-ng.org/
Other
154 stars 80 forks source link

Agents hanging during inventory #237

Open StCyr opened 2 years ago

StCyr commented 2 years ago

It's hard to solve a problem when important details are missing, that why we added this template, to help you and us.

General information

Operating system : Windows Server 2016 Standard and Windows Server 2019 Standard

OCS Inventory information

Windows agent version : 2.8.0.0 and 2.9.0.0

Problem's description

Agent hangs on some machines.

Last lines in logs are:

==============================================================================
Starting OCS Inventory Agent on Tuesday, February 08, 2022 12:00:13.
AGENT => Running OCS Inventory Agent Version 2.9.0.0
AGENT => Using OCS Inventory FrameWork Version 2.9.0.0
AGENT => Loading plug-in(s)
    DLL PLUGIN => Searching for Plug-in DLL(s) in folder <C:\Program Files\OCS Inventory Agent\plugins>
    DLL PLUGIN => 0 DLL Plug-in(s) successfully loaded on 0 DLL(s) found
AGENT => Using network connection with Communication Server
    COM PROVIDER => Loading Communication Provider <C:\Program Files\OCS Inventory Agent\ComHTTP.dll>
AGENT => Using Communication Provider <OCS Inventory cURL Communication Provider> Version <2.9.0.0>
AGENT => Sending Prolog
    DID_CHECK => *********redacted*************
    COM SERVER => Initializing cURL library for sendRequest
    COM SERVER => Using cURL with server authentication
    COM SERVER => Disabling cURL proxy support
    COM SERVER => Enabling cURL SSL server validation support using CA Bundle <cacert.pem>
    COM SERVER => Sending HTTP Post request to URL <*****redacted*******>
    COM SERVER => HTTP Post response received <HTTP Status Code #200>
    COM SERVER => Cleaning cURL library
AGENT => Prolog successfully sent
    AGENT => Prolog Frequency set to 10 hour(s)
    AGENT => Inventory on startup option set to  
AGENT => Inventory change forced by /NOTIFY option
AGENT => Launching hardware and software checks
    INVENTORY => Logged on user ID is <Administrator>
    INVENTORY => Operating System is <Microsoft Windows Server 2016 Standard 10.0.14393 >, description <>
    INVENTORY => Operating System uses 64 bits memory address width
    INVENTORY => Computer domain or workgroup is <***redacted***>

Looking at the code, this must be happening at:


// Get NT Domain or Workgroup
    if (!m_pSysInfo->getDomainOrWorkgroup( cs1))
        m_pLogger->log( LOG_PRIORITY_WARNING, _T( "INVENTORY => Failed to retrieve computer domain or workgroup"));
    else
        m_pLogger->log( LOG_PRIORITY_DEBUG, _T( "INVENTORY => Computer domain or workgroup is <%s>"), 
                    cs1);
here, >>>   m_Device.SetDomainOrWorkgroup( cs1);
    // Get NT user Domain
here, >>>   if (!getAgentConfig()->isDefaultUserDomainRequired())
    {
here, >>>       if (!m_pSysInfo->getUserDomain(cs1, getAgentConfig()->getWmiFlagMode()))
            m_pLogger->log(LOG_PRIORITY_WARNING, _T("INVENTORY => Failed to retrieve user domain"));
        else
            m_pLogger->log(LOG_PRIORITY_DEBUG, _T("INVENTORY => User domain is <%s>"), cs1);
    }
    else
    {
or here >>>     cs1 = getAgentConfig()->getDefaultUserDomain();
        m_pLogger->log(LOG_PRIORITY_DEBUG, _T("INVENTORY => Default User domain is set to <%s>"), cs1);
    }
    m_Device.SetUserDomain( cs1);```
StCyr commented 2 years ago

At first glance, the getAgentConfig directives should not make the agent hang and the m_Device.SetDomainOrWorkgroup is just about storing a string in a variable, so I would say that something is going wrong at line

if (!m_pSysInfo->getUserDomain(cs1, getAgentConfig()->getWmiFlagMode()))

but what?

NB: The only 3 agents exhibiting this issue all have similar purposes and have been installed by the same person, so there's probably a link to do here....