Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
integracion_de_telegram_en_alertas_de_zabbix [2016/05/12 17:13] 10.12.12.129 [Configuración en el Front] |
integracion_de_telegram_en_alertas_de_zabbix [2017/03/28 13:06] (actual) 10.12.12.129 |
||
|---|---|---|---|
| Línea 27: | Línea 27: | ||
| | | ||
| BotFather nos preguntará por el nombre y un subnombreque queremos darle al bot. | BotFather nos preguntará por el nombre y un subnombreque queremos darle al bot. | ||
| - | Éste tiene que acabar con la palabra bot. En nuestro caso hemos elegido Merkatu_bot | + | Éste tiene que acabar con la palabra bot. En nuestro caso hemos elegido zabbixmerkatu_bot |
| - | Merkatu_bot | + | zabbixmerkatu_bot |
| | | ||
| - | Cuando registre el nuevo bot, nos devolverá el token que utilizaremos para añadirlo a nuestro script de python que haremos en el servidor más tarde. (ejemplo el token que nos han dado para Merkatu_bot): | + | Cuando registre el nuevo bot, nos devolverá el token que utilizaremos para añadirlo a nuestro script de python que haremos en el servidor más tarde. (ejemplo el token que nos han dado para zabbixmerkatu_bot): |
| - | Use this token to access the HTTP API: 230299965:AAHRfFy24Zj4yE2KEbJ_OHvGsDnQo8smQH4 | + | Use this token to access the HTTP API: 348816857:AAFnvD017g6PhfbIkHkaNbSi1bCjstXTEFo |
| | | ||
| Podemos salir de la conversación con GodFather, ya tenemos el token. | Podemos salir de la conversación con GodFather, ya tenemos el token. | ||
| Línea 52: | Línea 52: | ||
| /cancel – Cancel the current operation. | /cancel – Cancel the current operation. | ||
| + | **IMPORTANTE: Hay que añadir al bot al grupo de chat y enviarle un mensaje** | ||
| ===== Configurar Zabbix Server ===== | ===== Configurar Zabbix Server ===== | ||
| Línea 91: | Línea 92: | ||
| #!/usr/bin/python3.4 #Le indicamos donde se encuentra el interprete de python | #!/usr/bin/python3.4 #Le indicamos donde se encuentra el interprete de python | ||
| import telebot,sys | import telebot,sys | ||
| - | BOT_TOKEN='158700146:AAHOPReqqTR8V7FXysa8mJCbQACUWSTBog8' #cambiamos por el nuestro | + | BOT_TOKEN='348816857:AAFnvD017g6PhfbIkHkaNbSi1bCjstXTEFo' #cambiamos por el nuestro |
| DESTINATION=sys.argv[1] #Este argumento lo programamos en el front como {ALERT.SENDTO} | DESTINATION=sys.argv[1] #Este argumento lo programamos en el front como {ALERT.SENDTO} | ||
| SUBJECT=sys.argv[2] #Este argumento lo programamos en el front como {ALERT.SUBJECT} | SUBJECT=sys.argv[2] #Este argumento lo programamos en el front como {ALERT.SUBJECT} | ||
| Línea 112: | Línea 113: | ||
| [[http://zabbix.merkatu.info:8888/zabbix]] | [[http://zabbix.merkatu.info:8888/zabbix]] | ||
| - | Vamos a la pestaña de Administration >> Media Types >> Create Media-type | + | Vamos a la pestaña de Administración >> Media Types >> Create Media-type |
| Name -> Le damos un nombre descriptivo | Name -> Le damos un nombre descriptivo | ||
| Línea 143: | Línea 144: | ||
| ===== Para conocer los ids de los grupos y usuarios de telegram ===== | ===== Para conocer los ids de los grupos y usuarios de telegram ===== | ||
| + | ==== UserID ==== | ||
| + | |||
| + | If you want to get a user id, send a message from this user to the bot. Reload the page and the user id will be shown. | ||
| + | |||
| + | Example: | ||
| + | |||
| + | "message":{"message_id":59,"from":{"id":9083329,"first_name":"Gabriel","last_name":"R F","username":"GabrielRF"},"chat":{"id":9083329,"first_name":"Gabriel","last_name":"R F","username":"GabrielRF","type":"private"},"date":1446911853,"text":"\/start"}}]} | ||
| + | |||
| + | In this case, the user id is 9083329. So, on the step Users, the field Send to would be 9083329. | ||
| + | |||
| + | ==== GroupID ==== | ||
| + | |||
| + | If you prefer to have your bot working on a group, then create the group and add the bot to it. Reload the page and you will see a message like: | ||
| + | |||
| + | "message":{"message_id":60,"from":{"id":9083329,"first_name":"Gabriel","last_name":"R F","username":"GabrielRF"},"chat":{"id":-57169325,"title":"q31231","type":"group"},"date":1446912067,"group_chat_created":true}},{"update_id":727527785, | ||
| + | In this case, the group id is -57169325. So, on the step Users, the field Send to would be -57169325. | ||
| + | |||
| + | Note that a group id is always negative. Only user's id are positive. | ||