{"id":1475,"date":"2020-03-19T21:02:00","date_gmt":"2020-03-20T00:02:00","guid":{"rendered":"http:\/\/wordpress.jpcorp.eti.br\/?p=1475"},"modified":"2021-12-26T12:29:10","modified_gmt":"2021-12-26T15:29:10","slug":"zabbix-media-types-zoho-cliq-messages","status":"publish","type":"post","link":"https:\/\/wordpress.jpcorp.eti.br\/?p=1475","title":{"rendered":"Zabbix &#8211; Media types Zoho Cliq Messages"},"content":{"rendered":"<h3>Git do script<\/h3>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/github.com\/jhonespetter8\/zabbix-sendzohomessage\">https:\/\/github.com\/jhonespetter8\/zabbix-sendzohomessage<\/a><\/p>\n<p style=\"text-align: justify;\">Abaixo o post que fiz sobre funcionamento para telegram, no git acima tem a documenta\u00e7\u00e3o do Zoho sobre identificar o nome e api do canal ou bot, porem as configura\u00e7\u00f5es do uso que efetuei nos script para utilizar no Zabbix \u00e9 equivalente para telegram, portanto abaixo para um embasamento. (\u00c9 n\u00e3o estou afim de documentar bonitinho, me DES-CUL-PA!)<\/p>\n<p>&nbsp;<\/p>\n<h3>OPAAA 30\/04\/2020 entrou no escopo da Zabbix como integra\u00e7\u00e3o com Zoho:<\/h3>\n<p><a href=\"https:\/\/www.zabbix.com\/integrations\/zoho\">https:\/\/www.zabbix.com\/integrations\/zoho<\/a><\/p>\n<p><a href=\"http:\/\/wordpress.jpcorp.eti.br\/?attachment_id=1480\" rel=\"attachment wp-att-1480\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1480\" src=\"http:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2020\/03\/zabbixzoho.png\" alt=\"\" width=\"1267\" height=\"584\" srcset=\"https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2020\/03\/zabbixzoho.png 1267w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2020\/03\/zabbixzoho-300x138.png 300w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2020\/03\/zabbixzoho-644x297.png 644w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2020\/03\/zabbixzoho-768x354.png 768w\" sizes=\"auto, (max-width: 1267px) 100vw, 1267px\" \/><\/a><\/p>\n<hr \/>\n<h3>1 - Preparar ambiente no CentOS 7<\/h3>\n<p style=\"text-align: justify;\">Abaixo a instala\u00e7\u00e3o dos pacotes necess\u00e1rios e os m\u00f3dulos do Python, cria\u00e7\u00e3o do Script para envio das mensagens, se atente em alterar 'CHAVE_API_GERADA_NO_TELEGRAM' com a chave que ser\u00e1 gerada no Telegram e ativar o parametro AlertScripts no \"zabbix_server.conf\".<\/p>\n<p style=\"text-align: left;\">GitHub do projeto pyTelegramBotAPI:\u00a0<a href=\"https:\/\/github.com\/eternnoir\/pyTelegramBotAPI.git\">https:\/\/github.com\/eternnoir\/pyTelegramBotAPI.git<\/a><\/p>\n<pre class=\"lang:sh decode:true \">[root@zabbix]# yum -y install python-pip git python python-devel\r\n[root@zabbix]# pip install pyTelegramBotAPI pyopenssl ndg-httpsclient pyasn1 gcc make openssl-devel\r\n[root@zabbix]# git clone https:\/\/github.com\/eternnoir\/pyTelegramBotAPI.git\r\n[root@zabbix]# cd pyTelegramBotAPI\r\n[root@zabbix]# python setup.py install\r\n[root@zabbix]# mkdir \/usr\/lib\/zabbix\/alertscripts\r\n[root@zabbix]# vim \/usr\/lib\/zabbix\/alertscripts\/telegram.py\r\n\t#!\/usr\/bin\/env python\r\n\t\r\n\timport telebot,sys\r\n\t\r\n\tBOT_TOKEN='CHAVE_API_GERADA_NO_TELEGRAM'\r\n\tDESTINATION=sys.argv[1]\r\n\tSUBJECT=sys.argv[2]\r\n\tMESSAGE=sys.argv[3]\r\n\t\r\n\tMESSAGE = MESSAGE.replace('\/n','\\n')\r\n\t\r\n\ttb = telebot.TeleBot(BOT_TOKEN)\r\n\ttb.send_message(DESTINATION,SUBJECT + '\\n' + MESSAGE)\r\n\r\n[root@zabbix]# chown -R zabbix.zabbix \/usr\/lib\/zabbix\/alertscripts\r\n[root@zabbix]# chmod +x \/usr\/lib\/zabbix\/alertscripts\/telegram.py\r\n[root@zabbix]# grep AlertScripts \/etc\/zabbix\/zabbix_server.conf\r\n\tAlertScriptsPath=\/usr\/lib\/zabbix\/alertscripts\r\n<\/pre>\n<h3>2 - Criar Bot no Telegram<\/h3>\n<p style=\"text-align: justify;\">No seu Telegram adicione o @BotFather e entre com \"\/newbot\" para cria\u00e7\u00e3o do Bot, abaixo imagem:<\/p>\n<p style=\"text-align: justify;\">Ap\u00f3s cria\u00e7\u00e3o do Bot, crie um grupo e adicione ele, lembrando que o username \u00e9 a identifica\u00e7\u00e3o no caso acima \"zabbix_jp_bot\". E tamb\u00e9m altere no arquivo \"\/usr\/lib\/zabbix\/alertscripts\/telegram.py\" a Chave API.<\/p>\n<p>&nbsp;<\/p>\n<h3>3 - Identificar ID dos Grupos<\/h3>\n<p style=\"text-align: justify;\">Para identificar os Grupos do Telegram entre no link abaixo colocando a sua chave API, com isso voc\u00ea ir\u00e1 ver as conversar e identificar o ID do grupo, normalmente os ID de Grupos iniciam com \"-NUMERO\", abaixo um exemplo como ira encontrar na tela:<\/p>\n<blockquote><p><a href=\"https:\/\/api.telegram.org\/bot'CHAVE_API_GERADA_NO_TELEGRAM'\/getUpdates\">https:\/\/api.telegram.org\/botCHAVE_API_GERADA_NO_TELEGRAM\/getUpdates<\/a><\/p><\/blockquote>\n<h3><a href=\"http:\/\/wordpress.jpcorp.eti.br\/?attachment_id=483\" rel=\"attachment wp-att-483\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-483\" src=\"http:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/chat.png\" alt=\"chat\" width=\"199\" height=\"28\" \/><\/a>4 - Testar pelo terminal<\/h3>\n<p style=\"text-align: justify;\">Para testar no terminal execute o comando chamando o \"ID_GRUPO ASSUNTO MENSAGEM\":<\/p>\n<pre class=\"lang:sh decode:true \">[root@zabbix]# python \/usr\/lib\/zabbix\/alertscripts\/telegram.py -123456789 ASSUNTO MENSAGEM<\/pre>\n<h3>5 - Criar estrutura no Zabbix<\/h3>\n<p style=\"text-align: justify;\">Criar M\u00eddia types:<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/wordpress.jpcorp.eti.br\/?attachment_id=485\" rel=\"attachment wp-att-484\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-485 size-full\" src=\"http:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/media-types-telegram-1.png\" width=\"666\" height=\"407\" srcset=\"https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/media-types-telegram-1.png 666w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/media-types-telegram-1-300x183.png 300w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/media-types-telegram-1-644x394.png 644w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/a>Adicionar M\u00eddia para o usu\u00e1rio, abaixo pode ver que no campo \"Send To\" \u00e9 colocado o grupo do Telegram:<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/wordpress.jpcorp.eti.br\/?attachment_id=487\" rel=\"attachment wp-att-487\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-487\" src=\"http:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/user-media.png\" alt=\"user-media\" width=\"526\" height=\"354\" srcset=\"https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/user-media.png 526w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/user-media-300x202.png 300w\" sizes=\"auto, (max-width: 526px) 100vw, 526px\" \/><\/a>Adicionar a M\u00eddia na A\u00e7\u00e3o:<\/p>\n<h3><a href=\"http:\/\/wordpress.jpcorp.eti.br\/?attachment_id=488\" rel=\"attachment wp-att-488\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-488\" src=\"http:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/action-telegram-1.png\" alt=\"action-telegram\" width=\"896\" height=\"544\" srcset=\"https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/action-telegram-1.png 896w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/action-telegram-1-300x182.png 300w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/action-telegram-1-768x466.png 768w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/action-telegram-1-644x391.png 644w\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><\/a>6 - Valida\u00e7\u00e3o, agora basta gerar o gatilho para teste<\/h3>\n<p><a href=\"http:\/\/wordpress.jpcorp.eti.br\/?attachment_id=489\" rel=\"attachment wp-att-489\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-489\" src=\"http:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/telegram.png\" alt=\"telegram\" width=\"686\" height=\"685\" srcset=\"https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/telegram.png 686w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/telegram-150x150.png 150w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/telegram-300x300.png 300w, https:\/\/wordpress.jpcorp.eti.br\/wp-content\/uploads\/2016\/07\/telegram-644x643.png 644w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git do script https:\/\/github.com\/jhonespetter8\/zabbix-sendzohomessage Abaixo o post que fiz sobre funcionamento para telegram, no git acima tem a documenta\u00e7\u00e3o do Zoho sobre identificar o nome e api do canal ou bot, porem as configura\u00e7\u00f5es do uso que efetuei nos script para utilizar no Zabbix \u00e9 equivalente para telegram, portanto abaixo para um embasamento. (\u00c9 n\u00e3o&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[50,41,192],"class_list":["post-1475","post","type-post","status-publish","format-standard","hentry","category-zabbix","tag-python","tag-zabbix","tag-zoho"],"_links":{"self":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/1475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1475"}],"version-history":[{"count":3,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/1475\/revisions"}],"predecessor-version":[{"id":1481,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/1475\/revisions\/1481"}],"wp:attachment":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}