{ "info": { "author": "Max Rosin", "author_email": "git@hackrid.de", "bugtrack_url": null, "classifiers": [], "description": "# icinga2telegram\n\nicinga2telegram is a small Python script to send your [Icinga2](https://icinga.com) alerts to\nTelegram. It also adds emojis to your alerts to highlight the type and importance of the alert.\n(You can disable it with `--no-emojis`.)\n\n![Screenshot of icinga2telegram](screenshot.png)\n\n## Why Python instead of a simple Bash script?\nSeveral other people implemented Icinga2-Telegram notifications by writing a simple Bash\nscript. Most of the time this works but there are a few things I do not like about the\nBash solutions:\n\n1. They use two scripts with almost the same content.\n2. Bash can screw up really bad when your alert output contains special characters.\n3. The Bash solutions are based on environment variables. This does not work natively with\nIcinga2 director as it only supports arguments in command definitions.\n\nObviously the Python implementation has a bigger footprint than the Bash solution. It\nrequires a Python interpreter and installs several Python packages as dependencies. This\ncould be a problem for an embedded system with very limited resources but most Icinga2\ninstances run on powerful machines and the icinga2telegram footprint does not matter there.\nIn return you get a single maintainable and robust script that you can use for host and\nservice notifications.\n\n## Installation and Setup\n\n### Install icinga2telegram\nIt is recommended (but not required) to install icinga2telegram in a Python virtualenv.\n```\npip install icinga2telegram\n````\n\nRun `icinga2telegram --help` to see all available options.\n\n### Create a Telegram Bot\nYou need to create a Telegram bot by talking to the Botfather of Telegram. Please follow\nthe [official instructions](https://core.telegram.org/bots#creating-a-new-bot) and\ncopy your bot token. You will need it for the Icinga2 configuration.\n\n### Get your CHAT-ID\nNow you need to talk to your new bot because a bot can not start a new chat. Just open a\nchat with your bot and send a message. Afterwards you have to fetch the CHAT-ID of\nthe conversation between you and your bot. Replace TOKEN with your actual token.\n\n```\ncurl -s 'https://api.telegram.org/botTOKEN/getUpdates'\n```\n\nIf you have `jq` installed it is even simpler with:\n```\ncurl -s 'https://api.telegram.org/botTOKEN/getUpdates' | jq '.result[].message.chat'\n{\n \"id\": CHAT-ID,\n \"first_name\": \"Max\",\n \"username\": \"exampleuser\",\n \"type\": \"private\"\n}\n```\n\nCopy your CHAT-ID. You will need it for the Icinga2 configuration.\nIf you want to add more users everyone has to send a message to your bot and you need to\nextract the CHAT-IDs as shown above.\n(You can also invite your bot to groups but then you have to write a message like `@yourbot foo`\nto the group to send the message (with your CHAT-ID) to your bot.)\n\n\n## Icinga2 Example Configuration\n\nThis is just one way to use icinga2telegram for your notifications. Of course you can use another\nway to glue your users, CHAT-IDs and the actual notifications together.\n\n### User Definition with your CHAT-ID as a Variable\n```\nobject User \"max\" {\n display_name = \"Max\"\n enable_notifications = true\n vars.telegram_chat_id = \"CHAT-ID\"\n}\n```\n\n### Notification Definition for Hosts\n```\napply Notification \"Max (Host)\" to Host {\n command = \"icinga2telegram Host\"\n assign where host.address\n users = [ \"max\" ]\n}\n```\n\n### Notification Definition for Services\n```\napply Notification \"Max (Service)\" to Service {\n command = \"icinga2telegram Service\"\n assign where host.address\n users = [ \"max\" ]\n}\n\n```\n\n### Command Definition for Hosts\n```\nobject NotificationCommand \"icinga2telegram Host\" {\n import \"plugin-notification-command\"\n command = [ \"/opt/icinga2telegram/bin/icinga2telegram\" ]\n timeout = 1m\n arguments += {\n \"--address\" = \"$address$\"\n \"--chat\" = \"$user.vars.telegram_chat_id$\"\n \"--hostdisplayname\" = \"$host.display_name$\"\n \"--hostname\" = \"$host.name$\"\n \"--hostoutput\" = \"$host.output$\"\n \"--hoststate\" = \"$host.state$\"\n \"--icingaweb2url\" = \"https://monitoring.example.com/icingaweb2\"\n \"--notification-author\" = \"$notification.author$\"\n \"--notification-comment\" = \"$notification.comment$\"\n \"--notification-type\" = \"$notification.type$\"\n \"--time\" = \"$icinga.timet$\"\n \"--token\" = \"TOKEN\"\n }\n}\n```\n\n### Command Definition for Services\n```\nobject NotificationCommand \"icinga2telegram Service\" {\n import \"plugin-notification-command\"\n command = [ \"/opt/icinga2telegram/bin/icinga2telegram\" ]\n timeout = 1m\n arguments += {\n \"--address\" = \"$address$\"\n \"--chat\" = \"$user.vars.telegram_chat_id$\"\n \"--hostdisplayname\" = \"$host.display_name$\"\n \"--hostname\" = \"$host.name$\"\n \"--hostoutput\" = \"$host.output$\"\n \"--hoststate\" = \"$host.state$\"\n \"--icingaweb2url\" = \"https://monitoring.example.com/icingaweb2\"\n \"--notification-author\" = \"$notification.author$\"\n \"--notification-comment\" = \"$notification.comment$\"\n \"--notification-type\" = \"$notification.type$\"\n \"--servicedisplayname\" = \"$service.display_name$\"\n \"--servicename\" = \"$service.name$\"\n \"--serviceoutput\" = \"$service.output$\"\n \"--servicestate\" = \"$service.state$\"\n \"--time\" = \"$icinga.timet$\"\n \"--token\" = \"TOKEN\"\n }\n}\n```\n\n## License\n```\nSend your Icinga2 alerts to Telegram\nCopyright (C) 2018 Max Rosin\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ekeih/icinga2telegram", "keywords": "", "license": "LICENSE", "maintainer": "", "maintainer_email": "", "name": "icinga2telegram", "package_url": "https://pypi.org/project/icinga2telegram/", "platform": "", "project_url": "https://pypi.org/project/icinga2telegram/", "project_urls": { "Homepage": "https://github.com/ekeih/icinga2telegram" }, "release_url": "https://pypi.org/project/icinga2telegram/0.2.2/", "requires_dist": [ "Click", "emoji", "Jinja2", "python-telegram-bot" ], "requires_python": "", "summary": "Send your Icinga2 alerts to Telegram", "version": "0.2.2" }, "last_serial": 4603520, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "c3c18f7c622efc07667328bebd06e855", "sha256": "549fbb71239458447222cdeecf227642033d6c58835bfc5c0fb111b64319f80b" }, "downloads": -1, "filename": "icinga2telegram-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c3c18f7c622efc07667328bebd06e855", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15702, "upload_time": "2018-12-08T18:01:41", "url": "https://files.pythonhosted.org/packages/3d/1e/1130375fb0e8ab8dcdf12e11f14c5fd71eb2b8c3fb31894e310cf61f699d/icinga2telegram-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dd0188ae3816874c0f431abfcda3bf3c", "sha256": "263adf0f773e181cb57f20803a2de21e20be2d7ca8656d24d3c1d2826c76fbfd" }, "downloads": -1, "filename": "icinga2telegram-0.2.0.tar.gz", "has_sig": false, "md5_digest": "dd0188ae3816874c0f431abfcda3bf3c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2735, "upload_time": "2018-12-08T18:01:42", "url": "https://files.pythonhosted.org/packages/59/35/b30c9e7d1a88c16052b026d9c8c8f464b047f3e7ef552cb36e01bc40b96d/icinga2telegram-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "f060711ebe8232aec5040633af62596d", "sha256": "9eb67c0c2e61e8be6749f7023ddb31c186b5d6d236000e31a706d21d1e93d3d7" }, "downloads": -1, "filename": "icinga2telegram-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f060711ebe8232aec5040633af62596d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17819, "upload_time": "2018-12-15T19:51:18", "url": "https://files.pythonhosted.org/packages/84/9d/8b43180df45e1d804f01704fddcd23c6e7983d3e1ce7c49d1004f25058e4/icinga2telegram-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "94e7016bd6195aa9a2309b71326bbc8c", "sha256": "3cb4a2bc52182caf63ef04e3c916f187ffafca550271ffb2efe37b2518ab47fc" }, "downloads": -1, "filename": "icinga2telegram-0.2.1.tar.gz", "has_sig": false, "md5_digest": "94e7016bd6195aa9a2309b71326bbc8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5040, "upload_time": "2018-12-15T19:51:20", "url": "https://files.pythonhosted.org/packages/6c/dd/470dd40be3d568f80ad7abcec3aa48110488c3b61b60c62043381e07a97c/icinga2telegram-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "9cfdb8729fd6405fca6a7ef72b0e9853", "sha256": "3c0c80ad327857a5ad3a5bf23fa4398d84d0736052c57d86303bb0ffb4e548ea" }, "downloads": -1, "filename": "icinga2telegram-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9cfdb8729fd6405fca6a7ef72b0e9853", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17818, "upload_time": "2018-12-15T20:20:01", "url": "https://files.pythonhosted.org/packages/04/7a/1144d2d8a037e923c872f3ed456d7c96301f22f5bb91ee6277de8c1e4447/icinga2telegram-0.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d259b960fc5d9d8755ed79d14fd38c4", "sha256": "057902ce90cf8793124dd39c7d65d77d316ec0ed08941bc74a6512a5219f29f6" }, "downloads": -1, "filename": "icinga2telegram-0.2.2.tar.gz", "has_sig": false, "md5_digest": "5d259b960fc5d9d8755ed79d14fd38c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5040, "upload_time": "2018-12-15T20:20:02", "url": "https://files.pythonhosted.org/packages/68/a4/e0e23e09baa890700220d07542059591feedff550424abe2aecea5032bbb/icinga2telegram-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9cfdb8729fd6405fca6a7ef72b0e9853", "sha256": "3c0c80ad327857a5ad3a5bf23fa4398d84d0736052c57d86303bb0ffb4e548ea" }, "downloads": -1, "filename": "icinga2telegram-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9cfdb8729fd6405fca6a7ef72b0e9853", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17818, "upload_time": "2018-12-15T20:20:01", "url": "https://files.pythonhosted.org/packages/04/7a/1144d2d8a037e923c872f3ed456d7c96301f22f5bb91ee6277de8c1e4447/icinga2telegram-0.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d259b960fc5d9d8755ed79d14fd38c4", "sha256": "057902ce90cf8793124dd39c7d65d77d316ec0ed08941bc74a6512a5219f29f6" }, "downloads": -1, "filename": "icinga2telegram-0.2.2.tar.gz", "has_sig": false, "md5_digest": "5d259b960fc5d9d8755ed79d14fd38c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5040, "upload_time": "2018-12-15T20:20:02", "url": "https://files.pythonhosted.org/packages/68/a4/e0e23e09baa890700220d07542059591feedff550424abe2aecea5032bbb/icinga2telegram-0.2.2.tar.gz" } ] }