Closed seventhsite closed 1 year ago
And other error in 6.4 which I don't realise yet.
Can't get graph image: graph not a PNG or you have no access to graph (graphData: graph:45981:2h:900:300; itemID: 45981; graphID: 2608)
I tried to remove all parameters from script URL, but it doesn't help. I can open a graph https://zabbix.example.com/chart2.php?graphid=2608 and see the PNG image. In script I chaged line 204 to
/usr/bin/curl -s -b "$ZABBIX_COOKIES_PATH" -c "$ZABBIX_COOKIES_PATH" -L -H 'Content-Type: image/png' -o "$GRAPH_PATH" "${ZABBIX_URL}/chart2.php?graphid=${ZABBIX_GRAPH_ID}"
but still got this error.
@seventhsite i change deprecated parameter. Please, update the script and check second issue. Maybe it's related to the first issue.
@seventhsite i change deprecated parameter. Please, update the script and check second issue. Maybe it's related to the first issue.
Thank you for quick reaction! I changed the script on my side after I found the problem with user-username. But after it I gave the error about PNG. So, not - it is not related.
@seventhsite you log in with the same user as in the script when you check the chart in the browser? You have a utility file
in server? May you download graph from browser and check it by file
utility:
file image.png
@seventhsite try to remove > /dev/null 2>/dev/null
on 204 line and test sending on test mode in zabbix web interface.
Output is empty (only png error) even if I add -v to curl. Looks like somewhere else in script it forwarded to /dev/null.
I also tried
curl -v -s -b "/usr/lib/zabbix/alertscripts/zbx_cookies" -c "/usr/lib/zabbix/alertscripts/zbx_cookies" -L -H 'Content-Type: image/png' -o "/home/seventh/1.png" "https://zabbix.example.com/chart2.php?graphid=2608"
And got HTML document with error inside:
You are not logged in. You must login to view this page.
Maybe something wrong with cookies...
I tried in different ways, seem like cookie is ok. I think something changed in auth process in 6.4.
UPD: Maybe ZBXNEXT-8012 (Changes: user.checkAuthentication: added new parameter token)
@seventhsite error message not changed. You must disable deleting graph image in line 217 and check it (${GRAPHS_DIR}/graph_${ZABBIX_GRAPH_ID}_${CUR_TIME}.png
). You successfully authorized but graph not an image.
Output is empty (only png error) even if I add -v to curl. Looks like somewhere else in script it forwarded to /dev/null.
My bad. I waited for lines in log.
check what content in ZABBIX_WEB_AUTH var defined in line 186
I made echo $ZABBIX_WEB_AUTH >> $SCRIPT_LOG_PATH
on next line and see in log:
</html>nter>nginx/1.18.0</center>enter>d>
comment line 217 and check image in graph path
I also commented block at 390. So graphs images is the html files with auth request
Now I think about </html>nter>nginx/1.18.0</center>enter>d>
- looks like it is NGINX 403 Forbidden. I will research my NGINX config...
My logs now.
==> /var/log/zabbix/telegram_custom_script.log <==
[2023-04-30 12:31:44] Zabbix Telegram alertscript: [DEBUG] - current time: 1682850704; cookies expire time: 0; cookies modify time: 1682850693; cookies lifetime: 30; auth needed: 1
</html>nter>nginx/1.18.0</center>enter>d>
[2023-04-30 12:31:44] Zabbix Telegram alertscript: [ERROR] - Can't get graph image: graph not a PNG or you have no access to graph (graphData: graph:45981:2h:900:300; itemID: 45981; graphID: 2608)
[2023-04-30 12:31:45] Zabbix Telegram alertscript: [ERROR] - Can't send graph: Bad Request: IMAGE_PROCESS_FAILED (chatID: 196755136; subject: ; itemID: 45981; graphID: 2608)
I was right. I added
allow 127.0.0.1;
allow MY_SERVER_IP;
in few sections of nginx zabbix.conf (IDK which one is needed) and now it work!
Thank you!
Hi! Thank you for your script! I like it.
There is a problem in Zabbix 6.4.
Zabbix Telegram alertscript: [ERROR] - Can't get Zabbix API auth token: Invalid parameter "/": unexpected parameter "user".