cconard96 / jamf

JAMF Plugin for GLPI
GNU General Public License v2.0
6 stars 5 forks source link

Import does not work #97

Closed rani2001 closed 6 months ago

rani2001 commented 2 years ago

Hello,

We have just installed the 2.2.0 plugin on our GLPI server. We are using Jamf Cloud version 10.35.

I configured the plugin with the Jamf Cloud URL (https://jss.domain.com:8443) of our JSS instance and created a JSS account with read-everywhere access.

When I try to import Jamf data into GLPI via the plugin, nothing happens. If I go to the JSS Account Link menu of a user in GLPI, I get the following two errors:

Warning: Trying to access array offset on value of type null in /var/www/glpi-dev/glpi/marketplace/jamf/inc/user_jssaccount.class.php on line 200

Warning: foreach() argument must be of type array|object, null given in /var/www/glpi-dev/glpi/marketplace/jamf/inc/user_jssaccount.class.php on line 202

Could you tell me if I forgot something please?

Thank you

cconard96 commented 2 years ago

On the import page, do any devices show if you click "Discover Now"?

rani2001 commented 2 years ago

HI @cconard96,

No, no devices are displayed.

Thank you

cconard96 commented 2 years ago

Sorry for the delayed response. I tested the plugin on my Jamf Pro instance hosted on Jamf Cloud and it still seems to work on the latest Jamf Pro version. In the past, similar issues were caused by missing root certificates for the curl utility.

See: https://github.com/cconard96/jamf/issues/68#issuecomment-762922092

Can you check and see if this is the same issue you are having?

rani2001 commented 2 years ago

Hello,

Thank you for your reply. I will look at this. I imagine that it must be done on the GLPI server, is that right? If so, we will see with our provider because we use GLPI Cloud. We use certificates provided by AWS on our JSS instance.

I'll keep you informed.

Thank you

cconard96 commented 2 years ago

Correct, it would need done on the GLPI server.

rani2001 commented 2 years ago

Hello,

Sorry for taking a bit of time but I'll let you know. Even following the procedure to add the root certificate, the problem remains :-(

cconard96 commented 2 years ago

Can you run this test curl command from the terminal on your server to test the connection (Replace the example Jamf instance URL with your own)?

curl --head https://jss.domain.com:8443/JSSResource

If there are no certificate issues, you should receive an HTTP response. Most likely, it will start with "HTTP/2 401" since you would not be logged in, but any HTTP response would indicate a connection success. If this does not work from the command line, there may be some other issue outside GLPI and the plugin and I am not able to help further with that troubleshooting.

adul3 commented 1 year ago

Hi ! I've got a similar problem on my GLPI 9.5.8 and jamf server, both on premise. On the Jamf plugin page, nothing appears. I've checked the ca-certs on my glpi's server and added the jamf cert, verified with curl (as mentioned above), it works. But nothing either on the plugin (automatic action does not work too). Is there a way to see if the plugin encounters an error (logs?). Thanks.

cconard96 commented 1 year ago

Plugin errors would be logged the same as ones from GLPI itself, so they would be in the log files in files/_log inside your GLPI folder.

Please specify your JAMF version and plugin version too.

adul3 commented 1 year ago

Ok for the logs... i'll try to catch any error while i try to import devices.

JAMF server version is 10.39.1 Jamf plugin version is 2.2.0

As i said the curl command works, i get the token ; curl --verbose --location --request POST 'https://my_jamf_server:8443/api/v1/auth/token' --header 'Authorization: Basic YWRlYnJ1eW5lOpOWxXJlRIM2cpLyI='

adul3 commented 1 year ago

While I try to discover devices, in the GLPI's php-errors.log I find this ;

[2022-09-21 14:42:31] glpiphplog.WARNING:   *** PHP Warning (2): count(): Parameter must be an array or an object that implements Countable in /var/www/my_vhost/htdocs/marketplace/jamf/inc/mobilesync.class.php at line 647
  Backtrace :
  marketplace/jamf/inc/cron.class.php:56             PluginJamfMobileSync::discover()
  inc/crontask.class.php:943                         PluginJamfCron::cronImportJamf()
  marketplace/jamf/ajax/cron.php:50                  CronTask::launch()

[2022-09-21 14:42:31] glpiphplog.WARNING:   *** PHP Warning (2): Invalid argument supplied for foreach() in /var/www/my_vhost/htdocs/marketplace/jamf/inc/mobilesync.class.php at line 672
  Backtrace :
  marketplace/jamf/inc/cron.class.php:56             PluginJamfMobileSync::discover()
  inc/crontask.class.php:943                         PluginJamfCron::cronImportJamf()
  marketplace/jamf/ajax/cron.php:50                  CronTask::launch()

[2022-09-21 14:42:31] glpiphplog.WARNING:   *** PHP Warning (2): count(): Parameter must be an array or an object that implements Countable in /var/www/my_vhost/htdocs/marketplace/jamf/inc/computersync.class.php at line 526
  Backtrace :
  marketplace/jamf/inc/cron.class.php:56             PluginJamfComputerSync::discover()
  inc/crontask.class.php:943                         PluginJamfCron::cronImportJamf()
  marketplace/jamf/ajax/cron.php:50                  CronTask::launch()

[2022-09-21 14:42:31] glpiphplog.WARNING:   *** PHP Warning (2): Invalid argument supplied for foreach() in /var/www/my_vhost/htdocs/marketplace/jamf/inc/computersync.class.php at line 551
  Backtrace :
  marketplace/jamf/inc/cron.class.php:56             PluginJamfComputerSync::discover()
  inc/crontask.class.php:943                         PluginJamfCron::cronImportJamf()
  marketplace/jamf/ajax/cron.php:50                  CronTask::launch()
adul3 commented 1 year ago

Ok, I resolved some part of my problems...

Part of the errors in the logs were caused by a typo in the login/password of the JSS User... :(

Now, the devices managed by my Jamf server are imported in the GLPI inventory, yes !

But...

cconard96 commented 1 year ago

The "importjamf" action would only import devices if the Auto-Import option is set to Yes in the plugin's config. It isn't recommended to enable that initially until at least a few are manually imported to avoid any potential large scale issues.

You can try clearing the pending imports using the button on the import page (even if none are showing, there could be some residual data in the database) and then clicking Discover again. This should then display any devices in Jamf that are not already imported. You can then select the ones you want to import and click Import.

If it still doesn't work after clearing the pending imports, based on the errors you provided, I am thinking there may be a bug that had been fixed in the 3.X.X version of the plugin for GLPI 10 but had not been backported.

cconard96 commented 1 year ago

Actually, can you try changing the $response = self::get($endpoint); line in inc/apiclassic.class.php in the getItems function to $response = static::get($endpoint);?

adul3 commented 1 year ago

Hi

I tried clearing the pending imports and then clic on the discover button, after a couple of minutes, nothing in the list of devices to import...

I modified the code in the inc/apiclassic.class.php file, but it's not better... :(

While the process was running on the Glpi server, I looked on the Jamf server logs and seen that my JSS account was making a huge number of connections, is it normal ? In the Jamf server, I have more than 2K devices.