{"action":"created","issue":{"url":"https://api.github.com/repos/pryorda/vmware_exporter/issues/40","repository_url":"https://api.github.com/repos/pryorda/vmware_exporter","labels_url":"https://api.github.com/repos/pryorda/vmware_exporter/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/pryorda/vmware_exporter/issues/40/comments","events_url":"https://api.github.com/repos/pryorda/vmware_exporter/issues/40/events","html_url":"https://github.com/pryorda/vmware_exporter/issues/40","id":393045906,"node_id":"MDU6SXNzdWUzOTMwNDU5MDY=","number":40,"title":"Metrics for only one host or datastore instance are reported","user":{"login":"karlism","id":19568035,"node_id":"MDQ6VXNlcjE5NTY4MDM1","avatar_url":"https://avatars3.githubusercontent.com/u/19568035?v=4","gravatar_id":"","url":"https://api.github.com/users/karlism","html_url":"https://github.com/karlism","followers_url":"https://api.github.com/users/karlism/followers","following_url":"https://api.github.com/users/karlism/following{/other_user}","gists_url":"https://api.github.com/users/karlism/gists{/gist_id}","starred_url":"https://api.github.com/users/karlism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlism/subscriptions","organizations_url":"https://api.github.com/users/karlism/orgs","repos_url":"https://api.github.com/users/karlism/repos","events_url":"https://api.github.com/users/karlism/events{/privacy}","received_events_url":"https://api.github.com/users/karlism/received_events","type":"User","site_admin":false},"labels":[{"id":971819244,"node_id":"MDU6TGFiZWw5NzE4MTkyNDQ=","url":"https://api.github.com/repos/pryorda/vmware_exporter/labels/bug","name":"bug","color":"d73a4a","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-12-20T13:25:48Z","updated_at":"2018-12-21T18:50:14Z","closed_at":null,"author_association":"NONE","body":"Helllo,\r\n\r\nVMware exporter returns metrics only for one host or datastore instance.\r\n\r\nEnvironment:\r\nvmware_exporter.py v0.3.0\r\nPython 3.5.2 (Ubuntu) & Python 3.6.6 (OpenBSD)\r\nI've checked that all permissions are correct on vSphere side and also tried connecting by using administrator account.\r\n\r\nSteps to reproduce:\r\n```\r\n$ cat config.yml\r\ndefault:\r\n    vsphere_host: \"hostname\"   # this is vCenter host\r\n    vsphere_user: 'username'\r\n    vsphere_password: 'password'\r\n    ignore_ssl: True\r\n    collect_only:\r\n        vms: False\r\n        vmguests: False\r\n        datastores: True\r\n        hosts: True\r\n        snapshots: False\r\n$ ./vmware_exporter.py -c config.yml\r\n$ curl -s localhost:9272/metrics | grep -v \"#\"\r\nvmware_host_power_state{cluster_name=\"XXX cluster\",dc_name=\"DC_NAME\",host_name=\"vm1.example.com\"} 1.0\r\n```\r\n\r\nApplying following patch shows that only first host or datastore is processed in for loop:\r\n```\r\n--- vmware_exporter.py.orig     2018-12-20 14:11:48.535447407 +0100\r\n+++ vmware_exporter.py  2018-12-20 14:15:59.207702036 +0100\r\n@@ -299,7 +299,9 @@\r\n         \"\"\"\r\n         log(\"Starting datastore metrics collection\")\r\n         datastores = self._vmware_get_obj(content, [vim.Datastore])\r\n+        print(datastores)\r\n         for datastore in datastores:\r\n+            print(datastore)\r\n             # ds.RefreshDatastoreStorageInfo()\r\n             summary = datastore.summary\r\n             ds_name = summary.name\r\n@@ -461,7 +463,9 @@\r\n         \"\"\"\r\n         log(\"Starting host metrics collection\")\r\n         hosts = self._vmware_get_obj(content, [vim.HostSystem])\r\n+        print(hosts)\r\n         for host in hosts:\r\n+            print(host)\r\n             summary = host.summary\r\n             host_name, host_dc_name, host_cluster_name = self._vmware_host_metadata(inventory, host)\r\n             host_metadata = [host_name, host_dc_name, host_cluster_name]\r\n```\r\nOutput after applying patch:\r\n```\r\n$ ./vmware_exporter.py -c config.yml \r\n[2018-12-20 13:21:36.743208+00:00] Starting web server on port 9272\r\n[2018-12-20 13:21:41.860451+00:00] Start collecting metrics from hostname\r\n[2018-12-20 13:21:42.041749+00:00] Starting inventory collection\r\n[2018-12-20 13:21:43.712368+00:00] Finished inventory collection\r\n[2018-12-20 13:21:43.712878+00:00] Starting datastore metrics collection\r\n[2018-12-20 13:21:43.713506+00:00] Starting host metrics collection\r\n(ManagedObject) [\r\n   'vim.Datastore:datastore-1263',\r\n   'vim.Datastore:datastore-26',\r\n   'vim.Datastore:datastore-29',\r\n   'vim.Datastore:datastore-25',\r\n   'vim.Datastore:datastore-28',\r\n   'vim.Datastore:datastore-6324',\r\n   'vim.Datastore:datastore-1261',\r\n   'vim.Datastore:datastore-369',\r\n   'vim.Datastore:datastore-3412',\r\n   'vim.Datastore:datastore-6169',\r\n   'vim.Datastore:datastore-6167',\r\n   'vim.Datastore:datastore-2064',\r\n   'vim.Datastore:datastore-2065',\r\n   'vim.Datastore:datastore-12841',\r\n   'vim.Datastore:datastore-12847',\r\n   'vim.Datastore:datastore-27354',\r\n   'vim.Datastore:datastore-27349'\r\n]\r\n'vim.Datastore:datastore-1263'\r\n(ManagedObject) [\r\n   'vim.HostSystem:host-1487',\r\n   'vim.HostSystem:host-1315',\r\n   'vim.HostSystem:host-1390',\r\n   'vim.HostSystem:host-1260',\r\n   'vim.HostSystem:host-1460',\r\n   'vim.HostSystem:host-1462',\r\n   'vim.HostSystem:host-24',\r\n   'vim.HostSystem:host-27',\r\n   'vim.HostSystem:host-6322',\r\n   'vim.HostSystem:host-3411',\r\n   'vim.HostSystem:host-367',\r\n   'vim.HostSystem:host-6246',\r\n   'vim.HostSystem:host-6276',\r\n   'vim.HostSystem:host-6255',\r\n   'vim.HostSystem:host-6194',\r\n   'vim.HostSystem:host-6166',\r\n   'vim.HostSystem:host-6205',\r\n   'vim.HostSystem:host-2063',\r\n   'vim.HostSystem:host-12840',\r\n   'vim.HostSystem:host-12846',\r\n   'vim.HostSystem:host-27348',\r\n   'vim.HostSystem:host-27353'\r\n]\r\n'vim.HostSystem:host-1487'\r\n[2018-12-20 13:21:43.828089+00:00] Finished collecting metrics from hostname\r\n```"},"comment":{"url":"https://api.github.com/repos/pryorda/vmware_exporter/issues/comments/449468777","html_url":"https://github.com/pryorda/vmware_exporter/issues/40#issuecomment-449468777","issue_url":"https://api.github.com/repos/pryorda/vmware_exporter/issues/40","id":449468777,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTQ2ODc3Nw==","user":{"login":"dannyk81","id":24274156,"node_id":"MDQ6VXNlcjI0Mjc0MTU2","avatar_url":"https://avatars0.githubusercontent.com/u/24274156?v=4","gravatar_id":"","url":"https://api.github.com/users/dannyk81","html_url":"https://github.com/dannyk81","followers_url":"https://api.github.com/users/dannyk81/followers","following_url":"https://api.github.com/users/dannyk81/following{/other_user}","gists_url":"https://api.github.com/users/dannyk81/gists{/gist_id}","starred_url":"https://api.github.com/users/dannyk81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dannyk81/subscriptions","organizations_url":"https://api.github.com/users/dannyk81/orgs","repos_url":"https://api.github.com/users/dannyk81/repos","events_url":"https://api.github.com/users/dannyk81/events{/privacy}","received_events_url":"https://api.github.com/users/dannyk81/received_events","type":"User","site_admin":false},"created_at":"2018-12-21T18:50:14Z","updated_at":"2018-12-21T18:50:14Z","author_association":"COLLABORATOR","body":"@jc2k I have a possible fix in https://github.com/pryorda/vmware_exporter/pull/42\r\n\r\nThis fixed the issue for me."}}
{"actor":{"display_login":"dannyk81"}}