Closed jurim76 closed 4 years ago
Seems like this issue already fixed in latest master commit. Please, try to update.
Updated from master branch, still get the same error
Traceback (most recent call last):
File "/etc/bareos/zabbix/zabbixexport.py", line 534, in
Please attach full command line.
Why do you run zabbix_export.py? There is only zabbix-export.py in repo.
Actually, this is the original zabbix-export.py script from your master branch, renamed to zabbix_export.py in my environment.
And the full command line is... ?
Actually there is only 526 lines in zabbix-export.py (not 534, like in zabbix_export.py), so your version is definitely changed from current master version. That can be the source of problems.
Yes, I've defined the static zabbix_username, password and url variables in script and turned info logging off. Here is the original script with arguments. md5sum /usr/local/bin/zabbix-export.py cfe7d336ed17c833a982902855515dfa /usr/local/bin/zabbix-export.py
/usr/local/bin/zabbix-export.py --zabbix-url https://zbx.*.net --zabbix-username zabbix -- zabbix-password **** --directory /var/tmp/zabbix
2020-01-17 20:59:14,895 INFO JSON-RPC Server Endpoint: https://zbx.*.net/api_jsonrpc.php
2020-01-17 20:59:14,915 INFO All files will be save in /var/tmp/zabbix
2020-01-17 20:59:14,923 INFO Convert all format to yaml
2020-01-17 20:59:14,923 INFO Start export XML part...
2020-01-17 20:59:14,923 INFO Export groups
2020-01-17 20:59:16,281 INFO Export hosts
2020-01-17 20:59:32,776 INFO Export templates
2020-01-17 20:59:38,267 INFO Export valueMaps
2020-01-17 20:59:39,130 INFO Export maps
2020-01-17 20:59:39,205 INFO Start export JSON part...
2020-01-17 20:59:39,205 INFO Processing mediatypes...
2020-01-17 20:59:39,217 INFO Processing images...
2020-01-17 20:59:39,263 INFO Processing usergroups...
2020-01-17 20:59:39,287 INFO Processing users...
2020-01-17 20:59:39,301 INFO Processing proxy...
2020-01-17 20:59:39,316 INFO Processing global macroses...
2020-01-17 20:59:39,327 INFO Processing maintenances...
2020-01-17 20:59:39,338 INFO Processing screens...
Traceback (most recent call last):
File "/usr/local/bin/zabbix-export.py", line 525, in
I can only guess that your zabbix instance is somewhat broken: some screen(s) doesn't have valid owner.
I'm not sure, but seems ok
mysql> select * from zabbix.users where userid=29\G 1. row userid: 29 alias: name: surname: passwd: url: autologin: 1 autologout: 0 lang: en_GB refresh: 30s type: 1 theme: default attempt_failed: 0 attempt_ip: attempt_clock: 0 rows_per_page: 50
mysql> select * from screens where userid=29\G 1. row screenid: 74 name: Transaction Monitoring hsize: 1 vsize: 5 templateid: NULL userid: 29 private: 1
Can you try this little patch:
--- a/zabbix-export.py
+++ b/zabbix-export.py
@@ -312,7 +312,7 @@ def main(zabbix_, save_yaml, directory, only="all"):
screens = zabbix_.screen.get(selectUsers='extend', selectUserGroups='extend', selectScreenItems='extend')
for screen in screens:
# resolve users/usergroups/screenitems:
- screen['userid'] = userid2user[screen['userid']]
+ screen['userid'] = userid2user[int(screen['userid'])]
screen['users'] = [{'permission': user['permission'], 'userid': userid2user[user['userid']]} for user in screen['users']]
screen['userGroups'] = [{"permission": group['permission'], "usrgrpid": usergroupid2usergroup[group['usrgrpid']]} for group in screen['userGroups']]
for si in screen['screenitems']:
?
The same error with a patch. There is only this screen in db now, no idea :(
2020-01-20 20:18:58,279 INFO Processing screens...
Traceback (most recent call last):
File "/etc/bareos/zabbix/zabbixexport.py", line 537, in
Ok, please try next patch (instead of previous patch). zabbix-review-export-3.txt
If it will not work out, please try to run following command (substitute yours values intead of asterisks):
/usr/local/bin/zabbix-export.py --debug --zabbix-url https://zbx.*.net --zabbix-username zabbix --
zabbix-password **** --directory /var/tmp/zabbix --only screens 2>&1 > ~/zabbix-review-export.txt
and attach file zabbix-review-export.txt here.
PLEASE NOTE: this debug file will contain SENSITIVE information (your zabbix URL/login/password) in plain text. Consider removing it with any text processing tools you like.
The problem was on my side, zabbix account for zabbix_export.py script (in my case - zabbix-backup account, from zabbix administrators group) should belong to screen's owner group also (zabbix users). Sorry to disturb you.
Zabbix v4.4.4
Unable to export any user's screen
Traceback (most recent call last): File "/etc/bareos/zabbix/zabbixexport.py", line 476, in
main(zabbix =zabbix_, save_yaml=args.save_yaml, directory=args.directory)
File "/etc/bareos/zabbix/zabbix_export.py", line 293, in main
screen['userid'] = userid2user[screen['userid']]
KeyError: '29'
or
KeyError: '33'...etc