OCSInventory-NG / OCSInventory-Server

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

cron_all_software.php not working #413

Closed oetti77 closed 1 year ago

oetti77 commented 1 year ago

General informations

Operating system : Debian 11.5

Server informations

Perl version : v5.32.1 PHP version: 7.4.33 Mysql / Mariadb / Percona version : 10.5.15-MariaDB-0+deb11u1 Debian 11

OCS Inventory informations

Ocs server version : 2.11.1

Problem's description

Running "cron_all_software.php" via cron or manually results in an error. All software left empty. That's what i get for all software packages

` ... [Fri Dec 30 17:14:45.053592 2022] [php7:notice] [pid 93571] [client 192.168.250.94:60800] An error occure when attempt to insert software with identifier : Update for Microsoft Visio 2016 (KB4504718) 32-Bit Edition;Microsoft;Unavailable [Fri Dec 30 17:14:45.053624 2022] [php7:notice] [pid 93571] [client 192.168.250.94:60800] An error occure when attempt to insert software with identifier : Update for Microsoft Office 2016 (KB5002248) 32-Bit Edition;Microsoft;Unavailable [Fri Dec 30 17:14:45.053672 2022] [php7:notice] [pid 93571] [client 192.168.250.94:60800] An error occure when attempt to insert software with identifier : Update KB5013887;Microsoft Corporation;Unavailable ...

`

thenextuser commented 1 year ago

+1 same here

Nearly identical system specifications:

General informations Operating system : Ubuntu 22.04.1 LTS

Server informations Perl version : v5.34.0 PHP version: 7.4.33 Mysql / Mariadb / Percona version : 10.6.11-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04

OCS Inventory informations Ocs server version : 2.11.1

thenextuser commented 1 year ago

Hello again,

I have been able to fix my problem:

In my database the table 'software_link' was missing. Unfortunately I don't know why, since it is a fresh installation. There also seem to be some other tables missing compared to an old OCS instance (These don't seem to be in the SQL file ocsbase.sql at all, so of course they can't be created).

But this is a different topic, I'll open a separate issue for this.

So I could solve the problem by creating the missing table 'software_link' manually. As a template I took the table from an old instance. Whether this is correct, I can not promise, but at least the call of the PHP script and the software count or the software listing works again as usual.

If you need help creating the table, here are the steps I took:

1) Connect via CLI to the OCS (database) server. 2) Stop Apache service with: sudo service apache2 stop 3) Start MariaDB CLI with: sudo mysql 4) Create the table there with the following commands (assumes your database is named 'ocs'. If not, then adjust the first line of the commands):

CREATE TABLE ocs.software_link ( ID int(11) NOT NULL AUTO_INCREMENT, NAME_ID int(11) NOT NULL, PUBLISHER_ID int(11) NOT NULL, VERSION_ID int(11) NOT NULL, CATEGORY_ID int(11) DEFAULT NULL, IDENTIFIER varchar(255) NOT NULL, COUNT int(11) DEFAULT NULL, PRIMARY KEY (ID), KEY NAME_ID (NAME_ID), KEY PUBLISHER_ID (PUBLISHER_ID), KEY VERSION_ID (VERSION_ID) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

(Attention: Put the names of the tables and columns in quotes, somehow this conflicts with the Github formatting)

5) Exit the MaraiaDB CLI with: quit 6) Start Apache service again with: sudo service apache2 start 7) Run PHP script again (in directory '/usr/share/ocsinventory-reports/ocsreports/crontab') with: php cron_all_software.php 8) If the PHP script is successful, set it as a cronjob as planned.

Good luck with it!

Kind regards.

oetti77 commented 1 year ago

Yeah, it's working now. Thanks for that. I've copied and pasted the SQL-Statements from here https://github.com/OCSInventory-NG/OCSInventory-ocsreports/blob/master/files/ocsbase_new.sql.

Next steps will be to compare the installed database structure with the link posted above.

Regards oetti

thenextuser commented 1 year ago

I miss the 'software_link' table completely in the last release 2.11.1 (from October 2022) within the 'ocsbase.sql' or 'ocsbase_new.sql'. But since this is present in the current branch of the files (last change January 2023) I guess the bug was already known and should be fixed in the next release. At least that's what it sounds like to me. Therefore, the issues can be closed from my side and I will observe the behaviour of the corresponding functions and tables in the next release.

Many greetings.

charleneauger commented 1 year ago

Hi,

Since this issue is resolved, I'll close it now.

Regards, Charlene