Icinga / icingaweb2-module-vspheredb

The easiest way to monitor a VMware vSphere environment.
https://icinga.com/docs/vsphere/latest
GNU General Public License v2.0
100 stars 34 forks source link

'hardware_cpu_model' cannot be null #172

Closed skupjoe closed 4 years ago

skupjoe commented 4 years ago

I get the following error in my logs after adding my ESX host.

Loading existing HostSystem from DB
Got 0 existing HostSystem
SOAPClient: sent 2.19 KiB in 0.06ms, waited 1006.10ms, got 3.84 KiB response in 0.03ms. Total duration: 1006.19ms
Got 1 HostSystem from VCenter
Ready to store HostSystem
Task hostSystems failed: Storing host_system[iCeŋWh&Ok®] failed: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'hardware_cpu_model' cannot be null, query was: INSERT INTO host_system (uuid, vcenter_uuid, host_name, product_api_version, product_full_name, bios_version, bios_release_date, sysinfo_vendor, sysinfo_model, sysinfo_uuid, service_tag, hardware_cpu_model, hardware_cpu_mhz, hardware_cpu_packages, hardwa
re_cpu_cores, hardware_cpu_threads, hardware_memory_size_mb, hardware_num_hba, hardware_num_nic, runtime_power_state, custom_values) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) {array (
  'uuid' => 'iCeŋWh&Ok®',
  'vcenter_uuid' => '߬qaO(\'',
  'host_name' => '<exx_hostname>.<domain>',
  'product_api_version' => '6.7.3',
  'product_full_name' => 'VMware ESXi 6.7.0 build-14320388',
  'bios_version' => 'P1.30',
  'bios_release_date' => '2014-05-23 00:00:00',
  'sysinfo_vendor' => 'To Be Filled By O.E.M.',
  'sysinfo_model' => 'To Be Filled By O.E.M.',
  'sysinfo_uuid' => '03000200-0400-0500-0006-000700080009',
  'service_tag' => 'To Be Filled By O.E.M.',
  'hardware_cpu_model' => NULL,
  'hardware_cpu_mhz' => NULL,
  'hardware_cpu_packages' => 1,
  'hardware_cpu_cores' => 4,
  'hardware_cpu_threads' => 8,
  'hardware_memory_size_mb' => 32714.0,
  'hardware_num_hba' => NULL,
  'hardware_num_nic' => NULL,
  'runtime_power_state' => 'poweredOn',
  'custom_values' => NULL,
)}

The error repeats during sync cycles, and my Hosts list is empty as a result.

Everything else in the module seems to be working.

Also worth noting, this used to be working on v6.5 of this module.

Your Environment

skupjoe commented 4 years ago

Seems to be similar to #112

skupjoe commented 4 years ago

It seems that I was also getting similar errors for the following columns:

'hardware_cpu_mhz' 'hardware_num_hba' 'hardware_num_nic'

However, my CPU's processor type (Intel(R) Xeon(R) CPU E3-1240 v3 @ 3.40GHz), rated capacity (GHz used & total), as well as my storage adapter names & nic name are definitely visible from the vsphere web console.

My host's "Hardware manufacturer" & "Hardware model" both display as "To Be Filled By O.E.M."

skupjoe commented 4 years ago

I was able to work around the issue (sort of) by making these adjustments to my database:

ALTER TABLE vspheredb.host_system MODIFY COLUMN hardware_cpu_model varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL;
ALTER TABLE vspheredb.host_system MODIFY COLUMN hardware_cpu_mhz int(10) unsigned NULL;
ALTER TABLE vspheredb.host_system MODIFY COLUMN hardware_num_hba smallint(5) unsigned NULL;
ALTER TABLE vspheredb.host_system MODIFY COLUMN hardware_num_nic smallint(5) unsigned NULL;

Now I don't get any more violation errors in the logs, and my ESX host appears in the GUI. However, I am left with the following view:

image

Slarty70 commented 4 years ago

Same here. You can fix the "Oops" by inserting the values for CPU, MHz, HBAs and NICs in the database (table host_system).

Julio-Angel commented 4 years ago

Having a similar issue: image

skupjoe commented 4 years ago

This happens on my work's 6.5 ESX server as well.

Thomas-Gelf commented 4 years ago

Sorry, I broke this when implementing customValue support. Problem is here:

https://github.com/Icinga/icingaweb2-module-vspheredb/commit/ebfd62a#diff-1f615ea052ea1d60ce6615129a2da625R170

Replace return $this; with continue; and you'll be covered. I'll immediately push a fix. And please revert your changes to the database in case you applied any.

Thomas-Gelf commented 4 years ago

@ACAYspace: your problem happens after changing the DB schema and allowing NULL values where not expected. Sorry for causing this issue.

skupjoe commented 4 years ago

Works well now- thanks for fixing