New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notify-by-Telegram #1001
Comments
Thanks. I am not sure if this is the right place for such thing. I am using telegram myself and its basically a simple curl command to send the notification to the telegram api. |
@luxzg Can you please share me the bot code if possible.. You can share it on mohanveera.bolem@gmail.com |
@Mohan-veera oh sure, as sni said before, it's basically one-liner. But let me get to work, I'll make it a small how-to and post right here as an answer. It was just so long ago, wouldn't want to write anything misleading from the top of my head. Btw, setup was done 3 years ago and it's still going strong, nagging us on Telegram every day with some alert :) |
OK, this is based on my notes from 3 years ago, so it might have parts that have been modified by Telegram in the meantime. Likewise, it may get changed by Telegram at some point so... you know. GET BOTFirst, you need a Telegram bot.
GET TELEGRAM CHANNELNow that you have a bot, you also need a channel, since it's alerting, you probably want a private channel.
I've also made sure other members can't post to channel, to stop spam, to do that long-press each member one by one, Change permissions, and put all options to OFF GET TELEGRAM GROUP IDNow, as funny as my seem, open Telegram on your desktop PC's browser.
We need this 10-number ID (no letters), in all my group chats it is 10 numbers and starts with "1". Let's say it's MAKE SURE YOU HAVE IT ALLNow you have the only two important IDs needed for Telegram HTTP API:
CREATE BASH/CURL SCRIPTNow, depending on your version and such, the following paths may be different.
SETUP NOTIFICATION SERVICE IN THRUKWe need to setup at least one test device/service with notification service that will trigger this script, and forward our message from Thruk.
So now we have one command that handles host notifications, and one that handles service notifications, and those two are linked to the new Thruk contact.
These generic groups usually handle all the hosts and services by default, but you should check their That's it, you now have a blog post ;D If you get stuck feel free to type here, just as you've found this after 3 years maybe at least one other person (eventually) gets some use out of this :) |
@Mohan-veera - I forgot to mention few things:
If @sni or anyone else has better way to do some of these don't be shy 😁 |
@luxzg Thanks a lot for your doc which helps me to integrate the Thruk to the bot.... |
The notification script is run by naemon, but you can utilize thruk to get the performance graph. There is the "thruk graph" cli tool. |
Hmm, this seems like it shouldn't be all that hard to use and adapt for Telegram. I'll give it a try. Thank you sni! If I end up victorious I'll post additional instructions here :) |
Sorry @sni to bug you, but I can't figure out where is the correct binary or how to install this module. I've found and tried this and get the error as below for everything except
I've tried these other files, only 3 are executable:
These two have some errors:
or
And "post-update" one has no output for either --help or -V or anything I've tried, probably best I don't touch it :) I'd love to try the graphing tool with Telegram, and I've found the perl module (I guess) here: But I don't see any documentation about how to include it properly in my installation I use Ubuntu 18.04.4 and fairly old install of Thruk. Is it time to upgrade? :) Will it be included if I go with new version? EDIT: EDIT 2:
|
So, I have installed a separate Ubuntu and only installed thruk and it's dependencies.
And my production install has them here:
But I get this error as I mentioned in earlier comment:
I'm assuimng So I tried simply copying files to one of other included folders:
And now I get a different error:
So I'm fairly certain now that one of variables is pointing in wrong direction, and thus @sni should I open ticket on OMD GitHub for this to get fixed or am I doing something wrong? |
Additional progress, and new bumps on the road... I've installed make and other build essentials, cpanminus, and then added Now I get a new error:
Inside Config I've noticed this is happening if root is used, so I switched back to "monitoring" user. And finally!!
So to conclude what I had to do to get the
Output:
Now I have a new problem, though that could be related to my Kerberos auth setup for this server :-/
Quest continues... EDIT: after few more wourkarounds for authentication for localhost, hurray!!! It works! |
If you get errors about missing modules, then you are using the wrong user. All commands need to run as site user. |
Hm, it could be, I won't test now, since I finally got everything working. I'll assume having these modules twice won't hurt. I'm also pretty sure I tried with both root and "monitoring" (site user), but like I said, I spent too much time to go test that, as I'd need to uninstall everything and start again... Anyway thanks for reply, when I will be setting up next monitoring with OMD/Thruk and Telegram, I'll make sure to try. (Or on the next major update of the server). I've just finished setting up real production notifications on services, and it works really nice, thanks! Below is what I've done to go from text-only notifications to text+graph on Telegram. Telegram integration - WITH GRAPH IMAGES !
Test in CLI
Big thanks!To sni for making Thruk, and for pointing me in the right direction :) |
Just a quick look at how notifications look in mobile app. Tnx again! P.S. @Mohan-veera - if you want to try with images, now you can :) |
That's not a good idea, the script will be gone after the next omd upate. Copy it to the sites local/lib/...
|
Ah, thank you for the tips. I've had to move scripts manually on update from 3.20 to 4.60 to 5.10, but never actually lost them. But better safe than sorry, sure! And I'll keep |
I've created a script to acknowledge a |
To skip the long story...
I am making small bash script to enable notifications to Telegram (instant messenger). But I am no developer... pulling whole git repository to add one file and then make a pull request is 2 days of work for me to remind myself how it's done.
Is it ok for me to publish the code here in this feature request, and possibly to get this included in future releases?
Basic script is functional (see screenshot below), but I hope to add more features to it tomorrow.
I'm using "notify-by-email" to provide me general directions, and I hope to make it a complete drop-in replacement.
Screenshot of notifications sent by Telegram bot:
It would make me happy to provide any kind of contribution to this awesome project
The text was updated successfully, but these errors were encountered: