I
I
Ivan Safonov2018-01-12 22:36:07
Python
Ivan Safonov, 2018-01-12 22:36:07

How to save zabbix graph using python?

Good day.
Using only ZabbixAPI, it is impossible to get a graph as a picture. A lot of charts need to be uploaded.
There was a way out, to generate a unique link for each chart, but in addition to such an ingenious solution, there was also a problem.
The link looks like this: https://myhost/zabbix/chart2.php?graphid=26076&per...
This is an image. If you open it in a browser, then right-click -> save image as... -> voila we have a .png file.
But unfortunately I can’t understand how to implement this action using Python =(
I ask for help from experienced colleagues, I can’t even understand how to google =(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2018-01-12
@dimonchik2013

selenium if you really want to
, but it's better to get an array of data and build graphs independently - then the data can be processed

D
Dmitry Zhig, 2020-11-01
@DiZHI

1 . If when outputting
res = request.get('***********')
print(res.content)
an error page is displayed, then -
data_api = {"name": 'login', "password" : 'password', "enter": "Sign in"}
req_cookie = requests.post('***************' + "/", data=data_api)
cookie = req_cookie.cookies
res = request.get('***************', cookies=cookie)
2 . If bytes are output, for example b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x06r\x00\x00\, then
b = open('Path to the image we save data', 'wb')
b.write(res.content)
Total :
data_api = {"name": 'login', "password":
cookie = req_cookie.cookies
res = request.get('******************', cookies=cookie)
b = open('Path to the image where we will save the data', 'wb ')
b.write(res.content)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question