[ZBX-18645] Media type test failed - Telegram integration Created: 2020 Nov 13  Updated: 2020 Nov 17  Resolved: 2020 Nov 17

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 5.2.1
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Lubomir Spacek Assignee: Zabbix Support Team
Resolution: Won't fix Votes: 0
Labels: frontend
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian GNU/Linux 10. Zabbix has been instaled from deb packages.

Desired=Unknown/Install/Remove/Purge/Hold

Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
/ Name Version Architecture Description
+++====================================================================================================
ii zabbix-agent 1:5.2.1-1+debian10 amd64 Zabbix network monitoring solution - agent
un zabbix-frontend-php <none> <none> (no description available)
ii zabbix-get 1:5.2.1-1+debian10 amd64 Zabbix network monitoring solution - get
ii zabbix-js 1:5.2.1-1+debian10 amd64 Zabbix network monitoring solution - js
ii zabbix-sender 1:5.2.1-1+debian10 amd64 Zabbix network monitoring solution - sender
ii zabbix-server-mysql 1:5.2.1-1+debian10 amd64 Zabbix network monitoring solution - server (MySQL)
un zabbix-server-pgsql <none> <none> (no description available)

Attachments: PNG File Screenshot from 2020-11-12 17-45-34.png     PNG File Screenshot from 2020-11-16 16-02-08.png     PNG File Screenshot from 2020-11-17 01-47-09.png     PNG File Screenshot from 2020-11-17 01-47-17.png     PNG File image-2020-11-16-12-06-09-763.png     PNG File image-2020-11-16-12-07-15-908.png     PNG File image-2020-11-16-12-12-11-086.png     PNG File image-2020-11-16-17-30-45-339.png     PNG File image-2020-11-16-17-35-56-644.png    

 Description   

Steps to reproduce:

  1. Install template media_telegram.yaml 

Result:

  1. script test fail:
  • TypeError: undefined not callable (property 'log' of [object Object])
  • at [anon] (duktape.c:65639) internal
  • at [anon] (function:55) preventsyield

Expected:
See screenshot.



 Comments   
Comment by Lubomir Spacek [ 2020 Nov 16 ]

What does it take to run the script correctly? Is it necessary to install something? Any template? Next media types? 

 

```

script: |
var Telegram = {
token: null,
to: null,
message: null,
proxy: null,
parse_mode: null,

sendMessage: function() {
var params =

{ chat_id: Telegram.to, text: Telegram.message, disable_web_page_preview: true, disable_notification: false }

,
data,
response,
request = new HttpRequest(),
url = 'https://api.telegram.org/bot' + Telegram.token + '/sendMessage';

if (Telegram.parse_mode !== null)

{ params['parse_mode'] = Telegram.parse_mode; }

if (Telegram.proxy)

{ request.setProxy(Telegram.proxy); }

request.addHeader('Content-Type: application/json');
data = JSON.stringify(params);

// Remove replace() function if you want to see the exposed token in the log file.
Zabbix.log(4, '[Telegram Webhook] URL: ' + url.replace(Telegram.token, '<TOKEN>'));
Zabbix.log(4, '[Telegram Webhook] params: ' + data);
response = request.post(url, data);
Zabbix.log(4, '[Telegram Webhook] HTTP code: ' + request.getStatus());

try

{ response = JSON.parse(response); }

catch (error)

{ response = null; }

if (request.getStatus() !== 200 || typeof response.ok !== 'boolean' || response.ok !== true) {
if (typeof response.description === 'string')

{ throw response.description; }

else

{ throw 'Unknown error. Check debug log for more information.' }

}
}
}

try {
var params = JSON.parse(value);

if (typeof params.Token === 'undefined')

{ throw 'Incorrect value is given for parameter "Token": parameter is missing'; }

Telegram.token = params.Token;

if (params.HTTPProxy)

{ Telegram.proxy = params.HTTPProxy; }

if (['Markdown', 'HTML', 'MarkdownV2'].indexOf(params.ParseMode) !== -1)

{ Telegram.parse_mode = params.ParseMode; }

Telegram.to = params.To;
Telegram.message = params.Subject + '\n' + params.Message;
Telegram.sendMessage();

return 'OK';
}
catch (error)

{ Zabbix.log(4, '[Telegram Webhook] notification failed: ' + error); throw 'Sending failed: ' + error + '.'; }

```

Comment by Aleksandrs Pahomovs [ 2020 Nov 16 ]

Good day,

Please try to use Administration -> Media types -> Telegram

Press button Test and use settings like mine: 

You can use mine ids and tokens for test purposes.

To: -249182871

Token:  1440084741:AAH2MHIzD7Wr-6-KeX-sKA9DpOs6LfoDIC4

It's working fine on:
zabbix@ubuntu20:~$ docker exec -it 56ca0ebda379 mysql -V
mysql Ver 8.0.22-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
zabbix@ubuntu20:~$ docker exec -it 56ca0ebda379 cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"

 

 

Comment by Lubomir Spacek [ 2020 Nov 17 ]

Same result.

Comment by Lubomir Spacek [ 2020 Nov 17 ]

May be, I will be must reinstall server from start point. I use zabbix from any version 2 (I think) and I do update this only from deb packages over couple years. Maybe it is time to do it.  I monioring over 300 hosts and 23000 items. So, if there is no any chance

Comment by Aleksandrs Pahomovs [ 2020 Nov 17 ]

Please be advised that this section of the tracker is for bug reports only. The case you have submitted can not be qualified as one, so please reach out to [email protected] for commercial support or consultancy services. Alternatively, you can also use our IRC channel or community forum (https://www.zabbix.com/forum) for assistance. With that said, we are closing this ticket. Thank you for understanding.

Generated at Sat Apr 19 01:19:08 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.