Hi All,
Anyone expirience with the API dashboard.create? I'm trying to device a script to bring Zabbix 5 dashboards to Zabbix6.
When I run my script I get the following error and I have tried to fill the users array on several methods.
pyzabbix.api.ZabbixAPIException: {'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter "/1/users/1": an array is expected.', 'json': "{'jsonrpc': '2.0', 'method': 'dashboard.create', 'params': {'name': 'Control-M', 'pages': {'height': '3', 'name': '', 'type': 'hostavail', 'view_mode': '0', 'widgetid': '146', 'width': '6', 'x': '12', 'y': '0\\n'}, 'users': {'userid': '115', 'permission': '2\\n'}, 'userGroups': {'usrgrpid': '19', 'permission': '2\\n'}}, 'id': '1', 'auth': '********'}"}
Snippet of my (Python) script:
# Get the user(s) for the dashboard
def fill_user(dashid):
ufile=open('dashboard-users.txt','r')
for user in ufile:
uf=user.split(";")
# ua=[" "," "]
# if uf[0] == dashid:
# ua[0]=uf[1]
# ua[1]=uf[2]
# if ua[0] == ' ':
# ua[0]=1
# ua[1]=3
ua={
"userid": uf[1],
"permission": uf[2]
}
#pprint(ua)
ufile.close()
return ua
# Get the usergroup(s) for the dashboard
def fill_usergroup(dashid):
gfile=open('dashboard-usergroups.txt','r')
for grp in gfile:
g=grp.split(";")
# ga=[" "," "]
# if g[0] == dashid:
# ga[0]=g[1]
# ga[1]=g[2]
# if ga[0] == ' ':
# ga[0]=1
# ga[1]=3
ga={
"usrgrpid": g[1],
"permission": g[2]
}
#pprint(ga)
gfile.close()
return ga
# Make the new dashboard
def make_dashboard():
dashid=line[0]
name=line[1]
#userid=get_user(line[2])
userarr=fill_user(dashid)
usgarr=fill_usergroup(dashid)
pages=fill_pages(dashid)
did=zapi.dashboard.create(name=name,pages=pages,us ers=userarr,userGroups=usgarr)
Anyone expirience with the API dashboard.create? I'm trying to device a script to bring Zabbix 5 dashboards to Zabbix6.
When I run my script I get the following error and I have tried to fill the users array on several methods.
pyzabbix.api.ZabbixAPIException: {'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter "/1/users/1": an array is expected.', 'json': "{'jsonrpc': '2.0', 'method': 'dashboard.create', 'params': {'name': 'Control-M', 'pages': {'height': '3', 'name': '', 'type': 'hostavail', 'view_mode': '0', 'widgetid': '146', 'width': '6', 'x': '12', 'y': '0\\n'}, 'users': {'userid': '115', 'permission': '2\\n'}, 'userGroups': {'usrgrpid': '19', 'permission': '2\\n'}}, 'id': '1', 'auth': '********'}"}
Snippet of my (Python) script:
# Get the user(s) for the dashboard
def fill_user(dashid):
ufile=open('dashboard-users.txt','r')
for user in ufile:
uf=user.split(";")
# ua=[" "," "]
# if uf[0] == dashid:
# ua[0]=uf[1]
# ua[1]=uf[2]
# if ua[0] == ' ':
# ua[0]=1
# ua[1]=3
ua={
"userid": uf[1],
"permission": uf[2]
}
#pprint(ua)
ufile.close()
return ua
# Get the usergroup(s) for the dashboard
def fill_usergroup(dashid):
gfile=open('dashboard-usergroups.txt','r')
for grp in gfile:
g=grp.split(";")
# ga=[" "," "]
# if g[0] == dashid:
# ga[0]=g[1]
# ga[1]=g[2]
# if ga[0] == ' ':
# ga[0]=1
# ga[1]=3
ga={
"usrgrpid": g[1],
"permission": g[2]
}
#pprint(ga)
gfile.close()
return ga
# Make the new dashboard
def make_dashboard():
dashid=line[0]
name=line[1]
#userid=get_user(line[2])
userarr=fill_user(dashid)
usgarr=fill_usergroup(dashid)
pages=fill_pages(dashid)
did=zapi.dashboard.create(name=name,pages=pages,us ers=userarr,userGroups=usgarr)
Comment