zevilz / zabbix-alertscript-telegram

Script for sending Zabbix alerts via Telegram bot (including sending native Zabbix graphs)
MIT License
19 stars 2 forks source link

Can't get graph image #2

Closed alexanderek closed 1 year ago

alexanderek commented 1 year ago
[2023-04-01 13:32:39] Zabbix Telegram alertscript: [DEBUG] - Graphs enabled and graph data exists (graphData: graph:48830:1h:900; itemID: 48830; period: 1h; width: 900; height: )
[2023-04-01 13:32:39] Zabbix Telegram alertscript: [DEBUG] - current time: 1680345159; cookies expire time: 1682936924; cookies modify time: 1680344924; cookies lifetime: 30; auth needed: 1
[2023-04-01 13:32:39] Zabbix Telegram alertscript: [DEBUG] - Cookies expired. Trying re-auth.
[2023-04-01 13:32:40] Zabbix Telegram alertscript: [ERROR] - Can't get graph image: graph not a PNG or you have no access to graph (graphData: graph:48830:1h:900; itemID: 48830; graphID: 3123)
zevilz commented 1 year ago

You can log in to zabbix web interface (same user as in script) and follow the following link to check the graph: <zabbix_url>/chart2.php?graphid=3123&from=now-1h&to=now&profileIdx=web.graphs.filter&width=900

alexanderek commented 1 year ago

Hi @zevilz

Yes, I see the graph at the link: zabbix/chart2.php?graphid=3123&from=now1h&to=now&profileIdx=web.graphs.filter&width=900

123

But through the script, now I get the following messages in the debug log:

[2023-04-04 11:22:16] Zabbix Telegram alertscript: [DEBUG] - Graphs enabled and graph data exists (graphData: graph:3123:1h:900; itemID: 3123; period: 1h; width: 900; height: )
[2023-04-04 11:22:16] Zabbix Telegram alertscript: [DEBUG] - Graph not exists for this item (graphData: graph:3123:1h:900; itemID: 3123)
[2023-04-04 11:23:46] Zabbix Telegram alertscript: [DEBUG] - Graphs enabled and graph data exists (graphData: graph:3123:1h:900:300; itemID: 3123; period: 1h; width: 900; height: 300)
[2023-04-04 11:23:46] Zabbix Telegram alertscript: [DEBUG] - Graph not exists for this item (graphData: graph:3123:1h:900:300; itemID: 3123)

environment: Docker Image: Zabbix 6.0 Alpine 3.16 + I added the necessary packages: curl, jo, jq.

bash-5.1$ curl --version
curl 7.83.1 (x86_64-alpine-linux-musl) libcurl/7.83.1 OpenSSL/1.1.1t zlib/1.2.12 brotli/1.0.9 nghttp2/1.47.0
Release-Date: 2022-05-11
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets

bash-5.1$ jo -V
{"program":"jo","author":"Jan-Piet Mens","repo":"https://github.com/jpmens/jo","version":"1.6"}

bash-5.1$ jq -V
jq-master-v20220328-1108-g836ca403de
zevilz commented 1 year ago

@alexanderek, item ID not a graph ID. You check graph ID 3123 in browser and trying get graph for item 3123 :)

alexanderek commented 1 year ago

@zevilz Thanks for the tip, but now I'm back to the main issue:

[2023-04-04 12:34:28] Zabbix Telegram alertscript: [DEBUG] - Graphs enabled and graph data exists (graphData: graph:52604:1h:900; itemID: 52604; period: 1h; width: 900; height: )
[2023-04-04 12:34:28] Zabbix Telegram alertscript: [DEBUG] - current time: 1680600868; cookies expire time: 1683188399; cookies modify time: 1680596399; cookies lifetime: 60; auth needed: 1
[2023-04-04 12:34:28] Zabbix Telegram alertscript: [DEBUG] - Cookies expired. Trying re-auth.
[2023-04-04 12:34:29] Zabbix Telegram alertscript: [ERROR] - Can't get graph image: graph not a PNG or you have no access to graph (graphData: graph:52604:1h:900; itemID: 52604; graphID: 3578)
[2023-04-04 12:43:58] Zabbix Telegram alertscript: [DEBUG] - Graphs enabled and graph data exists (graphData: graph:48837:1h:900; itemID: 48837; period: 1h; width: 900; height: )
[2023-04-04 12:43:59] Zabbix Telegram alertscript: [DEBUG] - current time: 1680601438; cookies expire time: 1683192869; cookies modify time: 1680600869; cookies lifetime: 60; auth needed: 1
[2023-04-04 12:43:59] Zabbix Telegram alertscript: [DEBUG] - Cookies expired. Trying re-auth.
[2023-04-04 12:43:59] Zabbix Telegram alertscript: [ERROR] - Can't get graph image: graph not a PNG or you have no access to graph (graphData: graph:48837:1h:900; itemID: 48837; graphID: 3118)
[2023-04-04 12:44:52] Zabbix Telegram alertscript: [DEBUG] - Graphs enabled and graph data exists (graphData: graph:48830:1h:900; itemID: 48830; period: 1h; width: 900; height: )
[2023-04-04 12:44:53] Zabbix Telegram alertscript: [DEBUG] - current time: 1680601492; cookies expire time: 1683193439; cookies modify time: 1680601439; cookies lifetime: 60; auth needed: 0
[2023-04-04 12:44:53] Zabbix Telegram alertscript: [ERROR] - Can't get graph image: graph not a PNG or you have no access to graph (graphData: graph:48830:1h:900; itemID: 48830; graphID: 3123)
zevilz commented 1 year ago

@alexanderek, can you save file from browser on disk and show output for file <filename>

alexanderek commented 1 year ago
$ file chart2.php.png 

chart2.php.png: PNG image data, 1016 x 368, 8-bit/color RGB, non-interlaced
zevilz commented 1 year ago

@alexanderek, try to remove > /dev/null 2>/dev/null on 204 line and test sending on test mode in zabbix web interface.

alexanderek commented 1 year ago

@zevilz Fixed. There was no file utility in the container. Thanks for the help!