The following warnings occurred:
Warning [2] Undefined array key "lockoutexpiry" - Line: 94 - File: global.php PHP 8.1.17 (Linux)
File Line Function
/global.php 94 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "lockoutexpiry" - Line: 573 - File: global.php PHP 8.1.17 (Linux)
File Line Function
/global.php 573 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $can_access_moderationqueue - Line: 749 - File: global.php PHP 8.1.17 (Linux)
File Line Function
/global.php 749 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 889 - File: global.php PHP 8.1.17 (Linux)
File Line Function
/global.php 889 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 889 - File: global.php PHP 8.1.17 (Linux)
File Line Function
/global.php 889 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $unreadreports - Line: 45 - File: global.php(956) : eval()'d code PHP 8.1.17 (Linux)
File Line Function
/global.php(956) : eval()'d code 45 errorHandler->error
/global.php 956 eval
/printthread.php 16 require_once
Warning [2] Undefined variable $awaitingusers - Line: 47 - File: global.php(956) : eval()'d code PHP 8.1.17 (Linux)
File Line Function
/global.php(956) : eval()'d code 47 errorHandler->error
/global.php 956 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 1021 - File: global.php PHP 8.1.17 (Linux)
File Line Function
/global.php 1021 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5196 - File: inc/functions.php PHP 8.1.17 (Linux)
File Line Function
/inc/functions.php 5196 errorHandler->error
/global.php 1021 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(257) : eval()'d code PHP 8.1.17 (Linux)
File Line Function
/printthread.php(257) : eval()'d code 2 errorHandler->error
/printthread.php 257 eval
/printthread.php 117 printthread_multipage
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined variable $nofollow - Line: 1 - File: inc/class_parser.php(1138) : eval()'d code PHP 8.1.17 (Linux)
File Line Function
/inc/class_parser.php(1138) : eval()'d code 1 errorHandler->error
/inc/class_parser.php 1138 eval
/inc/class_parser.php 1154 postParser->mycode_parse_url
[PHP]   postParser->mycode_parse_url_callback1
/inc/class_parser.php 491 preg_replace_callback
/inc/class_parser.php 201 postParser->parse_mycode
/printthread.php 179 postParser->parse_message
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined variable $nofollow - Line: 1 - File: inc/class_parser.php(1138) : eval()'d code PHP 8.1.17 (Linux)
File Line Function
/inc/class_parser.php(1138) : eval()'d code 1 errorHandler->error
/inc/class_parser.php 1138 eval
/inc/class_parser.php 1644 postParser->mycode_parse_url
[PHP]   postParser->mycode_auto_url_callback
/inc/class_parser.php 1597 preg_replace_callback
/inc/class_parser.php 524 postParser->mycode_auto_url
/inc/class_parser.php 201 postParser->parse_mycode
/printthread.php 179 postParser->parse_message
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined variable $nofollow - Line: 1 - File: inc/class_parser.php(1138) : eval()'d code PHP 8.1.17 (Linux)
File Line Function
/inc/class_parser.php(1138) : eval()'d code 1 errorHandler->error
/inc/class_parser.php 1138 eval
/inc/class_parser.php 1644 postParser->mycode_parse_url
[PHP]   postParser->mycode_auto_url_callback
/inc/class_parser.php 1597 preg_replace_callback
/inc/class_parser.php 524 postParser->mycode_auto_url
/inc/class_parser.php 201 postParser->parse_mycode
/printthread.php 179 postParser->parse_message
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.17 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined variable $nofollow - Line: 1 - File: inc/class_parser.php(1138) : eval()'d code PHP 8.1.17 (Linux)
File Line Function
/inc/class_parser.php(1138) : eval()'d code 1 errorHandler->error
/inc/class_parser.php 1138 eval
/inc/class_parser.php 1154 postParser->mycode_parse_url
[PHP]   postParser->mycode_parse_url_callback1
/inc/class_parser.php 491 preg_replace_callback
/inc/class_parser.php 201 postParser->parse_mycode
/printthread.php 179 postParser->parse_message



Category5.TV Community Forum
Telegram Push notifications - Printable Version

+- Category5.TV Community Forum (https://forum.category5.tv)
+-- Forum: NEMS - Nagios Enterprise Monitoring Server (https://forum.category5.tv/forum-8.html)
+--- Forum: User Contributions (https://forum.category5.tv/forum-44.html)
+--- Thread: Telegram Push notifications (/thread-96.html)

Pages: 1 2 3 4 5 6


Telegram Push notifications - baggins - 10-20-2017

Hi,

In another project I use Telegram to receive push notifications on my phone so I thought it would be nice to have the same in NEMS.
It is actually quite simple to set this up.

For those interested, here are the steps:

1) Get a Telegram account (it is free!): https://telegram.org/
After setting up your account you will have a bot and a chat id.

2) install lua-sec (this will also install lua-socket):


Code:
sudo apt-get install lua-sec


3) Install the following script in /usr/local/bin:
Name the script 'telegram_nems.lua'
This is a simple lua script I wrote just to get this working, so it is really minimal without error checking etc...


Code:
#!/usr/bin/lua
https = require('ssl.https')
local telegram_url = 'https://api.telegram.org/<your bot>/sendMessage?'
local chat_id = '<your chat id>'

     Notification = "Notification Type: " .. arg[1] ..'\n'    --$NOTIFICATIONTYPE$
     Host = "Host: " .. arg[2] ..'\n'                         --$HOSTNAME$
     State = "State: " .. arg[3] ..'\n'                       --$HOSTSTATE$/$SERVICESTATE$
     Address = "Address: " .. arg[4] ..'\n'                   --$HOSTADDRESS$
     Info = "Info: "  .. arg[5] ..'\n'                        --$HOSTOUTPUT$/"$SERVICEOUTPUT$"
     Date_Time = "Date/Time: " .. arg[6] ..'\n'               --$LONGDATETIME$
   if (#arg == 6) then
     message = '***** Nagios ***** ' ..'\n' ..'\n' .. Notification .. Host ..State .. Address .. Info .. Date_Time
   else
     Service = "Service: " .. arg[7] .. '\n'                  --$SERVICEDESC$
     message = '***** Nagios ***** ' ..'\n' ..'\n' .. Notification .. Host  .. Service ..State .. Address .. Info .. Date_Time
   end

local data_str = 'chat_id=' .. chat_id .. '&text=' .. message..''  
local res, code, headers, status = https.request(telegram_url, data_str)

4) In NConf, add the following to Misccommands:

Code:
command_name                          notify-host-by-telegram
command_line                          /usr/local/bin/telegram_nems.lua "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTSTATE$" "$HOSTADDRESS$" "$HOSTOUTPUT$" "$LONGDATETIME$"


Code:
command_name                          notify-service-by-telegram
command_line                          /usr/local/bin/telegram_nems.lua "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$SERVICESTATE$" "$HOSTADDRESS$" "$SERVICEOUTPUT$" "$LONGDATETIME$" "$SERVICEDESC$"

As usual: use at your own risk!


RE: Telegram Push notifications - Robbie Ferguson - 10-20-2017

Wow baggins - am I reading this right? You can use this to get push notifications from NEMS to your phone?

I love it! And I appreciate your sharing the code.

Cool to include this in NEMS 1.3?


RE: Telegram Push notifications - baggins - 10-20-2017

I have the messages on both my iPhone and iPad [Image: smile.gif]

The script needs some polishing, but feel free to include it in 1.3.

I'm glad being able to contribute to the fine work that you have done with NEMS!


RE: Telegram Push notifications - Robbie Ferguson - 10-23-2017

Awesome-- thanks!

If you make any "polishing" changes to it, please post here. I'll probably be feature locked within the next week or so... so if you want to fix anything up, this'd be the best time to get that in before 1.3.

Cheers,
Robbie


RE: Telegram Push notifications - Robbie Ferguson - 10-23-2017

Your commands made it into NEMS 1.3! https://docs.nemslinux.com/changelog_1.3

Congratulations, and thanks again for your contribution.


RE: Telegram Push notifications - Robbie Ferguson - 10-25-2017

Added to NEMS Docs - https://docs.nemslinux.com/usage/notify-host-by-telegram


RE: Telegram Push notifications - Robbie Ferguson - 10-25-2017

baggins, I'm in the process of setting up my test system and writing the documentation for this, but can't figure out where the Chat ID and Bot ID are located within the app. Can you please clarify the steps from a freshly-activated Telegram account to obtain these two credentials?

Thanks!


RE: Telegram Push notifications - Kaganishu - 10-26-2018

Hi Robbie, do you have solved your issue? Regards


RE: Telegram Push notifications - Robbie Ferguson - 10-26-2018

Hi Kaganishu. This is an old bug report. I thought it had been addressed. Are you experiencing the same issue?


RE: Telegram Push notifications - Kaganishu - 10-27-2018

Hi again, you're referring to documentation's page https://docs.nemslinux.com/usage/notify-host-by-telegram?