fusioninventory / fusioninventory-for-glpi

FusionInventory plugin for GLPI
http://www.FusionInventory.org/
GNU Affero General Public License v3.0
362 stars 150 forks source link

Fusioninventory doesn't create virtual machines as new computers #2833

Open baidez opened 5 years ago

baidez commented 5 years ago

Hi,

I have GLPI v9.4.3 and FusionInventory v9.4.0+1.0 and v2.5-3 agents.

Plugins:

| Additionnal fields | fields | 1.9.1 | | FusionInventory | fusioninventory | 9.4.0+1.0 |

In previous versions of software my agent could create the virtual machines from an ESXi host.

I'm not able to create new virtual machines form FI. I have de option Create computer based on virtual machine information ( only when the virtual machine has no inventory agent ! ) in Yes. I can import all information from an ESXi correctly but FI doesn't create the virtual machines as new computers.

I only see a lot of errors in sql-errors.log when I try to import a ESXi host with fusioninventory-injector like these:

[2019-06-26 09:55:48] glpisqllog.ERROR: DBmysql::query() in /srv/glpi/aplicacion/inc/dbmysql.class.php line 188
  *** MySQL query error:
  SQL: INSERT INTO `glpi_plugin_fusioninventory_dblockinventorynames` (`value`) VALUES ('cluster-gotham-esx02')
  Error: Duplicate entry 'cluster-gotham-esx02' for key 'PRIMARY'
  Backtrace :
  plugins/fusioninventory/inc/dblock.class.php:90
  ...ory/inc/inventorycomputerinventory.class.php:98 PluginFusioninventoryDBLock->setLock()
  ...fusioninventory/inc/communication.class.php:229 PluginFusioninventoryInventoryComputerInventory->import()
  ...fusioninventory/inc/communication.class.php:461 PluginFusioninventoryCommunication->import()
  plugins/fusioninventory/front/communication.php:93 PluginFusioninventoryCommunication->handleOCSCommunication()
  plugins/fusioninventory/index.php:59               include_once()
  {"user":"9@glpi","mem_usage":"0.101\", 2.58Mio)"}
[2019-06-26 09:55:48] glpisqllog.ERROR: DBmysql::query() in /srv/glpi/aplicacion/inc/dbmysql.class.php line 188
  *** MySQL query error:
  SQL: INSERT INTO `glpi_plugin_fusioninventory_dblockinventorynames` (`value`) VALUES ('cluster-gotham-esx02')
  Error: Duplicate entry 'cluster-gotham-esx02' for key 'PRIMARY'
  Backtrace :
  plugins/fusioninventory/inc/dblock.class.php:90
  ...ory/inc/inventorycomputerinventory.class.php:98 PluginFusioninventoryDBLock->setLock()
  ...fusioninventory/inc/communication.class.php:229 PluginFusioninventoryInventoryComputerInventory->import()
  ...fusioninventory/inc/communication.class.php:461 PluginFusioninventoryCommunication->import()
  plugins/fusioninventory/front/communication.php:93 PluginFusioninventoryCommunication->handleOCSCommunication()
  plugins/fusioninventory/index.php:59               include_once()
  {"user":"9@glpi","mem_usage":"0.101\", 2.58Mio)"}

I tried to delete the info from glpi_plugin_fusioninventory_dblockinventorynames and other dblock tables from FI but I obtain the same results. Before I used the Agent when all was correct but when I realized of the problem, I passed to test with fusioninventort-injector.

No info in Administration -> Logs. No skipped assets during imports.

In Apache I can see the request:

"POST /plugins/fusioninventory/ HTTP/1.1" 200 110 "-" "FusionInventory-Injector"

I started to use GLPI on v9.2.3 and I have been upgrading the code secuencially.

I can't install agents in virtual machines, and we have customized fields on computers (virtual machines).

How I could see the trace of an import of fusioninventory-injector or why FI doesn't create new objects?.

Thank you.

g-bougard commented 5 years ago

Just a minor point, I fixed your description as the current agent is 2.5 and 2.5.3 is not a version, but 2.5-3 is the the third debian package release of 2.5 with few bug fixes included.

duylong commented 5 years ago

Since update to FusionInventory v9.4.0+1.0, I get the same error. I don't know why... Temporarily I did:

inc/inventorycomputerinventory.class.php

      /*if (!$dbLock->setLock('inventorynames', $name, true)) {
         exit();
      }*/
...
         /*$query = $DB->buildInsert(
            'glpi_plugin_fusioninventory_dblockinventories', [
               'value' => $items_id
            ]
         );
         $CFG_GLPI["use_log_in_files"] = false;
         if (!$DB->query($query)) {
            $communication = new PluginFusioninventoryCommunication();
            $communication->setMessage("<?xml version='1.0' encoding='UTF-8'?>
         <REPLY>
         <ERROR>ERROR: SAME COMPUTER IS CURRENTLY UPDATED</ERROR>
         </REPLY>");
            $communication->sendMessage($_SESSION['plugin_fusioninventory_compressmode']);
            exit;
         }
         $CFG_GLPI["use_log_in_files"] = true;*/

$data = $rule->processAllRules($input, [], ['class'=>$this, 'return' => true]);

* Add the capacity to vm create:

inc/inventorycomputerinventory.class.php

  if (isset($data['_no_rule_matches']) AND ($data['_no_rule_matches'] == '1')) {
     $this->rulepassed(0, "Computer");
  } else if (!isset($data['found_equipment'])) {

... }

MiStErLu commented 5 years ago

I got the same problem here with GLPI 9.3.3 and FusionInventory 9.3+1.3

ddurieux commented 5 years ago

There is a fix in glpi9.4 branch. I will release in very few days, so if you can say me if this problem is fixed or not?

baidez commented 5 years ago

@ddurieux, I'm really sorry. I can't test the new code because I had to move my job to another public institution and now I don't know who is maintaining the project now. I hope someone else can try it.

MiStErLu commented 5 years ago

We will test when the 9.4.5 going out. (and fixed the search option)