zabbix-tooling / zabbix-ldap-sync

Sync Zabbix with LDAP directory server
BSD 3-Clause "New" or "Revised" License
50 stars 36 forks source link

--deleteorphans does not work without alldirusergroup #42

Closed teemus21 closed 2 years ago

teemus21 commented 2 years ago

When trying to use the older behavior of --delete-orphans without setting alldirusergroup, the script still attempts to create a group and fails:

(venv) root@host:~/zabbix-ldap-sync# /root/zabbix-ldap-sync/zabbix-ldap-sync --delete-orphans -f /root/zabbix-ldap-sync/zabbix-ldap.conf
2022-02-09 10:13:49 - INFO    - pyzabbix:68 - JSON-RPC Server Endpoint: https://1.2.3.4/api_jsonrpc.php
2022-02-09 10:13:49 - INFO    - pyzabbix:75 - Zabbix API version is: 5.4.1
2022-02-09 10:13:50 - INFO    - ZabbixConn:105 - Connected to Zabbix API Version 5.4.1
2022-02-09 10:13:50 - INFO    - ZabbixConn:406 - Creating Zabbix group None
Traceback (most recent call last):
  File "/root/zabbix-ldap-sync/zabbix-ldap-sync", line 115, in <module>
    main()
  File "/root/zabbix-ldap-sync/zabbix-ldap-sync", line 110, in main
    zabbix_conn.create_missing_groups()
  File "/root/zabbix-ldap-sync/lib/zabbixconn.py", line 408, in create_missing_groups
    grpid = self.create_group(eachGroup)
  File "/root/zabbix-ldap-sync/lib/zabbixconn.py", line 226, in create_group
    result = self.conn.usergroup.create(name=group)
  File "/root/zabbix-ldap-sync/venv/lib/python3.7/site-packages/pyzabbix/__init__.py", line 219, in fn
    args or kwargs
  File "/root/zabbix-ldap-sync/venv/lib/python3.7/site-packages/pyzabbix/__init__.py", line 196, in do_request
    raise ZabbixAPIException(msg, response_json['error']['code'], error=response_json['error'])
pyzabbix.ZabbixAPIException: ('Error -32602: Invalid params., Invalid parameter "/1/name": a character string is expected.', -32602)
scoopex commented 2 years ago

Hello @teemus21,

thanks for reporting. Can you attach a redacted version of you configuration file? Regards Marc

teemus21 commented 2 years ago

Here is a redacted config file.

zabbix-ldap.conf.txt

I run the script as follows:

/root/zabbix-ldap-sync/zabbix-ldap-sync -d -f /root/zabbix-ldap-sync/zabbix-ldap.conf

scoopex commented 2 years ago

I tested your scenario without success reproducing your problem. It seems I suppose your are not using the most recent release. Can you update, and recheck? Please repopen the issue, if your problem still remains....

teemus21 commented 2 years ago

I re-cloned the master branch, copied my config file and I'm still getting the same error:

./zabbix-ldap-sync -d -f /root/zabbix-ldap-sync/zabbix-ldap.conf
2022-02-19 11:23:37 - INFO    - ZabbixLDAPConf:42 - configuration for zabbix-ldap-sync release 0.13
2022-02-19 11:23:37 - INFO    - pyzabbix:68 - JSON-RPC Server Endpoint: https://1.2.3.4/api_jsonrpc.php
2022-02-19 11:23:37 - INFO    - pyzabbix:75 - Zabbix API version is: 5.4.1
2022-02-19 11:23:37 - INFO    - ZabbixConn:103 - Connected to Zabbix API Version 5.4.1
2022-02-19 11:23:37 - INFO    - ZabbixConn:404 - Creating Zabbix group None
Traceback (most recent call last):
  File "./zabbix-ldap-sync", line 115, in <module>
    main()
  File "./zabbix-ldap-sync", line 110, in main
    zabbix_conn.create_missing_groups()
  File "/root/zabbix-ldap-sync/lib/zabbixconn.py", line 406, in create_missing_groups
    grpid = self.create_group(eachGroup)
  File "/root/zabbix-ldap-sync/lib/zabbixconn.py", line 224, in create_group
    result = self.conn.usergroup.create(name=group)
  File "/root/zabbix-ldap-sync/venv/lib/python3.7/site-packages/pyzabbix/__init__.py", line 219, in fn
    args or kwargs
  File "/root/zabbix-ldap-sync/venv/lib/python3.7/site-packages/pyzabbix/__init__.py", line 196, in do_request
    raise ZabbixAPIException(msg, response_json['error']['code'], error=response_json['error'])
pyzabbix.ZabbixAPIException: ('Error -32602: Invalid params., Invalid parameter "/1/name": a character string is expected.', -32602)
scoopex commented 2 years ago

It seems i discovered and solved the the problem :-)