OCSInventory-NG / OCSInventory-Server

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

Software table is missing in the Database #451

Closed kiwib1b closed 2 months ago

kiwib1b commented 5 months ago

General informations

Operating system : Red Hat Enterprise Linux release 9.3 (Plow)

Server informations

Perl version : perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-linux-thread-multi Mysql / Mariadb / Percona version : mariadb-server-10.5.22-1.el9_2.x86_64

OCS Inventory informations

Ocs server version : ocsinventory-server-2.12.1-1

Problem's description

I have a recently installed OCS server but agent dont works correctly. I am using both the official agent and fusion inventory.

With fusion inventory it gives me the following error:

Tue Jan 23 12:39:28 2024;2002695;318;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;session;missing
Tue Jan 23 12:39:28 2024;2002695;114;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;inventory;no_session
Tue Jan 23 12:39:28 2024;2002695;104;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;inventory;incoming
Tue Jan 23 12:39:28 2024;2002695;528;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;accountinfos;missing
Tue Jan 23 12:39:28 2024;2002695;1001;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;ipdiscover;checking if is enabled
Tue Jan 23 12:39:28 2024;2002695;1001;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;ipdiscover;checking if parameters are OK
Tue Jan 23 12:39:28 2024;2002695;1001;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;ipdiscover;processing
Tue Jan 23 12:39:28 2024;2002695;1001;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;ipdiscover;checking if ipdiscover group capabilities are enabled
Tue Jan 23 12:39:28 2024;2002695;1001;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;ipdiscover;checking user agent
Tue Jan 23 12:39:28 2024;2002695;301;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;duplicate;error to delete hardware_id from software
Tue Jan 23 12:39:28 2024;2002695;517;vsphere-gj-2024-01-23-12-38-39;10.228.7.12;FusionInventory-Injector;duplicate;replacing_error

It duplicates my entries because it is unable to delete duplicates since the software table is missing

With the OCS agent (OCS-NG_WINDOWS_AGENT_v2.10.1.0) on a Windows server it does not even register:

Tue Jan 23 15:36:44 2024;2003917;100;HV-PV-DU000044-2024-01-23-14-18-03;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;prolog;accepted
Tue Jan 23 15:36:44 2024;2003917;311;HV-PV-DU000044-2024-01-23-14-18-03;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;session;started
Tue Jan 23 15:37:06 2024;2003917;319;HV-PV-DU000044-2024-01-23-14-18-03;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;session;found
Tue Jan 23 15:37:06 2024;2003917;104;HV-PV-DU000044-2024-01-23-14-18-03;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;inventory;incoming
Tue Jan 23 15:37:06 2024;2003917;515;HV-PV-DU000044-2024-01-23-14-18-03;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;end;error
Tue Jan 23 15:38:31 2024;2003917;103;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;prolog;new_deviceid
Tue Jan 23 15:38:31 2024;2003917;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;checking if is enabled
Tue Jan 23 15:38:31 2024;2003917;103;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;snmp;error: agent must communicate using https to be able to get SNMP communities (ony affects OCS unix agent) !!

if I disable it from collecting software information it registers but it duplicates itself and does not delete like fusion inventory:

Tue Jan 23 15:39:06 2024;2003700;100;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;prolog;accepted
Tue Jan 23 15:39:06 2024;2003700;311;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;session;started
Tue Jan 23 15:39:19 2024;2003702;319;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;session;found
Tue Jan 23 15:39:19 2024;2003702;104;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;inventory;incoming
Tue Jan 23 15:39:19 2024;2003702;113;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;inventory;u:drives
Tue Jan 23 15:39:19 2024;2003702;113;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;inventory;u:bios
Tue Jan 23 15:39:19 2024;2003702;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;checking if is enabled
Tue Jan 23 15:39:19 2024;2003702;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;checking if parameters are OK
Tue Jan 23 15:39:19 2024;2003702;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;processing
Tue Jan 23 15:39:19 2024;2003702;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;checking if ipdiscover group capabilities are enabled
Tue Jan 23 15:39:19 2024;2003702;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;checking user agent
Tue Jan 23 15:39:19 2024;2003702;320;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;session;end
Tue Jan 23 15:39:19 2024;2003702;301;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;duplicate;error to delete hardware_id from software
Tue Jan 23 15:39:19 2024;2003702;517;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;duplicate;replacing_error
Tue Jan 23 15:39:19 2024;2003702;101;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;inventory;transmitted
Tue Jan 23 15:44:09 2024;2003917;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;checking if is enabled
Tue Jan 23 15:44:09 2024;2003917;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;checking if parameters are OK
Tue Jan 23 15:44:09 2024;2003917;1001;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;ipdiscover;checking if computer is able to be elected
Tue Jan 23 15:44:09 2024;2003917;103;HV-PV-DU000044-2024-01-23-15-38-31;10.228.13.208;OCS-NG_WINDOWS_AGENT_v2.10.1.0;snmp;error: agent must communicate using https to be able to get SNMP communities (ony affects OCS unix agent) !!

The problem with everything is that the software table is missing from the database, which generates duplicates and nothing is recorded if I activate it to collect the software information. I don't know why when I installed this table it wasn't created.

MariaDB [ocsinventory]> show tables;
+---------------------------+
| Tables_in_ocsinventory    |
+---------------------------+
| accesslog                 |
| accountinfo               |
| accountinfo_config        |
| archive                   |
| assets_categories         |
| auth_attempt              |
| batteries                 |
| bios                      |
| blacklist_macaddresses    |
| blacklist_serials         |
| blacklist_subnet          |
| config                    |
| config_ldap               |
| conntrack                 |
| controllers               |
| cpus                      |
| cve_search                |
| cve_search_computer       |
| cve_search_correspondance |
| cve_search_history        |
| deleted_equiv             |
| deploy                    |
| devices                   |
| devicetype                |
| dico_ignored              |
| dico_soft                 |
| download_affect_rules     |
| download_available        |
| download_enable           |
| download_history          |
| download_servers          |
| downloadwk_conf_values    |
| downloadwk_fields         |
| downloadwk_history        |
| downloadwk_pack           |
| downloadwk_statut_request |
| downloadwk_tab_values     |
| drives                    |
| engine_mutex              |
| engine_persistent         |
| extensions                |
| files                     |
| groups                    |
| groups_cache              |
| hardware                  |
| hardware_osname_cache     |
| history                   |
| inputs                    |
| itmgmt_comments           |
| javainfo                  |
| journallog                |
| languages                 |
| layouts                   |
| local_groups              |
| local_users               |
| locks                     |
| memories                  |
| modems                    |
| monitors                  |
| netmap                    |
| network_devices           |
| networks                  |
| notification              |
| notification_config       |
| operators                 |
| ports                     |
| printers                  |
| prolog_conntrack          |
| regconfig                 |
| registry                  |
| registry_name_cache       |
| registry_regvalue_cache   |
| reports_notifications     |
| repository                |
| saas                      |
| saas_exp                  |
| save_query                |
| schedule_wol              |
| sim                       |
| slots                     |
| snmp_accountinfo          |
| snmp_communities          |
| snmp_configs              |
| snmp_default              |
| snmp_labels               |
| snmp_mibs                 |
| snmp_types                |
| snmp_types_conditions     |
| software_categories       |
| software_categories_link  |
| software_category_exp     |
| software_link             |
| software_name             |
| software_publisher        |
| software_version          |
| softwares_name_cache      |
| sounds                    |
| ssl_store                 |
| storages                  |
| subnet                    |
| tags                      |
| temp_files                |
| usbdevices                |
| videos                    |
| virtualmachines           |
+---------------------------+
105 rows in set (0.000 sec)
kiwib1b commented 5 months ago

To solve the problem we have reviewed the creation of the Database and launched the creation of the missing software table with the following result:

MariaDB [ocsinventory]> CREATE TABLE `software` (
    ->   `ID` bigint NOT NULL AUTO_INCREMENT,
    ->   `HARDWARE_ID` int NOT NULL,
    ->   `NAME_ID` int NOT NULL,
    ->   `PUBLISHER_ID` int NOT NULL,
    ->   `VERSION_ID` int NOT NULL,
    ->   `FOLDER` text,
    ->   `COMMENTS` text,
    ->   `FILENAME` varchar(255) DEFAULT NULL,
    ->   `FILESIZE` int DEFAULT '0',
    ->   `SOURCE` int DEFAULT NULL,
    ->   `GUID` varchar(255) DEFAULT NULL,
    ->   `LANGUAGE` varchar(255) DEFAULT NULL,
    ->   `INSTALLDATE` datetime DEFAULT NULL,
    ->   `BITSWIDTH` int DEFAULT NULL,
    ->   `ARCHITECTURE` varchar(255) DEFAULT NULL,
    ->   PRIMARY KEY (`ID`),
    ->   KEY `HARDWARE_ID` (`HARDWARE_ID`),
    ->   KEY `NAME_ID` (`NAME_ID`),
    ->   KEY `PUBLISHER_ID` (`PUBLISHER_ID`),
    ->   KEY `VERSION_ID` (`VERSION_ID`)
    ->   KEY `HARDWARE_ID_2` (`HARDWARE_ID`, `NAME_ID`, `VERSION_ID`) USING BTREE
    -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'KEY `HARDWARE_ID_2` (`HARDWARE_ID`, `NAME_ID`, `VERSION_ID`) USING BTREE
) EN...' at line 22

It seems that the problem is here it fails to create the table during installation

We create the table following what is included in the installation script except for the creation of the KEYs, which we do one by one and it is done correctly

This solves all the errors we had in the agent registration

Lea9250 commented 2 months ago

Hi @kiwib1b,

This has been fixed with PR https://github.com/OCSInventory-NG/OCSInventory-ocsreports/pull/1590, which was merged into our master branch on the ocsreports repository. Thank you for reporting the issue.

Regards, Léa