[Fusioninventory-devel] collect.php protocol

Guillaume Bougard gbougard at teclib.com
Mon Dec 7 11:37:45 UTC 2015


Hello Côme,

as I remember, only the status line is reported. This means the string reported with the HTTP error code.

As fas I know, 5xx codes are more used to report an HTTP Server error and 4xx are for app errors. So I would better advize you to report 4xx error if the report is related to FusionDirectory and it can't handle a request made by the agent.

In case of error, it not necessary to return any content.

In fact, the agent always first contact the server with a PROLOG request. This is a way for it to check it can communicate with the server part and specific task the server needs the agent to do. The returned PROLOG_FREQ value is the number of hours between contact tries. After the prolog, agent knows its report will be accepted by the server so it really starts its tasks only after. As the agent can also do other tasks than just inventory (network inventory, snmp discovery, deployement, etc...), any task it does will generate a HTTP request, so you may receive not interesting stuffs if the agent is setup to do them by default. For that sent stuffs, you may just drop them and not generate error.

Regards,

Guillaume Bougard 
Ingénieur R&D 


gbougard at teclib.com 

TECLIB' Montpellier 
3 rue Doria, 
34000 Montpellier, France 

Facebook | Twitter | www.teclib.com 

----- Mail original -----
De: "Côme Chilliet" <come at opensides.be>
À: "FusionInventory Developer discussion" <fusioninventory-devel at lists.alioth.debian.org>
Envoyé: Jeudi 3 Décembre 2015 04:35:37
Objet: Re: [Fusioninventory-devel] collect.php protocol

Le mercredi 2 décembre 2015, 14:18:59 Guillaume Bougard a écrit :
> Hello Côme,
> 
> as I understand, you want to report the error in fusioninventory-agent if the XML inventory it pushed failed in some way to be integrated in FusionDirectory.
> 
> In that way, just think FIA is just an HTTP client. So and as it only tries to submit an XML, the only thing it checks for error is the HTTP Status code of the server. And then it only logs the returned status line. See HTTP::Response doc, what is log is just the return of $r->status_line() (see request method in FIA code at lib/FusionInventory/Agent/HTTP/Client.pm).
> 
> In conclusion, try just to return an HTTP error with a short description. See also : http://php.net/manual/fr/function.http-response-code.php
> 
> Hope this help,

Thanks, it does help, I’ll try triggering a 500 error in case of error.
I don’t remember where the code for our collect.php is originally from but there is something like this in it:
> $reply = "";
> if (preg_match('/QUERY>PROLOG<\/QUERY/', $xml)) {
>     $reply= '<?xml version="1.0" encoding="UTF-8"?>
>         <REPLY>
>            <RESPONSE>SEND</RESPONSE>
>            <PROLOG_FREQ>8</PROLOG_FREQ>
>         </REPLY>';
> } else {
>     $reply = '<?xml version="1.0" encoding="UTF-8"?>
>        <REPLY>
>        </REPLY>';

And at the end $reply is printed.
So it seems there is an XML reply which FI agent is reading no? Is there anything useful we can put in it?
What it the PROLOG part for?

Côme

_______________________________________________
Fusioninventory-devel mailing list
Fusioninventory-devel at lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/fusioninventory-devel



More information about the Fusioninventory-devel mailing list