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

Failed to collect vcenter data #62

Closed
arogarth opened this issue Jan 3, 2019 · 11 comments

Comments

Projects
None yet
6 participants
@arogarth
Copy link

commented Jan 3, 2019

I tried to use this exporter using the docker image 'pryorda/vmware_exporter'.

I want to test the exporter locally with curl:

 curl localhost:9272/metrics?vsphere_host=vcenter02.company.com

I only get a collection error. Viewing the logs I get

[2019-01-03 10:26:23.940622+00:00] Starting web server on port 9272
[2019-01-03 10:26:26.638387+00:00] Start collecting metrics from vcenter02.company.com
[2019-01-03 10:26:26.819656+00:00] Starting inventory collection
[2019-01-03 10:26:26.853162+00:00] Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/vmware_exporter/vmware_exporter.py", line 686, in _async_render_GET
    yield self.generate_latest_metrics(request)
  File "/usr/local/lib/python3.6/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python3.6/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python3.6/site-packages/vmware_exporter/vmware_exporter.py", line 725, in generate_latest_metrics
    metrics = yield collector.collect()
  File "/usr/local/lib/python3.6/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python3.6/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python3.6/site-packages/vmware_exporter/vmware_exporter.py", line 185, in collect
    content,
  File "/usr/local/lib/python3.6/site-packages/twisted/python/threadpool.py", line 250, in inContext
    result = inContext.theWork()
  File "/usr/local/lib/python3.6/site-packages/twisted/python/threadpool.py", line 266, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "/usr/local/lib/python3.6/site-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python3.6/site-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
  File "/usr/local/lib/python3.6/site-packages/vmware_exporter/vmware_exporter.py", line 586, in _vmware_get_inventory
    for host in folder.host:
AttributeError: 'vim.Folder' object has no attribute 'host'

My docker-compose file

version: "3"
services:
  vcenter_exporter:
    container_name: vcenter-exporter
    image: pryorda/vmware_exporter:v0.4.2
    ports:
    - 9272:9272
    environment:
      VSPHERE_USER: "monitor"
      VSPHERE_PASSWORD: "p@$$w0rd"
      VSPHERE_IGNORE_SSL: "True"
      VSPHERE_COLLECT_VMS: "False"
      VSPHERE_COLLECT_DATASTORES: "False"
      VSPHERE_COLLECT_VMGUESTS: "False"
      VSPHERE_COLLECT_SNAPSHOTS: "False"
@arogarth

This comment has been minimized.

Copy link
Author

commented Jan 3, 2019

Same error using config-file....

@Jc2k

This comment has been minimized.

Copy link
Collaborator

commented Jan 3, 2019

Hi @arogarth!

Can you describe your environment a bit? Looks like you are using vCenter rather than raw ESXi access? What versions are you using? I'm guessing you have hosts that arent in a ClusterComputeResource?

(We have seen v0.4.2 working on standalone ESXi and 2 installs using vCenter so i'm trying to triage whats different in your environment).

@arogarth

This comment has been minimized.

Copy link
Author

commented Jan 3, 2019

We have two vCenter Server with multiple cluster and ESXi Server. The vCenter hast Version 6.0.0.

@arogarth

This comment has been minimized.

Copy link
Author

commented Jan 3, 2019

Commited a small bugfix which work for me - #63

Just a small if to check that folder object has attribute host...

@Jc2k

This comment has been minimized.

Copy link
Collaborator

commented Jan 3, 2019

Looks good. It would be helpful to know what other non-host items can be in dc.hostFolder.childEntity though - could you do me a big favour and do something like:

if not hasattr(folder, 'host'):
    print(folder)
@pryorda

This comment has been minimized.

Copy link
Owner

commented Jan 3, 2019

@Jc2k The MoB url should allow use to see the possible child entities.

@pryorda

This comment has been minimized.

Copy link
Owner

commented Jan 3, 2019

I dont know if this is inclusive of all childTypes or not.

image

@williancardoso

This comment has been minimized.

Copy link

commented Feb 5, 2019

Hi guys,
In my case, I try to use the docker image 'pryorda/vmware_exporter' and no mensagem is shown

curl localhost:9272/metrics?vsphere_host=vcenter1.company

in docker logs shown
vmware_exporter | [2019-02-05 22:33:02.277572+00:00] Start collecting metrics from 'vcenter1.company'
vmware_exporter | [2019-02-05 22:33:02.277893+00:00] Finished collecting metrics from 'vcenter1.company'

How to use in debug mode? I using the latest version (v0.7.0) - https://hub.docker.com/r/pryorda/vmware_exporter/tags

My vcenter is 6.5

@ykuksenko

This comment has been minimized.

Copy link

commented Mar 1, 2019

Hello all,
I am following up issue #88 here as it was closed and seems to have migrated here. I am seeing basically the same problem and am running vCenter 6.5. This may be a stupid question as I am a new python user. But on line 414 of vmware_exporter.py

 def _collect(dc, node):
            host_inventory = {}
            for folder in node.childEntity:
                if hasattr(folder, 'host'):
                    for host in folder.host:  # Iterate through Hosts in the Cluster
                        host_name = host.summary.config.name.rstrip('.')
                        host_inventory[host._moId] = [
                            host_name,
                            dc.name,
                            folder.name if isinstance(folder, vim.ClusterComputeResource) else ''
                        ]

                if isinstance(folder, vim.Folder):
                    host_inventory.extend(_collect(dc, folder))  # <<<===== THIS LINE !!!!!!!

return host_inventory

'.extend' is being called on a a dictionary. As far as I can find extend isn't something you can do to a dictionary. Was '.update' meant to be used or am I not understanding something? I tried plugging that in and the error went away. I seem to have full output for all sections now. Before this if I enabled only datastores could I get any metrics. I am not sure if I have complete output. I don't fully know what to expect as this is the first time I use this tool.

Thank you.

@kremers

This comment has been minimized.

Copy link
Contributor

commented May 15, 2019

I think this is obsolete now, since the _collect logic changed as a whole.
Would suggest to close this issue, except someone can still produce an error with the most up to date version.

@arogarth can you please re-test?

@pryorda pryorda closed this May 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.