Sending image in telegram.sh

Hi,

I’m modifying the default telegram.sh to send and image of the graph related with the service failing just after sending the default message.
When I put and static path of a PNG image the script works fine.

My error comes when I try to get the service graph automatically. I send a curl to download the PNG in a temp directory but what I get is a “Invalid user input” error message.

The curl I use to autheticate and download the graph is:

curl -s -o $GRAPH_PATH "https://SERVER_IP/SITE/check_mk/graph_image.py" -d "@payload.json" -H "Authorization: Bearer username password"

How can I get that image? Which is the rigth way to authenticate?

Thanks in advance :slight_smile:

Hello,
I found this discussion very helpful: Direktlink zu den neuen 2.0 Graphen? - #2 by Norm

I followed the steps and then found the URL to the png image. When I access this one with curl it just worked fine.

curl "http://<server>/checkmk/check_mk/graph_image.py?request=%7B%22specification%22%3A%5B%22template%22%2C%7B%22site%22%3A%22checkmk%22%2C%22host_name%22%3A%22My-Host-2%22%2C%22service_description%22%3A%22Check_MK%22%2C%22graph_index%22%3A0%2C%22graph_id%22%3A%22cmk_cpu_time_by_phase%22%7D%5D%2C%22data_range%22%3A%7B%22time_range%22%3A%5B1707210990.8852692%2C1707213830.8852692%5D%2C%22step%22%3A5.142857142857143%2C%22vertical_range%22%3Anull%7D%7D" -H "Authorization: Bearer username password"
2 Likes

Hi @rons4,

BIG THANKS! :slight_smile:
Thanks to your answer I have realized that I was sending some characters badly encoded. Now it works!
Your example works perfectly as well.

1 Like