20171024000001_monit_integration.rb 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. class MonitIntegration < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.exists?(name: 'system_init_done')
  5. Setting.create_if_not_exists(
  6. title: 'Monit integration',
  7. name: 'monit_integration',
  8. area: 'Integration::Switch',
  9. description: 'Defines if Monit (https://mmonit.com/monit/) is enabled or not.',
  10. options: {
  11. form: [
  12. {
  13. display: '',
  14. null: true,
  15. name: 'monit_integration',
  16. tag: 'boolean',
  17. options: {
  18. true => 'yes',
  19. false => 'no',
  20. },
  21. },
  22. ],
  23. },
  24. state: false,
  25. preferences: {
  26. prio: 1,
  27. permission: ['admin.integration'],
  28. },
  29. frontend: false
  30. )
  31. Setting.create_if_not_exists(
  32. title: 'Sender',
  33. name: 'monit_sender',
  34. area: 'Integration::Monit',
  35. description: 'Defines the sender email address of the service emails.',
  36. options: {
  37. form: [
  38. {
  39. display: '',
  40. null: false,
  41. name: 'monit_sender',
  42. tag: 'input',
  43. placeholder: 'monit@monitoring.example.com',
  44. },
  45. ],
  46. },
  47. state: 'monit@monitoring.example.com',
  48. preferences: {
  49. prio: 2,
  50. permission: ['admin.integration'],
  51. },
  52. frontend: false,
  53. )
  54. Setting.create_if_not_exists(
  55. title: 'Auto close',
  56. name: 'monit_auto_close',
  57. area: 'Integration::Monit',
  58. description: 'Defines if tickets should be closed if service is recovered.',
  59. options: {
  60. form: [
  61. {
  62. display: '',
  63. null: true,
  64. name: 'monit_auto_close',
  65. tag: 'boolean',
  66. options: {
  67. true => 'yes',
  68. false => 'no',
  69. },
  70. translate: true,
  71. },
  72. ],
  73. },
  74. state: true,
  75. preferences: {
  76. prio: 3,
  77. permission: ['admin.integration'],
  78. },
  79. frontend: false
  80. )
  81. Setting.create_if_not_exists(
  82. title: 'Auto close state',
  83. name: 'monit_auto_close_state_id',
  84. area: 'Integration::Monit',
  85. description: 'Defines the state of auto closed tickets.',
  86. options: {
  87. form: [
  88. {
  89. display: '',
  90. null: false,
  91. name: 'monit_auto_close_state_id',
  92. tag: 'select',
  93. relation: 'TicketState',
  94. translate: true,
  95. },
  96. ],
  97. },
  98. state: 4,
  99. preferences: {
  100. prio: 4,
  101. permission: ['admin.integration'],
  102. },
  103. frontend: false
  104. )
  105. Setting.create_if_not_exists(
  106. title: 'Defines postmaster filter.',
  107. name: '5300_postmaster_filter_monit',
  108. area: 'Postmaster::PreFilter',
  109. description: 'Defines postmaster filter to manage Monit (https://mmonit.com/monit/) emails.',
  110. options: {},
  111. state: 'Channel::Filter::Monit',
  112. frontend: false
  113. )
  114. end
  115. end