notifications.conf.tmpl 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ################################################################################
  2. # Notification commands #
  3. ################################################################################
  4. object NotificationCommand "telegram-notification-command" {
  5. import "plugin-notification-command"
  6. command = [ SysconfDir + "/icinga2/scripts/telegram-notification.py" ]
  7. env = {
  8. TELEGRAM_BOT_TOKEN = "{{ salt['pillar.get']('monitoring:private:telegram_bot_token') }}"
  9. TELEGRAM_CHAT_ID = "$user.vars.telegram_chat_id$"
  10. NOTIFICATION_TYPE = "$notification.type$"
  11. MESSAGE = "$telegram_message$"
  12. ACKNOWLEDGE_CALLBACK = "$acknowledge_callback$"
  13. }
  14. }
  15. object NotificationCommand "telegram-host-notification" {
  16. import "telegram-notification-command"
  17. vars.telegram_message = "$notification.type$ - $host.display_name$ is $host.state$"
  18. vars.acknowledge_callback = "HOST!$host.name$"
  19. }
  20. object NotificationCommand "telegram-service-notification" {
  21. import "telegram-notification-command"
  22. vars.telegram_message = "$notification.type$ $service.display_name$ auf $host.display_name$ $service.output$"
  23. vars.acknowledge_callback = "SERVICE!$host.name$!$service.name$"
  24. }
  25. ################################################################################
  26. # Notification Templates #
  27. ################################################################################
  28. template Notification "telegram-host-notification" {
  29. command = "telegram-host-notification"
  30. states = [ Up, Down ]
  31. types = [ Problem, Acknowledgement, Recovery, Custom,
  32. FlappingStart, FlappingEnd,
  33. ]
  34. period = "24x7"
  35. interval = 0
  36. }
  37. template Notification "telegram-service-notification" {
  38. command = "telegram-service-notification"
  39. states = [ OK, Warning, Critical, Unknown ]
  40. types = [ Problem, Acknowledgement, Recovery, Custom,
  41. FlappingStart, FlappingEnd,
  42. ]
  43. period = "24x7"
  44. interval = 0
  45. }
  46. ################################################################################
  47. # Notifications #
  48. ################################################################################
  49. apply Notification "notify_host_ffho_ops_by_telegram" to Host {
  50. import "telegram-host-notification"
  51. users = [ "ffho-ops" ]
  52. period = "24x7"
  53. times.begin = 3m
  54. assign where host.address
  55. }
  56. apply Notification "notify_service_ffho_ops_telegram" to Service {
  57. import "telegram-service-notification"
  58. users = [ "ffho-ops" ]
  59. period = "24x7"
  60. times.begin = 3m
  61. assign where host.address
  62. ignore where service.name == "apt-Updates"
  63. ignore where service.name == "libs"
  64. ignore where service.name == "running_kernel"
  65. ignore where service.name == "salt"
  66. }
  67. apply Notification "notify_host_ffho_dek_by_telegram" to Host {
  68. import "telegram-host-notification"
  69. users = [ "ffho-dek" ]
  70. period = "24x7"
  71. times.begin = 3m
  72. assign where host.vars.location.region.code == "ffho_dek"
  73. }
  74. apply Notification "notify_service_ffho_dek_telegram" to Service {
  75. import "telegram-service-notification"
  76. users = [ "ffho-dek" ]
  77. period = "24x7"
  78. times.begin = 3m
  79. assign where host.vars.location.region.code == "ffho_dek"
  80. ignore where service.name == "apt-Updates"
  81. ignore where service.name == "libs"
  82. ignore where service.name == "running_kernel"
  83. ignore where service.name == "salt"
  84. }