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

[BUG] Error 500 on import #1595

Open
Parnoud opened this issue Mar 4, 2024 · 10 comments
Open

[BUG] Error 500 on import #1595

Parnoud opened this issue Mar 4, 2024 · 10 comments

Comments

@Parnoud
Copy link

Parnoud commented Mar 4, 2024

OCS Inventory version
Version : 2.12.0
Client : 2.10.1.0

Describe the bug
I have 9000 host who update my OCS, some time few clients who get error in OCSinventory.log :
ERROR *** AGENT => Failed to send Inventory <HTTP Status Code #500>

Serveur side i get :
Activity.log
Mon Mar 4 15:44:22 2024;12420;311;XX-2023-10-06-14-34-54;XX;OCS-NG_WINDOWS_AGENT_v2.10.1.0;session;started
Mon Mar 4 15:44:59 2024;12413;319;XX-2023-10-06-14-34-54;XX;OCS-NG_WINDOWS_AGENT_v2.10.1.0;session;found
Mon Mar 4 15:44:59 2024;12413;104;XX-2023-10-06-14-34-54;XX;OCS-NG_WINDOWS_AGENT_v2.10.1.0;inventory;incoming
Mon Mar 4 15:44:59 2024;12413;515;XX-2023-10-06-14-34-54;XX;OCS-NG_WINDOWS_AGENT_v2.10.1.0;end;error

Nothing in error.log

i try to set OCS_OPT_DBI_PRINT_ERROR to 1 but i get nothing ?

I try to do a local export from a client (XML + OCS file) with ocsinventory-injector.pl i get ERROR: 500 Internal Server Error

i try with 0 plugin client side, same issue.

Where i can find more log for debug this issue ? what does ocsinventory-log.pl do ? does is print more log than the others ?

i try to look if /usr/local/share/perl/5.32.1/Apache/Ocsinventory.pm is the good one :
$Apache::Ocsinventory::VERSION = '2.12.0';
$Apache::Ocsinventory::MAJOR_VERSION = '2';
$Apache::Ocsinventory::MINOR_VERSION = '12';
$Apache::Ocsinventory::BUILD_VERSION = '850';
$XML::Simple::PREFERRED_PARSER = 'XML::Parser';

Expected behavior
No error for inventory import

@gillesdubois
Copy link
Member

Hi,

Just to be sure, did you restart the apache service after changing the setting ?

Regards,
Gilles DUBOIS.

@Parnoud
Copy link
Author

Parnoud commented Mar 5, 2024

Yes, I already try this.

@daniellybto
Copy link

Same problem here.

I tried restarting apache2 - it didn't solve the problem;
I tried restarting my server where OCS Inventory is installed - it didn't help;
I also tried restarting the machine where the OCS Agent is installed - it didn't help;

@gillesdubois
Copy link
Member

Hi,

Without logs from OCS_OPT_DBI_PRINT_ERROR won't be able to help much more.
If this setting doesn't work could you try to enable general query logs from mysql ? That way you'll see all queries that goes trought the SQL server before returning the 500.

500 errors on the agent are most of the time related to a datamodel mismatch.

Regards,
Gilles DUBOIS.

@daniellybto
Copy link

Hello everyone, sorry for the delay and thanks for the DBI_PRINT_ERROR tip.

After that I realized that I had left the wrong server configuration, which was causing the error. So, I made the correction and everything worked correctly, at least for me.

Thank you ^^

@asferreira
Copy link

I'm facing the same problem here on a fresh installation using the same server and client versions as reported by @Parnoud.
No errors on error.log and OCS_OPT_DBI_PRINT_ERROR didn´t change anything.

Checking the mysql's log files I come to conclusion that the 500 errors are indeed caused by model mismatch. What I can't understand is why it is happening and why OCS_OPT_DBI_PRINT_ERROR does not report any error.

Regards,

Anderson

@Parnoud
Copy link
Author

Parnoud commented Jul 25, 2024

I try to add log on MariaDB but nothing i showing up. i'm thinking one or more value on my inventory is more longer than 255 Char maybe and the engine don't support that ?

@Parnoud
Copy link
Author

Parnoud commented Aug 2, 2024

After update 2.12.2 issue is still here. i'm gonna try to add log on update.pm and inventory.pm to find why.

@Parnoud
Copy link
Author

Parnoud commented Aug 2, 2024

Some Softwares Names in XML are longer than 255 char :

<SOFTWARES>
<PUBLISHER>Brother</PUBLISHER>
<NAME>Package de pilotes Windows - Brother HL-2290, HL-2295D, HL-L2590DN, HL-L2595DW, HL-B2000D, HL-B2050DN, HL-B2080DW, HL-L2310D, HL-L2325DW, HL-L2330D, HL-L2335D, HL-L2350DW, HL-L2357DW, HL-L2370DN, HL-L2370DW, HL-L2375DW, HL-L2379DW, HL-L2385DW (07/15/2021 1.2.0.0)</NAME>
<VERSION>07/15/2021 1.2.0.0</VERSION>
<FOLDER/>
<COMMENTS/>
<FILENAME/>
<FILESIZE>0</FILESIZE>
<GUID>4E44BF489DF1B8DF03BB035E7A1FE6891FF76C7B</GUID>
<LANGUAGE/>
<INSTALLDATE>0000//0/0/00</INSTALLDATE>
<BITSWIDTH>64</BITSWIDTH>
<SOURCE>1</SOURCE>
</SOFTWARES>

i look in database, Table sofware_name is a Varchar(255) :

MariaDB [ocsweb]> describe software_name;
+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| ID    | int(11)      | NO   | PRI | NULL    | auto_increment |
| NAME  | varchar(255) | NO   | UNI | NULL    |                |
+-------+--------------+------+-----+---------+----------------+

Can we pass Type to "Text" or truncate to max 255 ?

@Parnoud
Copy link
Author

Parnoud commented Aug 2, 2024

That was the issue, we create a "dirty fix" :
https://github.com/OCSInventory-NG/OCSInventory-Server/blob/master/Apache/Ocsinventory/Server/Inventory/Software.pm
ligne 345

we whange
my $name = $software->{NAME};
To
my $name = substr( $software->{NAME}, 0, 255 );

Can you provide use a real fix ? like i motion before ?

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

No branches or pull requests

7 participants