checks.tf 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. locals {
  2. splunk_hot = var.environment == "test" ? "10000" : "50000"
  3. #interconnect-0 = var.environment == "test" ? ["169.254.230.197", "169.254.142.233", "169.254.221.229", "169.254.145.141"] : ["169.254.152.217", "169.254.88.105", "169.254.253.45", "169.254.91.129"]
  4. #interconnect-1 = var.environment == "test" ? ["169.254.186.189", "169.254.119.73", "169.254.20.161", "169.254.128.189"] : ["169.254.247.157", "169.254.246.157", "169.254.22.21", "169.254.38.13"]
  5. dns_checks_all = var.environment == "test" ? {
  6. "dnstest.accenturefederalcyber.com": "203.0.113.1",
  7. "dnstest.xdrtest.accenturefederalcyber.com": "203.0.113.1",
  8. } : {
  9. "dnstest.accenturefederalcyber.com": "203.0.113.1",
  10. "dnstest.xdr.accenturefederalcyber.com": "203.0.113.1",
  11. }
  12. dns_checks_private = var.environment == "test" ? {
  13. "dnstest.pvt.xdrtest.accenturefederalcyber.com": "10.10.10.10",
  14. "10.10.10.10": "dnstest.pvt.xdrtest.accenturefederalcyber.com.",
  15. } : {
  16. "dnstest.pvt.xdr.accenturefederalcyber.com": "10.10.10.10",
  17. "10.10.10.10": "dnstest.pvt.xdr.accenturefederalcyber.com.",
  18. }
  19. # To ensure this list is complete:
  20. # salt \* grains.get partitions | grep "^ /" | sort | uniq | grep -v snap
  21. disk_thresholds = {
  22. "/root": "1000", # This is the / partition
  23. "/boot": "20%",
  24. "/home": "20%",
  25. "/opt": "20%",
  26. "/tmp": "20%",
  27. "/var": "20%",
  28. "/var/log": "20%"
  29. "/var/log/audit": "20%",
  30. "/var/tmp": "20%",
  31. "/var/www/html": "20%",
  32. # Indexers:
  33. "/opt/splunk": 5000,
  34. "/opt/splunkdata/hot": local.splunk_hot,
  35. # Syslog Servers
  36. "/mnt/resource": "20%",
  37. "/opt/syslog-ng": 7000,
  38. # Docker Hosts
  39. "/opt/docker/containers": "20%",
  40. "/opt/docker/overlay": "20%",
  41. "/opt/docker/overlay2": "20%"
  42. }
  43. }
  44. resource "sensu_check" "check_dns_all" {
  45. for_each = local.dns_checks_all
  46. name = "check_dns_${ each.key }"
  47. command = "check_dns --hostname=${ each.key } --expected-address=${ each.value } --warning=${ var.sensu_checks["dns"]["warning"] } --critical=${ var.sensu_checks["dns"]["critical"] }"
  48. namespace = "default"
  49. subscriptions = [ "linux", ]
  50. handlers = [ "victorops", "logfile", ]
  51. cron = "* * * * *"
  52. publish = "true"
  53. runtime_assets = [ "sensu-plugins-monitoring", ]
  54. }
  55. resource "sensu_check" "check_dns_private" {
  56. for_each = local.dns_checks_private
  57. name = "check_dns_${ each.key }"
  58. command = "check_dns --hostname=${ each.key } --expected-address=${ each.value } --warning=${ var.sensu_checks["dns"]["warning"] } --critical=${ var.sensu_checks["dns"]["critical"] }"
  59. namespace = "default"
  60. subscriptions = [ "private_dns_client", ]
  61. handlers = [ "victorops", "logfile", ]
  62. cron = "* * * * *"
  63. publish = "true"
  64. runtime_assets = [ "sensu-plugins-monitoring", ]
  65. }
  66. # Systems that can't enumerate their mount points get
  67. # a single 'check all' disk space option
  68. resource "sensu_check" "check_disks_all" {
  69. name = "check_disk_all"
  70. # Checks all partitions except /snap/*
  71. command = "check_disk -c 20% -A --ignore-eregi-path '/snap/' --ignore-eregi-path '/opt/docker/.*' --ignore-eregi-path '/(sys|proc)/'"
  72. namespace = "default"
  73. subscriptions = [ "check_disk_all" ]
  74. handlers = [ "victorops", "logfile", ]
  75. cron = "* * * * *"
  76. publish = "true"
  77. runtime_assets = [ "sensu-plugins-monitoring", ]
  78. }
  79. # Systems that enumerate their mount points subscribe to
  80. # particular checks with thresholds defined above.
  81. resource "sensu_check" "check_disks" {
  82. for_each = local.disk_thresholds
  83. name = "check_disk${ replace(each.key, "/", "_") }"
  84. command = "check_disk -c ${ each.value } -p ${ replace(each.key, "root", "/") }"
  85. namespace = "default"
  86. subscriptions = [ "check_disk${ replace(each.key, "/", "_") }" ]
  87. handlers = [ "victorops", "logfile", ]
  88. cron = "* * * * *"
  89. publish = "true"
  90. runtime_assets = [ "sensu-plugins-monitoring", ]
  91. }
  92. #resource "sensu_check" "check_ping_interconnect-0" {
  93. # for_each = toset(local.interconnect-0)
  94. # name = "ping_interconnect-0-${index(local.interconnect-0, each.value) +1}"
  95. # command = "check_ping -H ${each.value} -w 500,80% -c 500,80% -4"
  96. # namespace = "default"
  97. # subscriptions = [ "interconnect-0", ]
  98. # handlers = [ "victorops", "logfile", ]
  99. # cron = "* * * * *"
  100. # publish = "true"
  101. # runtime_assets = [ "sensu-plugins-monitoring", ]
  102. #}
  103. #
  104. #resource "sensu_check" "check_ping_interconnect-1" {
  105. # for_each = toset(local.interconnect-1)
  106. # name = "ping_interconnect-1-${index(local.interconnect-1, each.value) +1}"
  107. # command = "check_ping -H ${each.value} -w 500,80% -c 500,80% -4"
  108. # namespace = "default"
  109. # subscriptions = [ "interconnect-1", ]
  110. # handlers = [ "victorops", "logfile", ]
  111. # cron = "* * * * *"
  112. # publish = "true"
  113. # runtime_assets = [ "sensu-plugins-monitoring", ]
  114. #}
  115. resource "sensu_check" "check_phantom_ports" {
  116. name = "phantom_ports"
  117. command = "check-ports.rb -h 0.0.0.0 -p 443"
  118. namespace = "default"
  119. subscriptions = [ "phantom_ports", ]
  120. handlers = [ "victorops", "logfile", ]
  121. cron = "* * * * *"
  122. publish = "true"
  123. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  124. }
  125. resource "sensu_check" "check_portal_http" {
  126. name = "portal_http"
  127. command = "check-http.rb -u https://portal.${var.dns_info["public"]["zone"]}/api/health/ --response-code 200"
  128. namespace = "default"
  129. subscriptions = [ "portal", ]
  130. handlers = [ "victorops", "logfile", ]
  131. cron = "* * * * *"
  132. publish = "true"
  133. runtime_assets = [ "sensu-plugins-http", "sensu-ruby-runtime", ]
  134. }
  135. resource "sensu_check" "check_salt_master_ports" {
  136. name = "salt_master_ports"
  137. command = "check-ports.rb -h 0.0.0.0 -p 4505,4506"
  138. namespace = "default"
  139. subscriptions = [ "salt_master_ports", ]
  140. handlers = [ "victorops", "logfile", ]
  141. cron = "* * * * *"
  142. publish = "true"
  143. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  144. }
  145. resource "sensu_check" "check_splunk_cm_ports" {
  146. name = "splunk_cm_ports"
  147. command = "check-ports.rb -h 0.0.0.0 -p 8089"
  148. namespace = "default"
  149. subscriptions = [ "splunk_cm_ports", ]
  150. handlers = [ "victorops", "logfile", ]
  151. cron = "* * * * *"
  152. publish = "true"
  153. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  154. }
  155. resource "sensu_check" "check_splunk_ds_ports" {
  156. name = "splunk_ds_ports"
  157. command = "check-ports.rb -h 0.0.0.0 -p 8089"
  158. namespace = "default"
  159. subscriptions = [ "splunk_ds_ports", ]
  160. handlers = [ "victorops", "logfile", ]
  161. cron = "* * * * *"
  162. publish = "true"
  163. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  164. }
  165. resource "sensu_check" "check_splunk_hf_ports" {
  166. name = "splunk_hf_ports"
  167. command = "check-ports.rb -h 0.0.0.0 -p 8089,8000"
  168. namespace = "default"
  169. subscriptions = [ "splunk_hf_ports", ]
  170. handlers = [ "victorops", "logfile", ]
  171. cron = "* * * * *"
  172. publish = "true"
  173. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  174. }
  175. resource "sensu_check" "check_splunk_indexer_ports_moose" {
  176. name = "splunk_indexer_ports_moose"
  177. command = "check-ports.rb -h 0.0.0.0 -p 8089,9998,9887,8088"
  178. namespace = "default"
  179. subscriptions = [ "splunk_indexer_ports_moose", ]
  180. handlers = [ "victorops", "logfile", ]
  181. cron = "* * * * *"
  182. publish = "true"
  183. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  184. }
  185. resource "sensu_check" "check_splunk_indexer_ports" {
  186. name = "splunk_indexer_ports"
  187. command = "check-ports.rb -h 0.0.0.0 -p 8089,9998,9887"
  188. namespace = "default"
  189. subscriptions = [ "splunk_indexer_ports", ]
  190. handlers = [ "victorops", "logfile", ]
  191. cron = "* * * * *"
  192. publish = "true"
  193. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  194. }
  195. resource "sensu_check" "check_splunk_sh_ports" {
  196. name = "splunk_sh_ports"
  197. command = "check-ports.rb -h 0.0.0.0 -p 8089,8000"
  198. namespace = "default"
  199. subscriptions = [ "splunk_sh_ports", ]
  200. handlers = [ "victorops", "logfile", ]
  201. cron = "* * * * *"
  202. publish = "true"
  203. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  204. }
  205. resource "sensu_check" "check_splunk_uf_ports" {
  206. name = "splunk_uf_ports"
  207. command = "check-ports.rb -h 0.0.0.0 -p 8089"
  208. namespace = "default"
  209. subscriptions = [ "splunk", ]
  210. handlers = [ "victorops", "logfile", ]
  211. cron = "* * * * *"
  212. publish = "true"
  213. runtime_assets = [ "sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  214. }
  215. resource "sensu_check" "check_syslog-ng_service" {
  216. name = "syslog-ng_service"
  217. command = "check-process.rb -p syslog-ng"
  218. namespace = "default"
  219. subscriptions = [ "syslog-ng_service", ]
  220. handlers = [ "victorops", "logfile", ]
  221. cron = "* * * * *"
  222. publish = "true"
  223. runtime_assets = [ "sensu-plugins-process-checks", "sensu-ruby-runtime", ]
  224. }
  225. resource "sensu_check" "check_salt-minion_service" {
  226. name = "salt-minion_service"
  227. command = "check-process.rb -p salt-minion --critical-under 1 --critical-over 5"
  228. namespace = "default"
  229. subscriptions = [ "salt-minion_service", ]
  230. handlers = [ "victorops", "logfile", ]
  231. cron = "* * * * *"
  232. publish = "true"
  233. runtime_assets = [ "sensu-plugins-process-checks", "sensu-ruby-runtime", ]
  234. }