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

Delete virtual machine or datastore #108

Closed
takenek opened this issue Dec 3, 2014 · 6 comments
Closed

Delete virtual machine or datastore #108

takenek opened this issue Dec 3, 2014 · 6 comments

Comments

@takenek
Copy link

takenek commented Dec 3, 2014

Hello,
I just delete datastore from my VMWare but zabbix-vsphere-import don`t saw this and Zabbix spam me error in logs:
4650:20141203:103525.483 error reason for "SATA_3_EMC:vpoller["datastore.get", "{$VSPHERE.HOST}", "{HOST.NAME}", "freeSpacePercentage", "null"]" changed: Cannot evaluate function "last()": item "SATA_3_EMC:vpoller["datastore.get", "{$VSPHERE.HOST}", "{HOST.NAME}", "info.freeSpace",
4650:20141203:104526.459 error reason for "SATA_3_EMC:vpoller["datastore.get", "{$VSPHERE.HOST}", "{HOST.NAME}", "freeSpacePercentage", "null"]" changed: Cannot evaluate function [last()].

root@XXX2:~# /root/import/import.sh
[2014-12-03 11:02:29,845] - INFO - Connecting to Zabbix server at https://XXX.pl/zabbix/
[2014-12-03 11:02:30,003] - INFO - [vSphere ClusterComputeResource] Importing objects to Zabbix
[2014-12-03 11:02:30,192] - INFO - [vSphere ClusterComputeResource] Objects are in sync with Zabbix
[2014-12-03 11:02:30,192] - INFO - [vSphere HostSystem] Importing objects to Zabbix
[2014-12-03 11:02:30,389] - INFO - [vSphere HostSystem] Objects are in sync with Zabbix
[2014-12-03 11:02:30,390] - INFO - [vSphere VirtualMachine] Importing objects to Zabbix
[2014-12-03 11:02:30,611] - INFO - [vSphere VirtualMachine] Objects are in sync with Zabbix
[2014-12-03 11:02:30,612] - INFO - [vSphere Datastore] Importing objects to Zabbix
[2014-12-03 11:02:30,852] - INFO - [vSphere Datastore] Objects are in sync with Zabbix

This is possible to autodelete objects from Zabbix?

dnaeon added a commit that referenced this issue Dec 3, 2014
@dnaeon
Copy link
Owner

dnaeon commented Dec 3, 2014

Hi,

I've just pushed a fix for this in thet latest zabbix-vsphere-import script from the Github repo.

Now, when you run zabbix-vsphere-import it will print a warning message for every extra host that exists in Zabbix, but is not found in the vSphere host from which we import objects.

In order to make zabbix-vsphere-import actually do the removal of such extra hosts use the --delete flag of the tool, e.g.

$ zabbix-vsphere-import --delete --file <your.config.file>

Please test it first without using --delete and see the output, which hosts are about to be removed from Zabbix and if everything looks good, then simply use the --delete flag to do the actual removal.

Let me know if you have any issues.

Thanks,
Marin

@takenek
Copy link
Author

takenek commented Dec 4, 2014

root@WIZJA2:~/import2# ./zabbix-vsphere-import -f zabbix-vsphere-import.yaml
[2014-12-04 21:25:05,448] - INFO - JSON-RPC Server Endpoint: https://wizja2.xxx.pl/zabbix//api_jsonrpc.php
[2014-12-04 21:25:05,448] - INFO - Connecting to Zabbix server at https://wizja2.xxx.pl/zabbix/
[2014-12-04 21:25:05,473] - INFO - Starting new HTTPS connection (1): wizja2.xxx.pl
[2014-12-04 21:25:05,956] - INFO - Zabbix API version is 2.2.7
[2014-12-04 21:25:05,956] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-04 21:25:06,141] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-04 21:25:06,141] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-04 21:25:06,368] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-04 21:25:06,369] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-04 21:25:06,649] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-04 21:25:06,650] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-04 21:25:06,839] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-04 21:25:06,841] - INFO - Searching for extra hosts in Zabbix, which are no longer present at vc02.xxx.net
[2014-12-04 21:25:07,059] - WARNING - Host 'Icinga' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:25:07,060] - WARNING - Host 'Zabbix' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:25:07,060] - WARNING - Host 'ds:///vmfs/volumes/543658ea-ec7af3d8-99d9-5cf3fcb69f8c/' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:25:07,060] - WARNING - Host 'ds:///vmfs/volumes/4f562061-d79ff7d8-f3b8-5ef3fcbc9f8f/' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:25:07,060] - WARNING - Host 'Project-open-v40' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:25:07,060] - WARNING - Host 'WWW.xxx.PL-DEBIAN7' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:25:07,060] - WARNING - Host 'MOBIL-TEST' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:25:07,061] - INFO - Sync completed

But got crash when use --delete:

root@WIZJA2:~/import2# ./zabbix-vsphere-import --delete -f zabbix-vsphere-import.yaml
[2014-12-04 21:27:20,984] - INFO - JSON-RPC Server Endpoint: https://wizja2.xxx.pl/zabbix//api_jsonrpc.php
[2014-12-04 21:27:20,984] - INFO - Connecting to Zabbix server at https://wizja2.xxx.pl/zabbix/
[2014-12-04 21:27:20,994] - INFO - Starting new HTTPS connection (1): wizja2.xxx.pl
[2014-12-04 21:27:21,168] - INFO - Zabbix API version is 2.2.7
[2014-12-04 21:27:21,169] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-04 21:27:21,333] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-04 21:27:21,334] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-04 21:27:21,577] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-04 21:27:21,578] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-04 21:27:21,834] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-04 21:27:21,834] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-04 21:27:22,063] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-04 21:27:22,064] - INFO - Searching for extra hosts in Zabbix, which are no longer present at vc02.xxx.net
[2014-12-04 21:27:23,191] - WARNING - Host 'Icinga' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:27:23,254] - WARNING - Deleting host 'Icinga' with hostid '10235'
[2014-12-04 21:27:23,707] - WARNING - Host 'Zabbix' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-04 21:27:23,782] - WARNING - Deleting host 'Zabbix' with hostid '10329'
[2014-12-04 21:27:24,036] - WARNING - Host 'ds:///vmfs/volumes/543658ea-ec7af3d8-99d9-5cf3fcb69f8c/' exists in Zabbix, but is not found in 'vc02.xxx.net'
Traceback (most recent call last):
File "./zabbix-vsphere-import", line 674, in
main()
File "./zabbix-vsphere-import", line 669, in main
zabbix.check_for_extra_hosts(delete=args['--delete'])
File "./zabbix-vsphere-import", line 533, in check_for_extra_hosts
hostid = self.zapi.host.get(filter={'host': host})[0]['hostid']
IndexError: list index out of range

@dnaeon
Copy link
Owner

dnaeon commented Dec 5, 2014

Hi,

I will provide a fix for this today.

Thanks,
Marin

dnaeon added a commit that referenced this issue Dec 5, 2014
@dnaeon
Copy link
Owner

dnaeon commented Dec 5, 2014

Please get the latest zabbix-vsphere-import tool from the Github repo.

I've just pushed a fix for this issue. Let me know how it goes.

Thanks,
Marin

@takenek
Copy link
Author

takenek commented Dec 5, 2014

Look OK:

./zabbix-vsphere-import -f zabbix-vsphere-import.yaml
root@WIZJA2:~/import2# ./zabbix-vsphere-import -f zabbix-vsphere-import.yaml
[2014-12-05 08:41:53,388] - INFO - JSON-RPC Server Endpoint: https://wizja2.xxx.pl/zabbix//api_jsonrpc.php
[2014-12-05 08:41:53,389] - INFO - Connecting to Zabbix server at https://wizja2.xxx.pl/zabbix/
[2014-12-05 08:41:53,395] - INFO - Starting new HTTPS connection (1): wizja2.xxx.pl
[2014-12-05 08:41:53,578] - INFO - Zabbix API version is 2.2.7
[2014-12-05 08:41:53,578] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:41:53,746] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:41:53,747] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:41:53,960] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:41:53,961] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:41:54,240] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:41:54,241] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:41:54,478] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:41:54,479] - INFO - Searching for extra hosts in Zabbix, which are no longer present at vc02.xxx.net
[2014-12-05 08:41:54,723] - WARNING - Host 'WWW.xxx.PL-DEBIAN7' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:41:54,723] - WARNING - Host 'MOBIL-TEST' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:41:54,723] - WARNING - Host 'ds:///vmfs/volumes/543658ea-ec7af3d8-99d9-5cf3fcb69f8c/' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:41:54,723] - WARNING - Host 'ds:///vmfs/volumes/4f562061-d79ff7d8-f3b8-5ef3fcbc9f8f/' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:41:54,723] - WARNING - Host 'Project-open-v40' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:41:54,724] - INFO - Sync completed

root@WIZJA2:~/import2# ./zabbix-vsphere-import --delete -f zabbix-vsphere-import.yaml
[2014-12-05 08:41:59,493] - INFO - JSON-RPC Server Endpoint: https://wizja2.xxx.pl/zabbix//api_jsonrpc.php
[2014-12-05 08:41:59,494] - INFO - Connecting to Zabbix server at https://wizja2.xxx.pl/zabbix/
[2014-12-05 08:41:59,504] - INFO - Starting new HTTPS connection (1): wizja2.xxx.pl
[2014-12-05 08:41:59,729] - INFO - Zabbix API version is 2.2.7
[2014-12-05 08:41:59,729] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:41:59,863] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:41:59,863] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:42:00,129] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:42:00,130] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:42:00,484] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:42:00,485] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:42:00,716] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:42:00,717] - INFO - Searching for extra hosts in Zabbix, which are no longer present at vc02.xxx.net
[2014-12-05 08:42:00,937] - WARNING - Host 'WWW.xxx.PL-DEBIAN7' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:42:01,014] - WARNING - Deleting host 'WWW.xxx.PL-DEBIAN7' with hostid '10377'
[2014-12-05 08:42:01,509] - WARNING - Host 'MOBIL-TEST' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:42:01,582] - WARNING - Deleting host 'MOBIL-TEST' with hostid '10334'
[2014-12-05 08:42:01,767] - WARNING - Host 'ds:///vmfs/volumes/543658ea-ec7af3d8-99d9-5cf3fcb69f8c/' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:42:01,835] - WARNING - Deleting host 'ds:///vmfs/volumes/543658ea-ec7af3d8-99d9-5cf3fcb69f8c/' with hostid '10371'
[2014-12-05 08:42:02,043] - WARNING - Host 'ds:///vmfs/volumes/4f562061-d79ff7d8-f3b8-5ef3fcbc9f8f/' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:42:02,137] - WARNING - Deleting host 'ds:///vmfs/volumes/4f562061-d79ff7d8-f3b8-5ef3fcbc9f8f/' with hostid '10348'
[2014-12-05 08:42:02,282] - WARNING - Host 'Project-open-v40' exists in Zabbix, but is not found in 'vc02.xxx.net'
[2014-12-05 08:42:02,362] - WARNING - Deleting host 'Project-open-v40' with hostid '10148'
[2014-12-05 08:42:02,608] - INFO - Sync completed

root@WIZJA2:~/import2# ./zabbix-vsphere-import -f zabbix-vsphere-import.yaml
[2014-12-05 08:42:09,271] - INFO - JSON-RPC Server Endpoint: https://wizja2.xxx.pl/zabbix//api_jsonrpc.php
[2014-12-05 08:42:09,271] - INFO - Connecting to Zabbix server at https://wizja2.xxx.pl/zabbix/
[2014-12-05 08:42:09,280] - INFO - Starting new HTTPS connection (1): wizja2.xxx.pl
[2014-12-05 08:42:09,458] - INFO - Zabbix API version is 2.2.7
[2014-12-05 08:42:09,458] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:42:09,614] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:42:09,615] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:42:09,837] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:42:09,838] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:42:10,210] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:42:10,210] - INFO - [[email protected]] Importing objects to Zabbix
[2014-12-05 08:42:10,553] - INFO - [[email protected]] Objects are in sync with Zabbix
[2014-12-05 08:42:10,554] - INFO - Searching for extra hosts in Zabbix, which are no longer present at vc02.xxx.net
[2014-12-05 08:42:10,756] - INFO - Sync completed

@dnaeon
Copy link
Owner

dnaeon commented Dec 5, 2014

Thanks for confirming the fix! :)

@dnaeon dnaeon closed this as completed Dec 5, 2014
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