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

Import blocked #179

Closed
Virsacer opened this issue Aug 27, 2020 · 8 comments
Closed

Import blocked #179

Virsacer opened this issue Aug 27, 2020 · 8 comments
Milestone

Comments

@Virsacer
Copy link
Contributor

Expected Behavior

Import everything

Current Behavior

13:24:13: Task hostSensors failed: Storing host_sensor[] failed: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'health_state' at row 1, query was: INSERT INTO host_sensor (name, host_uuid, health_state, current_reading, unit_modifier, base_units, rate_units, sensor_type, vcenter_uuid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) {array (
  'name' => 'System Board 1 Exhaust Temp',
  'host_uuid' => 'xxxxxx',
  'health_state' => 'Green',
  'current_reading' => 2800,
  'unit_modifier' => -2,
  'base_units' => 'degrees C',
  'rate_units' => 'none',
  'sensor_type' => 'temperature',
  'vcenter_uuid' => 'xxxxxx',
)}
13:24:14: Task eventStream failed: There is already an active transaction
13:24:16: Task eventStream failed: There is already an active transaction
13:24:18: Task eventStream failed: There is already an active transaction
13:24:20: Task eventStream failed: There is already an active transaction
13:24:22: Task eventStream failed: There is already an active transaction
13:25:39: Task storagePods failed: There is already an active transaction
13:25:39: Task quickStats failed: There is already an active transaction
13:27:09: Task storagePods failed: There is already an active transaction
13:27:09: Task quickStats failed: There is already an active transaction
13:28:39: Task storagePods failed: There is already an active transaction
13:28:39: Task quickStats failed: There is already an active transaction
13:29:09: Task vmDatastoreUsage failed: There is already an active transaction
13:29:09: Task vmDiskUsage failed: There is already an active transaction
13:30:09: Task storagePods failed: There is already an active transaction
13:30:09: Task quickStats failed: There is already an active transaction
13:31:39: Task storagePods failed: There is already an active transaction
13:31:39: Task quickStats failed: There is already an active transaction

Possible Solution

Convert 'health_state' to lower case.

Steps to Reproduce (for bugs)

New Database
Add vCenter

Your Environment

  • VMware vCenter®/ESXi™-Version: 7.0.0
  • Version/GIT-Hash of this module: 917b4cd
  • Icinga Web 2 version: 2.8.1
  • Operating System and version: Oracle Linux 7
  • Webserver, PHP versions: Apache, PHP 7.3.11
@Thomas-Gelf
Copy link
Contributor

This is REALLY strange, Green shouldn't be valid, according to the documentation this is has to be one of the following enum constants: HealthState

Could you please navigate to:

https://<your-vcenter>/mob/?moid=<host-managed-object-id>&doPath=runtime%2ehealthSystemRuntime%2esystemHealthInfo%2enumericSensorInfo

In the URL please replace <your-vcenter> with hostname/ip[:port] and <host-managed-object-id> with the MoID belonging to this host (often ha-host on ESXior the hostname in a vCenter). In case you can navigate to this host in vSphereDB click on theMO Reflink and then navigate toruntime->healthSystemRuntime->systemHealthInfo->numericSensorInfo. Please share as much as possible from the result page, at lease a screenshot showing key => Greenwith an uppercaseG`.

Thanks,
Thomas

@Virsacer
Copy link
Contributor Author

Virsacer commented Sep 9, 2020

Well, the documentation does not explicitly say it has to be lower case?

Ok, here are about 120 readings - all with "Green", so I guess a screenshot of the beginning is enough:

ESXi Sensors

@Thomas-Gelf
Copy link
Contributor

That's VERY strange, I do not see why they should violate their own specs - and how this could happen. I bet there are quite some tools out there checking for the exact strings green, yellow and so on. Please also share https://<your-vcenter>/mob/?moid=ServiceInstance&doPath=content%2eabout. Is this a fresh installation, or did you upgrade from 6.x?

@Virsacer
Copy link
Contributor Author

Virsacer commented Sep 9, 2020

This is a fresh installation...

image

@Thomas-Gelf
Copy link
Contributor

Thomas-Gelf commented Sep 9, 2020

In library/Vspheredb/DbObject/HostSensor.php on line 45 please replace...

$this->set($property, $properties[$key]->key);

...with...

$this->set($property, lcfirst($properties[$key]->key));

...and let me know whether this helps. Unfortunately in my current working copy I already completely removed this method from HostSensor and modified it to work in a more generic way. However, the new code has an even harder dependency on correct values :-/

But that's not your problem. Please try it out and let me know!

@Thomas-Gelf
Copy link
Contributor

(comment has been updated)

@Thomas-Gelf Thomas-Gelf added this to the v1.2.0 milestone Sep 9, 2020
@Virsacer
Copy link
Contributor Author

Virsacer commented Sep 9, 2020

Yes, this is working - thank you :-)

No strtolower to be completely safe?

@Thomas-Gelf
Copy link
Contributor

@Virsacer: the code you tweaked no longer exists. Yesterday it has been moved to a base object and would now affect every ElementDescription instance, a class used by VMware in multiple places. It would affect vSphereDB for example where it deals with performance counter names, groups and units. I checked a few vCenter and ESXi instances: lcfirst would corrupt only one single not-so-important counter name, strtolower would corrupt most of them, plus group and unit names.

Fortunately as of how that new piece of code is triggered, lcfirst/strtolower would (at least for now) not even touch that one single counter name when synchronizing them. Still, I consider this a risky fix. The side-effects of lcfirst triggered on the wrong object would be negligible while strtolower would be devastating. That's why I sticked with lcfirst, it will suffice for all values that should be shipped for HostSensor healthState. I also placed a comment explaining this hack next to the code. I'll push it tomorrow, currently it sits on top of 20 other commits waiting for another feature to be finished in my working copy ;-)

The problem here is that VMware seems to violate their own specs, IMHO this is a bug. But of course for now working around that issue is probably the better option than waiting for their fix ;-)

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

No branches or pull requests

2 participants