glpi-project / glpi-agent

GLPI Agent
GNU General Public License v2.0
212 stars 51 forks source link

Error adding winrm agent #160

Closed amrpb closed 1 year ago

amrpb commented 2 years ago

Documentation

Yes, I read it

Solution search

Yes, I read it

Professional support

No response

Is your help request related to a problem?

When adding new winrm remote agent it returns the error:

C:\Programas\glpi-agent>glpi-remote add winrm://user:password@192.168.** --target server0 Subroutine new redefined at C:/Programas/glpi-agent/perl/agent/GLPI/Agent/SOAP/WsMan/ResourceUri.pm line 19. Can't locate object method "new" via package "ResourceUri" (perhaps you forgot to load "ResourceUri"?) at C:/Programas/glpi-agent/perl/agent/GLPI/Agent/SOAP/WsMan/Node.pm line 69.

Expected behavior

no errors.

Actions you've considered

reinstall glpi-agent

Additional context

No response

g-bougard commented 2 years ago

Hi @amrpb what is your agent version ?

amrpb commented 2 years ago

Hi @amrpb what is your agent version ?

Hi, thank you. My agent version is the latest: 1.3 (downloaded yesterday)

g-bougard commented 2 years ago

Can you use --debug --debug options and report output ?

amrpb commented 2 years ago

Can you use --debug --debug options and report output ?

Of course:

C:\Programas\glpi-agent>glpi-remote add winrm://user:password@192.168.x.x --target server0 --debug Current vardir: C:/Programas/glpi-agent/var [debug] Logger backend Stderr initialized [debug] [http client] authentication required, submitting credentials [debug] [http client] authentication required, trying basic with gpli user (WSMAN) Subroutine new redefined at C:/Programas/glpi-agent/perl/agent/GLPI/Agent/SOAP/WsMan/ResourceUri.pm line 19. Can't locate object method "new" via package "ResourceUri" (perhaps you forgot to load "ResourceUri"?) at C:/Programas/glpi-agent/perl/agent/GLPI/Agent/SOAP/WsMan/Node.pm line 69.

g-bougard commented 2 years ago

Indeed, I see a problem around the "C:/Programas/glpi-agent/perl/agent/GLPI/Agent/SOAP/WsMan/ResourceUri.pm" filename. "ResourceUri" should be "ResourceURI". Do you have 2 files at that place with the same name but with difference in upper/lower characters ? Also did you use the default installation folder ? Anyway can you explain how it's possible you have a "ResourceUri.pm" file where a "ResourceURI.pm" one should have been installed ? The filename case may not be important for the windows system, but it is really for class loading in perl code.

amrpb commented 2 years ago

Hi, i only have one file. This is the default installation folder. The output of dir in int WsMan folder shows the filename correct: imagem Thank you

g-bougard commented 2 years ago

Hi @amrpb

I can't explain why the agent is trying to load the "ResourceUri" class in place of the "ResourceURI". "ResourceUri" string doesn't even exist in the source code. I tested again with an agent on windows and it tries to load "ResourceURI" class on my side.

Have you any explanation how this could be possible on your side ?

What is you OS version ? With me it works from linux or windows 10. Do you have any linux agent from which you can make a try ?

amrpb commented 2 years ago

Yes, i wil try from other agent and another Windows 10. Thank you

g-bougard commented 1 year ago

Closing without more issuer feedback.

SirDieter commented 1 year ago

@g-bougard I have the same issue running the glpi agent on Win 11. The same error shows up but the file name is correct: ResourceURI not ResourceUri.

Is there any code which is case sensitive and some code that case insensitive to handle files? I do not know perl, but maybe this error is related to this? https://stackoverflow.com/questions/7995113/using-perl-on-windows-how-can-i-ensure-i-get-the-path-in-the-correct-case-follo

g-bougard commented 1 year ago

Hi @SirDieter can you report which agent version you're using ? And can you share a "dir" on the following folder: C:\\Program Filess\GLPI-Agent\perl\agent\GLPI\Agent\SOAP\WsMan And also share the error you have ?

SirDieter commented 1 year ago

@g-bougard

I use GLPI Agent 1.4 on Win 11:

The error message:

Subroutine new redefined at C:/ITAM Test/GLPI-Agent/perl/agent/GLPI/Agent/SOAP/WsMan/ResourceUri.pm line 19.
Can't locate object method "new" via package "ResourceUri" (perhaps you forgot to load "ResourceUri"?) at C:/ITAM Test/GLPI-Agent/perl/agent/GLPI/Agent/SOAP/WsMan/Node.pm line 69.

Output of dir command


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        01.07.2022     09:31           2825 Action.pm
-a----        01.07.2022     09:31            622 Address.pm
-a----        01.07.2022     09:31            253 Arguments.pm
-a----        01.07.2022     09:31            627 Attribute.pm
-a----        01.07.2022     09:31           1091 Body.pm
-a----        01.07.2022     09:31            673 Code.pm
-a----        01.07.2022     09:31            249 Command.pm
-a----        01.07.2022     09:31            253 CommandId.pm
-a----        01.07.2022     09:31            257 CommandLine.pm
-a----        01.07.2022     09:31            348 CommandResponse.pm
-a----        01.07.2022     09:31            888 CommandState.pm
-a----        01.07.2022     09:31            533 DataLocale.pm
-a----        01.07.2022     09:31            647 Datetime.pm
-a----        01.07.2022     09:31            517 DesiredStream.pm
-a----        01.07.2022     09:31            259 EndOfSequence.pm
-a----        01.07.2022     09:31            616 Enumerate.pm
-a----        01.07.2022     09:31           2144 EnumerateResponse.pm
-a----        01.07.2022     09:31            350 EnumerationContext.pm
-a----        01.07.2022     09:31           1925 Envelope.pm
-a----        01.07.2022     09:31            251 ExitCode.pm
-a----        01.07.2022     09:31            866 Fault.pm
-a----        01.07.2022     09:31            554 Filter.pm
-a----        01.07.2022     09:31            495 Header.pm
-a----        01.07.2022     09:31            441 Identify.pm
-a----        01.07.2022     09:31            729 IdentifyResponse.pm
-a----        01.07.2022     09:31            394 InputStreams.pm
-a----        01.07.2022     09:31            243 Items.pm
-a----        01.07.2022     09:31            525 Locale.pm
-a----        01.07.2022     09:31            499 MaxElements.pm
-a----        01.07.2022     09:31            501 MaxEnvelopeSize.pm
-a----        01.07.2022     09:31           1015 MessageID.pm
-a----        01.07.2022     09:31           1166 Namespace.pm
-a----        01.07.2022     09:31           7086 Node.pm
-a----        01.07.2022     09:31           1296 OperationID.pm
-a----        01.07.2022     09:31            429 OperationTimeout.pm
-a----        01.07.2022     09:31            271 OptimizeEnumeration.pm
-a----        01.07.2022     09:31            493 Option.pm
-a----        01.07.2022     09:31            532 OptionSet.pm
-a----        01.07.2022     09:31            404 OutputStreams.pm
-a----        01.07.2022     09:31           1027 PartComponent.pm
-a----        01.07.2022     09:31            548 Pull.pm
-a----        01.07.2022     09:31            440 PullResponse.pm
-a----        01.07.2022     09:31            431 Reason.pm
-a----        01.07.2022     09:31            660 Receive.pm
-a----        01.07.2022     09:31            397 ReceiveResponse.pm
-a----        01.07.2022     09:31            391 ReferenceParameters.pm
-a----        01.07.2022     09:31            247 RelatesTo.pm
-a----        01.07.2022     09:31            381 ReplyTo.pm
-a----        01.07.2022     09:31            358 ResourceCreated.pm
-a----        01.07.2022     09:31            491 ResourceURI.pm
-a----        01.07.2022     09:31            561 Selector.pm
-a----        01.07.2022     09:31            378 SelectorSet.pm
-a----        01.07.2022     09:31            586 SequenceId.pm
-a----        01.07.2022     09:31            923 SessionId.pm
-a----        01.07.2022     09:31           1324 Shell.pm
-a----        01.07.2022     09:31            247 Signal.pm
-a----        01.07.2022     09:31           1555 Stream.pm
-a----        01.07.2022     09:31            241 Text.pm
-a----        01.07.2022     09:31            456 To.pm
-a----        01.07.2022     09:31            239 Value.pm
g-bougard commented 1 year ago

Hi @SirDieter indeed, I can reproduce on my win10 test system. I still don't understand how it triggers, but I'll make some investigations.

g-bougard commented 1 year ago

I finally understood the issue was due to an answer from remote when requesting a Shell object. It was setting ResourceUri where I expected ResourceURI. This was a problem on windows as the FS is not case sensitive, so it tried to load ResourceURI.pm for ResourceUri class. On linux, ResourceUri class was automatically regenerated from a basic template, so that was not an issue on other OS than windows.

The fix will be available in the next nightly or from the development version you will be able to download as Windows-Build artifact from: https://github.com/glpi-project/glpi-agent/actions/runs/2948413207