Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.12.3 available

The official documentation can be found on http://wiki.ocsinventory-ng.org. Read it before asking your question.

Client gets 500 http error with custom plugin [closed]

Hello,

I created a plugin that retrieves info about apt updates.

Plugin is installed on the server (the section has been added in GUI, the database has been created etc).

Client-side, I edited modules.conf and added the pm file..

Running ocsinventory-agent returns "error cannot establish communication : 500 Internal Server Error".

With the --debug flag, I see the relevant XML section added  to the final XML.

    <APT>
      <LAST_APT_UPDATE>1970-01-01 01:00:00</LAST_APT_UPDATE>
      <PENDING_SECURITY_UPDATES>0</PENDING_SECURITY_UPDATES>
      <PENDING_UPDATES>9</PENDING_UPDATES>
      <REBOOT_REQUIRED>0</REBOOT_REQUIRED>
    </APT>

The error is not present on a client that does not have the plugin.

I suppose there is an error while inserting data in the database (maybe an error in Map.pm ?), but I don't know how to get logs / increase verbosity.

# extract of install.php

function extension_install_apt()
{
    $commonObject = new ExtensionCommon();
    $commonObject -> sqlQuery(
        "CREATE TABLE IF NOT EXISTS `apt` (
                              `ID` INT(11) NOT NULL AUTO_INCREMENT,
                              `HARDWARE_ID` INT(11) NOT NULL,
                              `LAST_APT_UPDATE` VARCHAR(255) DEFAULT NULL,
                              `PENDING_UPDATES` INT(11) DEFAULT NULL,
                              `PENDING_SECURITY_UPDATES` INT(11) DEFAULT NULL,
                              `REBOOT_REQUIRED` BOOLEAN DEFAULT NULL,
                              PRIMARY KEY  (`ID`,`HARDWARE_ID`)
                              ) ENGINE=INNODB ;"
    );
}

# extract of Map.pm

$DATA_MAP{apt} = {
    mask => 0,
    multi => 1,
    auto => 1,
    delOnReplace => 1,
    sortBy => 'LAST_APT_UPDATE',
    writeDiff => 0,
    cache => 0,
    fields => {
        LAST_APT_UPDATE => {},
        PENDING_UPDATES => {},
        PENDING_SECURITY_UPDATES => {},
        REBOOT_REQUIRED => {}
    }
};

1;

I use a docker container by the way (version 2.12).

Thank you,

closed with the note: Problem solved
in OCS Inventory NG plugins by (270 points)
closed by

1 Answer

0 votes
 
Best answer
Ok, so I cleaned the plugin completely (cleaning the files in the docker container), then reinstalled it. The issue described in the original message was fixed.

It's probably the consequences of developing live in the extensions repository...
by (270 points)
 
Powered by Question2Answer
...