Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The macOS agent fails to start after installation #461

Open
6lvckmania opened this issue Mar 25, 2024 · 5 comments
Open

The macOS agent fails to start after installation #461

6lvckmania opened this issue Mar 25, 2024 · 5 comments

Comments

@6lvckmania
Copy link

General Information

  • Operating System: macOS Sonoma 14.4
  • Perl Version: v5.30.3

OCS Inventory Information

  • Unix Agent Version: 2.10.0/2.10.1

Problem Description

The macOS agent fails to start after installation. Upon launching the client on a clean laptop, it immediately closes without contacting the server. Additionally, despite specifying in the settings for the ocsng.log file to be created, it remains absent. This issue manifests inconsistently across different machines.

Please advise on resolving this issue and identifying its root cause.

Inventory Log File (Optional)

No ocsng.log file has been created.

@cainatplugify
Copy link

after a phew weeks, I finally figured out the solution to this problem on Sonoma OSX 14.4+, and to be honest it's quite simple to fix.

you need to change the first line of the following file:
/Applications/OCSNG.app/Contents/Resources/ocsinventory-agent

the first line will have the content:
#!/usr/bin/perl

and you need to update it to:
#!/usr/bin/perl5.30

and that is it, fixed

@6lvckmania
Copy link
Author

6lvckmania commented Mar 27, 2024

@cainatplugify Okay, that helped partially (thank you a lot), but have you ever encountered the fact that /var/log/ocsng.log is not created?
I tried to create it manually, but I still get errors:

/Applications/OCSNG.app/Contents/Resources/ocsinventory-agent ; exit;
Use of uninitialized value $idate in localtime at /Applications/OCSNG.app/Contents/Resources/lib/Ocsinventory/Agent/Backend/OS/Generic/OS.pm line 30.
sysctl: unknown oid 'machdep.cpu.vendor'
2024-03-27 16:41:14.443 system_profiler[63830:557185] WARNING: AVCaptureDeviceTypeExternal is deprecated for Continuity Cameras. Please use AVCaptureDeviceTypeContinuityCamera and add NSCameraUseContinuityCameraDeviceType to your Info.plist.
Use of uninitialized value $main_edid in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 344.
Argument "" isn't numeric in addition (+) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 350.
Use of uninitialized value $s in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 275.
Use of uninitialized value $s in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 275.
Use of uninitialized value $s in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 275.
Argument "" isn't numeric in numeric gt (>) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 321.
Argument "" isn't numeric in numeric gt (>) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 321.
Use of uninitialized value $v in division (/) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 325.
Use of uninitialized value $v in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 325.
Use of uninitialized value $_[0] in multiplication (*) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 645.
Use of uninitialized value $_[0] in multiplication (*) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 645.
Use of uninitialized value $_[0] in multiplication (*) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 645.
Use of uninitialized value $_[0] in multiplication (*) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 645.

Saving session...completed.

[Process completed]

I also managed to fix all the errors on Intel with your fix, but the agent still doesn't communicate with the server.

@Lea9250
Copy link
Contributor

Lea9250 commented Apr 8, 2024

Hi @6lvckmania,

Can you confirm that this is happening on Sonoma 14.4+ systems only ? Do you have multiple perl versions installed ?
We'll be looking into this and testing on different versions to ensure the next release is fully compatible.

Regards,
Léa

@nlcth
Copy link

nlcth commented Apr 16, 2024

Hi @Lea9250,

I installed my Macbook Pro M3 at the end of January. I can confirm that during that time the agent worked. I do not remember when I updated to 14.4 or 14.4.1 exactly. But the agent logging stopped on 11 April. When an update is available I usually update within a few weeks. I'm pretty certain I ran 14.4 before upgrading to 14.4.1 in april. I believe it is likely the issue was introduced in 14.4.1. Unfortunately, I have no other macOS system at my disposal to test.

macOS Sonoma 14.4 - Released March 7, 2024
macOS Sonoma 14.4.1 - Released March 25, 2024

Agent version: https://github.com/OCSInventory-NG/UnixAgent/releases/download/v2.10.1-MAC/Ocsinventory_Unix_Agent-2.10.1-MAC.tar.gz

After executing below, there's no new entries in /var/log/ocsng.log. Last ones are from 11 April.

[Thu Apr 11 14:46:35 2024][info] [download] Download is off.
[Thu Apr 11 14:46:44 2024][info] [download] Beginning work. I am 26684.
[Thu Apr 11 14:46:44 2024][info] [download] Option turned off. Exiting.
% sudo /Applications/OCSNG.app/Contents/Resources/ocsinventory-agent
Password:
Perl INC : /Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/ /Applications/OCSNG.app/Contents/Resources/lib/ /Library/Perl/5.34/darwin-thread-multi-2level /Library/Perl/5.34 /Network/Library/Perl/5.34/darwin-thread-multi-2level /Network/Library/Perl/5.34 /Library/Perl/Updates/5.34.1 /System/Library/Perl/5.34/darwin-thread-multi-2level /System/Library/Perl/5.34 /System/Library/Perl/Extras/5.34/darwin-thread-multi-2level /System/Library/Perl/Extras/5.34 
Failed to load Ocsinventory::Agent, Can't load '/Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/auto/List/Util/Util.bundle' for module List::Util: dlopen(/Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/auto/List/Util/Util.bundle, 0x0001): tried: '/Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/auto/List/Util/Util.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/auto/List/Util/Util.bundle' (no such file), '/Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/auto/List/Util/Util.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/Applications/OCSNG.app/Contents/Resources/lib/darwin-thread-multi-2level/auto/List/Util/Util.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Applications/OCSNG.app/Contents/Resources/lib/darwin-thread-multi-2level/auto/List/Util/Util.bundle' (no such file), '/Applications/OCSNG.app/Contents/Resources/lib/darwin-thread-multi-2level/auto/List/Util/Util.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')) at /System/Library/Perl/5.34/XSLoader.pm line 96.
 at /Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/List/Util.pm line 24.
Compilation failed in require at /Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/Scalar/Util.pm line 23.
Compilation failed in require at /Applications/OCSNG.app/Contents/Resources/lib/XML/Simple.pm line 44.
BEGIN failed--compilation aborted at /Applications/OCSNG.app/Contents/Resources/lib/XML/Simple.pm line 44.
Compilation failed in require at /Applications/OCSNG.app/Contents/Resources/lib/Ocsinventory/Agent.pm line 11.
BEGIN failed--compilation aborted at /Applications/OCSNG.app/Contents/Resources/lib/Ocsinventory/Agent.pm line 11.
Compilation failed in require at (eval 1) line 1.
BEGIN failed--compilation aborted at (eval 1) line 1.

you can run the agent directly for its source directory with --devlib

Changing the perl in version to 5.30 does not fix the issue.
Below is the current version called when executing perl.

% perl -v

This is perl 5, version 34, subversion 1 (v5.34.1) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)

% whereis perl
perl: /usr/bin/perl

-----EDIT-----

I have resolved the issue with Util.bundle and have been able to start the agent by renaming EDID.pm. Both are required to be able to start the agent on Apple Silicon (M3).

It only works if you execute: /Applications/OCSNG.app/Contents/Resources/ocsinventory-agent. Running /Applications/OCSNG.app still does nothing after indicating to contact the inventory server and entering admin password.

Util.bundle mach-o Fix

Downloaded the source of List::Util: https://cpan.metacpan.org/authors/id/P/PE/PEVANS/Scalar-List-Utils-1.63.tar.gz
Compiled using to keep it compatible:

% env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' perl Makefile.PL
% make

% file Util.bundle 
Util.bundle: Mach-O universal binary with 3 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64] [arm64e:Mach-O 64-bit bundle arm64e]
Util.bundle (for architecture x86_64):	Mach-O 64-bit bundle x86_64
Util.bundle (for architecture arm64):	Mach-O 64-bit bundle arm64
Util.bundle (for architecture arm64e):	Mach-O 64-bit bundle arm64e

Copy Util.bundle from your compile location Scalar-List-Utils-1.63/blib/arch/auto/List/Util and place it in: /Applications/OCSNG.app/Contents/Resources/lib/darwin-thread-multi-2level/auto/List/Util

After launching I am getting the same errors as reported by @6lvckmania:

% sudo /Applications/OCSNG.app/Contents/Resources/ocsinventory-agent            
Password:
Perl INC : /Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/ /Applications/OCSNG.app/Contents/Resources/lib/ /Library/Perl/5.34/darwin-thread-multi-2level /Library/Perl/5.34 /Network/Library/Perl/5.34/darwin-thread-multi-2level /Network/Library/Perl/5.34 /Library/Perl/Updates/5.34.1 /System/Library/Perl/5.34/darwin-thread-multi-2level /System/Library/Perl/5.34 /System/Library/Perl/Extras/5.34/darwin-thread-multi-2level /System/Library/Perl/Extras/5.34 
Use of uninitialized value $idate in localtime at /Applications/OCSNG.app/Contents/Resources/lib/Ocsinventory/Agent/Backend/OS/Generic/OS.pm line 30.
sysctl: unknown oid 'machdep.cpu.vendor'
Use of uninitialized value $main_edid in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 344.
Argument "" isn't numeric in addition (+) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 350.
Use of uninitialized value $s in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 275.
Use of uninitialized value $s in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 275.
Use of uninitialized value $s in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 275.
Argument "" isn't numeric in numeric gt (>) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 321.
Argument "" isn't numeric in numeric gt (>) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 321.
Use of uninitialized value $v in division (/) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 325.
Use of uninitialized value $v in unpack at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 325.
Use of uninitialized value $_[0] in multiplication (*) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 645.
Use of uninitialized value $_[0] in multiplication (*) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 645.
Use of uninitialized value $_[0] in multiplication (*) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 645.
Use of uninitialized value $_[0] in multiplication (*) at /Applications/OCSNG.app/Contents/Resources/lib/Parse/EDID.pm line 645.

In regards to sysctl error 'machdep.cpu.vendor'. This does not appear to be available on Mac Silicon. Unsure of Intel Mac's. This does not prevent the agent from starting though.

% sysctl -a | grep machdep.cpu       
machdep.cpu.cores_per_package: 8
machdep.cpu.core_count: 8
machdep.cpu.logical_per_package: 8
machdep.cpu.thread_count: 8
machdep.cpu.brand_string: Apple M3

Workaround EDID.pm errors

I renamed EDID.pm to end in .bak in /Applications/OCSNG.app/Contents/Resources/lib/Parse/ and started the agent. On the inventory server I can see the agent made contact. This has also appeared to fix the "$idate in localtime" error in OS.pm.

Last inventory: 04/16/2024 22:27
Last contact: 04/16/2024 22:27

I don't know how important https://metacpan.org/pod/Parse::EDID is for OCS. Going by the description of the project. I could probably do without the information.

This module provides some function to parse Extended Display Identification Data binary data structures.
Extended Display Identification Data (EDID) is a metadata format for display devices to describe their capabilities to a video source. The data format is defined by a standard published by the Video Electronics Standards Association (VESA).

% sudo /Applications/OCSNG.app/Contents/Resources/ocsinventory-agent
Perl INC : /Applications/OCSNG.app/Contents/Resources/lib//darwin-thread-multi-2level/ /Applications/OCSNG.app/Contents/Resources/lib/ /Library/Perl/5.34/darwin-thread-multi-2level /Library/Perl/5.34 /Network/Library/Perl/5.34/darwin-thread-multi-2level /Network/Library/Perl/5.34 /Library/Perl/Updates/5.34.1 /System/Library/Perl/5.34/darwin-thread-multi-2level /System/Library/Perl/5.34 /System/Library/Perl/Extras/5.34/darwin-thread-multi-2level /System/Library/Perl/Extras/5.34 
Use of uninitialized value $idate in localtime at /Applications/OCSNG.app/Contents/Resources/lib/Ocsinventory/Agent/Backend/OS/Generic/OS.pm line 30.
sysctl: unknown oid 'machdep.cpu.vendor'

@rubberduck3000
Copy link

Hi!

Updating to #!/usr/bin/perl5.30 fixed it for me on Macbook Air A1392 Intel CPU/ Sonoma 14.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants