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

zabbix-vsphere-import cannot create a new host #100

Closed
Satei opened this issue Oct 31, 2014 · 11 comments
Closed

zabbix-vsphere-import cannot create a new host #100

Satei opened this issue Oct 31, 2014 · 11 comments

Comments

@Satei
Copy link

Satei commented Oct 31, 2014

Hallo

My problem is the vsphere import script.
Autodiscover and also the import of datastores runs perfect, but not the import of hosts.
I get the following error:
[2014-10-31 07:40:40,323] - WARNING - [vSphere VirtualMachine] Cannot create host in Zabbix: (u'Error -32500: Application error., No permissions to referred object or it does not exist! while sending {"params": {"templates": [{"templateid": "10419"}], "proxy_hostid": null, "interfaces": [{"ip": "127.0.0.1", "useip": 1, "dns": "", "main": 1, "type": 1, "port": "10050"}], "macros": [{"macro": "{$VSPHERE.HOST}", "value": "infra-abg-esxi1.psi.de"}], "host": "VM-ON-ESXI", "groups": [{"groupid": "6"}, {"groupid": null}]}, "jsonrpc": "2.0", "method": "host.create", "auth": "63dc0b74023978e067684883e03472e2", "id": 7}', -32500)
The user is Zabbix Super Admin and the datastore was created so everything with the rights should be fine.
After google'ing I get no solution, so I hope you can help me, because the feature is exactly what I need.

Regards
Bodo

@dnaeon
Copy link
Owner

dnaeon commented Oct 31, 2014

Hey Bodo,

Can you please post your zabbix-vsphere-import.yaml configuration file that you are using during the import?

From the error above it seems that one of the groups for Virtual Machines is null, which doesn't look correct.

Do you get this error for all Virtual Machines or just specific ones?

Thanks,
Marin

@Satei
Copy link
Author

Satei commented Oct 31, 2014

Hello Marin

Sure, I removed the "proxy:" line because it was the same error with the line and without proxy.
My VCenters/ESXI are polled from the zabbix-server directly.
Same error with esxi 5.5 u2 or vcenter 5.1.

Thanks for your help
Bodo


vsphere:
hostname: ESXI-OR-VCENTER.fqdn

vpoller:
endpoint: tcp://localhost:10123
retries: 3
timeout: 3000

zabbix:
hostname: http://zabbix.fqdn
username: user
password: withrights

vsphere_object_host:
templates:
- Template VMware vSphere Hypervisor - vPoller Native
macros:
VSPHERE.HOST: ESXI-OR-VCENTER.fqdn
groups:
- Hypervisors

vsphere_object_vm:
templates:
- Template VMware vSphere Virtual Machine - vPoller Native
macros:
VSPHERE.HOST: ESXI-OR-VCENTER.fqdn
groups:
- Virtual machines

vsphere_object_datastore:
templates:
- Template VMware vSphere Datastore - vPoller Native
macros:
VSPHERE.HOST: ESXI-OR-VCENTER.fqdn
groups:
- Datastores

@dnaeon
Copy link
Owner

dnaeon commented Oct 31, 2014

Hi Bodo,

Can you please try changing the Zabbix group in the vsphere_object_vm section from Virtual machines to Virtual Machines (note the capital letters in the latter one) and let me know how it goes?

Also, is this issue happening for all Virtual Machines or just specific ones?

Thanks,
Marin

@Satei
Copy link
Author

Satei commented Oct 31, 2014

Hello Marin

Than the script trys to create the group but fails.
I think because of the group with the "same" name only with the little m.

[2014-10-31 12:43:38,529] - INFO - Creating Zabbix host group 'Virtual Machines'
Traceback (most recent call last):
File "./py-vpoller/src/zabbix/vsphere-import/zabbix-vsphere-import", line 642, in
main()
File "./py-vpoller/src/zabbix/vsphere-import/zabbix-vsphere-import", line 638, in main
zabbix.import_vsphere_vms()
File "./py-vpoller/src/zabbix/vsphere-import/zabbix-vsphere-import", line 360, in import_vsphere_vms
host_options = self._get_zabbix_host_options('vsphere_object_vm')
File "./py-vpoller/src/zabbix/vsphere-import/zabbix-vsphere-import", line 523, in _get_zabbix_host_options
result = self.create_host_group(name=group)
File "./py-vpoller/src/zabbix/vsphere-import/zabbix-vsphere-import", line 228, in create_host_group
params={'name': name}
File "./py-vpoller/src/zabbix/vsphere-import/zabbix-vsphere-import", line 563, in _call_zabbix_method
result = self.conn.do_request(req)
File "/usr/local/lib/python2.7/dist-packages/zabbix_api.py", line 295, in do_request
raise Already_Exists(msg, jobj['error']['code'])
zabbix_api.Already_Exists: (u'Error -32602: Invalid params., Host group "Virtual Machines" already exists. while sending {"params": {"name": "Virtual Machines"}, "jsonrpc": "2.0", "method": "hostgroup.create", "auth": "46cb625e7d290063ac0ca162d5435f14", "id": 6}', -32602)

I tryed it with a groupname "VM".
Than the script created the group but fails with the same error:
Cannot create host in Zabbix: (u'Error -32500: Application error., No permissions to referred object or it does not exist!

It happens to all VMs.
I tryed it with a VCenter server with 3 hosts and around 30 VMs and all of it failed.

Regards
Bodo

@dnaeon
Copy link
Owner

dnaeon commented Oct 31, 2014

Hey Bodo,

That's strange, because Virtual machines and Virtual Machines are two different groups.

On what environment is your Zabbix infra running? Windows? Please provide more details about your Zabbix environment, so that I can try to test and reproduce it.

Thanks,
Marin

@Satei
Copy link
Author

Satei commented Oct 31, 2014

Hello Marin

Ubuntu 14.04.1 LTS
Zabbix server v2.2.6 (revision 48483) with the "no snmp bulk" patch (ZBXNEXT-2301)
vpoller 0.3.3 (GITsource)
I tested it against:
ESXi 5.5.0, 1331820
VCenter 5.1.0, 799733 (Windows 2012)
Both without proxy, directly from zabbixserver.

Is that enough information?
Thanks in advance and have a nice weekend.

Regards
Bodo

@dnaeon
Copy link
Owner

dnaeon commented Nov 1, 2014

Hi Bodo,

Please check your Zabbix & Database logs and see whether there are any errors reported when you experience this issue.

So far, I am not able to re-produce this issue on my side.

Regards,
Marin

@Satei
Copy link
Author

Satei commented Nov 3, 2014

Hello Marin

OK in the morning I updated my zabbix-server to 2.2.7.
I hoped the error would be away, but no luck :(
During the install, the only special thing I must build in was, that I must add another includepath (-I/usr/include/libxml2) in the vpoller.so Makefile.
Without adding -I/usr/include/libxml2 it cannot find parser.h:
cc -fPIC -shared -o vpoller.so vpoller.c -I../../../include -I/usr/local/include -I/usr/include -L/usr/local/lib -lzmq
In file included from ../../../include/common.h:23:0,
from ../../../include/threads.h:23,
from vpoller.c:32:
../../../include/sysinc.h:401:28: fatal error: libxml/parser.h: Datei oder Verzeichnis nicht gefunden

include <libxml/parser.h>

                        ^

compilation terminated.
make: *** [vpoller] Fehler 1

But after that everything went fine.

But now to the import script:
Without debug nothing is shown in the LOGs.
Only in Apache the zabbix_api requests:
"POST /api_jsonrpc.php HTTP/1.0" 200 299 "-" "python/zabbix_api"
"POST /api_jsonrpc.php HTTP/1.0" 200 2068 "-" "python/zabbix_api"
"POST /api_jsonrpc.php HTTP/1.0" 200 155095 "-" "python/zabbix_api"
"POST /api_jsonrpc.php HTTP/1.0" 200 155095 "-" "python/zabbix_api"
"POST /api_jsonrpc.php HTTP/1.0" 200 51541 "-" "python/zabbix_api"
"POST /api_jsonrpc.php HTTP/1.0" 200 2068 "-" "python/zabbix_api"
"POST /api_jsonrpc.php HTTP/1.0" 200 2068 "-" "python/zabbix_api"
"POST /api_jsonrpc.php HTTP/1.0" 200 376 "-" "python/zabbix_api"
"POST /api_jsonrpc.php HTTP/1.0" 200 155095 "-" "python/zabbix_api"

With debug in zabbix-server-log is also nothing.
mySQL makes a ROLLBACK, maybe that get you a hint?
130 Connect zabbix@zabbix.fqdn on zabbix
130 Query SET NAMES utf8
130 Query SHOW TABLES LIKE 'dbversion'
130 Query SELECT dv.mandatory,dv.optional FROM dbversion dv
130 Query SELECT n.* FROM nodes n WHERE n.nodetype=1 ORDER BY n.nodeid
130 Query BEGIN
130 Query SELECT u.userid,u.autologout,s.lastaccess FROM sessions s,users u WHERE s.sessionid='ff498b46338c2b441fa511184d607570' AND s.status=0 AND s.userid=u.userid AND (s.lastaccess+u.autologout>1414997157 OR u.autologout=0)
130 Query SELECT MAX(g.gui_access) AS gui_access FROM usrgrp g,users_groups ug WHERE ug.userid=6 AND g.usrgrpid=ug.usrgrpid
130 Query SELECT u.userid,u.alias,u.name,u.surname,u.url,u.autologin,u.autologout,u.lang,u.refresh,u.type, u.theme,u.attempt_failed,u.attempt_ip,u.attempt_clock,u.rows_per_page FROM users u WHERE u.userid='6'
130 Query SELECT ug.userid FROM usrgrp g,users_groups ug WHERE ug.userid='6' AND g.usrgrpid=ug.usrgrpid AND g.debug_mode=1
130 Query COMMIT
130 Query BEGIN
130 Query SELECT g.* FROM groups g WHERE g.groupid='6'
130 Query ROLLBACK
130 Quit

mysql> SELECT g.* FROM groups g WHERE g.groupid='6';
+---------+------------------+----------+-------+
| groupid | name | internal | flags |
+---------+------------------+----------+-------+
| 6 | Virtual machines | 0 | 0 |
+---------+------------------+----------+-------+
1 row in set (0.00 sec)

It's the same sessionid:
[2014-11-03 07:45:56,716] - INFO - Connecting to Zabbix server at http://zabbix.fqdn
[2014-11-03 07:45:56,733] - INFO - [vSphere ClusterComputeResource] Importing objects to Zabbix
[2014-11-03 07:45:56,794] - INFO - [vSphere ClusterComputeResource] Objects are in sync with Zabbix
[2014-11-03 07:45:56,794] - INFO - [vSphere HostSystem] Importing objects to Zabbix
[2014-11-03 07:45:56,889] - INFO - [vSphere HostSystem] Objects are in sync with Zabbix
[2014-11-03 07:45:56,889] - INFO - [vSphere VirtualMachine] Importing objects to Zabbix
[2014-11-03 07:45:56,977] - INFO - [vSphere VirtualMachine] Number of objects to be imported: 1
[2014-11-03 07:45:57,029] - INFO - [vSphere VirtualMachine] Creating Zabbix host 'VM-ON-ESXI'
[2014-11-03 07:45:57,233] - WARNING - [vSphere VirtualMachine] Cannot create host in Zabbix: (u'Error -32500: Application error., No permissions to referred object or it does not exist! while sending {"params": {"templates": [{"templateid": "10419"}], "proxy_hostid": null, "interfaces": [{"ip": "127.0.0.1", "useip": 1, "dns": "", "main": 1, "type": 1, "port": "10050"}], "macros": [{"macro": "{$VSPHERE.HOST}", "value": "ESXI-OR-VCENTER.fqdn"}], "host": "VM-ON-ESXI", "groups": [{"groupid": "6"}, {"groupid": null}]}, "jsonrpc": "2.0", "method": "host.create", "auth": "ff498b46338c2b441fa511184d607570", "id": 7}', -32500)
[2014-11-03 07:45:57,234] - INFO - [vSphere VirtualMachine] Import of objects completed
[2014-11-03 07:45:57,234] - INFO - [vSphere Datastore] Importing objects to Zabbix
[2014-11-03 07:45:57,331] - INFO - [vSphere Datastore] Objects are in sync with Zabbix

Big thanks for your help.
Regards
Bodo

@dnaeon
Copy link
Owner

dnaeon commented Nov 3, 2014

Hey Bodo,

I think I see what the problem is.

In your API request to Zabbix for host creation for some reason one of the hostgroup of the VM to be created is null.

This is the portion of the request to Zabbix, which shows an incorrect group:

"groups": [{"groupid": "6"}, {"groupid": null}]

The {"groupid": null} shouldn't be there and it's presense means that there was no cluster found for the ESXi host where your VM runs.

Are you running the zabbix-vsphere-import tool against a vCenter or a standalone ESXi host?

Can you please comment lines 394 and 395 of the zabbix-vsphere-import tool and re-run the script again?

Let me know of the results when ready.

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

dnaeon commented Nov 3, 2014

Hey Bodo,

I've just pushed a fix for this issue in the latest zabbix-vsphere-import tool. Please grab the latest version of the tool and try it again:

42470df

Thanks,
Marin

@Satei
Copy link
Author

Satei commented Nov 3, 2014

Hello Marin

Yes that's it!
It works like a charm.

Thanks for the help!

Regards
Bodo

@dnaeon dnaeon closed this as completed Nov 3, 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