OCSInventory-NG / OCSInventory-Server

Communication server of OCS Inventory
http://www.ocsinventory-ng.org/
GNU General Public License v2.0
352 stars 140 forks source link

Some clients not reporting their software inventory #338

Closed TheFiZi closed 3 years ago

TheFiZi commented 3 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 informations

Operating system : CentOS Linux release 7.9.2009 (Core)

Server informations

Perl version : v5.16.3 Mysql / Mariadb / Percona version : 5.5.68-MariaDB

OCS Inventory informations

Ocs server version : 2.8.0

Problem's description

We have about a dozen systems (out of 1000+) that are not reporting their installed software to our OCS Inventory Server.

I found the following for one of the clients in the ssl_error_log

[Wed Jul 14 11:21:00.513838 2021] [php7:warn] [pid 4763] [client 10.21.39.148:56953] PHP Warning:  implode(): Invalid arguments passed in /usr/share/ocsinventory-reports/ocsreports/require/softwares/SoftwareCategory.php on line 253, referer: https://ocsinventory.mydomain.com/ocsreports/index.php?function=computer&head=1&systemid=304209&cat=software
[Wed Jul 14 11:21:00.513890 2021] [php7:warn] [pid 4763] [client 10.21.39.148:56953] PHP Warning:  Invalid argument supplied for foreach() in /usr/share/ocsinventory-reports/ocsreports/require/softwares/SoftwareCategory.php on line 233, referer: https://ocsinventory.mydomain.com/ocsreports/index.php?function=computer&head=1&systemid=304209&cat=software
[Wed Jul 14 11:21:00.664998 2021] [php7:warn] [pid 4763] [client 10.21.39.148:56953] PHP Warning:  implode(): Invalid arguments passed in /usr/share/ocsinventory-reports/ocsreports/require/softwares/SoftwareCategory.php on line 253, referer: https://ocsinventory.mydomain.com/ocsreports/index.php?function=computer&head=1&systemid=304209&cat=software
[Wed Jul 14 11:21:00.665015 2021] [php7:warn] [pid 4763] [client 10.21.39.148:56953] PHP Warning:  Invalid argument supplied for foreach() in /usr/share/ocsinventory-reports/ocsreports/require/softwares/SoftwareCategory.php on line 233, referer: https://ocsinventory.mydomain.com/ocsreports/index.php?function=computer&head=1&systemid=304209&cat=software
[Wed Jul 14 11:22:23.298465 2021] [php7:warn] [pid 7935] [client 10.21.39.148:56425] PHP Warning:  implode(): Invalid arguments passed in /usr/share/ocsinventory-reports/ocsreports/require/softwares/SoftwareCategory.php on line 253, referer: https://ocsinventory.mydomain.com/ocsreports/index.php?function=computer&head=1&systemid=304209
[Wed Jul 14 11:22:23.298525 2021] [php7:warn] [pid 7935] [client 10.21.39.148:56425] PHP Warning:  Invalid argument supplied for foreach() in /usr/share/ocsinventory-reports/ocsreports/require/softwares/SoftwareCategory.php on line 233, referer: https://ocsinventory.mydomain.com/ocsreports/index.php?function=computer&head=1&systemid=304209
[Wed Jul 14 11:22:23.475773 2021] [php7:warn] [pid 7935] [client 10.21.39.148:56425] PHP Warning:  implode(): Invalid arguments passed in /usr/share/ocsinventory-reports/ocsreports/require/softwares/SoftwareCategory.php on line 253, referer: https://ocsinventory.mydomain.com/ocsreports/index.php?function=computer&head=1&systemid=304209&cat=software
[Wed Jul 14 11:22:23.475791 2021] [php7:warn] [pid 7935] [client 10.21.39.148:56425] PHP Warning:  Invalid argument supplied for foreach() in /usr/share/ocsinventory-reports/ocsreports/require/softwares/SoftwareCategory.php on line 233, referer: https://ocsinventory.mydomain.com/ocsreports/index.php?function=computer&head=1&systemid=304209&cat=software

I found this similar issue: https://github.com/OCSInventory-NG/OCSInventory-Server/issues/275 but I do not understand what the bug submitters solution ended up being.

TheFiZi commented 3 years ago

After upgrading to 2.9.1 the issue persisted.

I finally found out I can enable MySQL error logging by editing /etc/httpd/conf.d/z-ocsinventory-server.conf and changing

PerlSetEnv OCS_OPT_DBI_PRINT_ERROR 0
to
PerlSetEnv OCS_OPT_DBI_PRINT_ERROR 1

After enabling that our logs flooded with:

DBD::mysql::st execute failed: Out of range value for column 'ID' at row 1 at /usr/local/share/perl5/Apache/Ocsinventory/Server/Inventory/Software.pm line 56.

According to this (https://ask.ocsinventory-ng.org/10330/error-last-inventory-and-http-status-code-%23-500) I need to do the following:

To correct the problem you have to change id column of table "softwares" from int to bigint. I have one question : do you delete machines (and their softwares associated) that are not more inventoried? Actually this feature is not implemented yet but we are working on it.

After changing ID from int to bigint the Out of range value for column 'ID' at row 1 went away along with all "POST /ocsinventory HTTP/1.1" 500 that were randomly appearing at the same time as the MySQL error.

Checking a few random systems that were not reporting software before, they appear to be reporting software now.

The 2.9.1 upgrade caused a different issue though related to displaying All Software in the WebUI. I will open a separate issue for that if I can't find a solution.