checks.tf 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. default_handlers = var.environment == "test" ? ["logfile"] : ["victorops", "logfile"]
  20. # To ensure this list is complete:
  21. # salt \* grains.get partitions | grep "^ /" | sort | uniq | grep -v snap
  22. disk_thresholds = {
  23. "/root" : "20%", # This is the / partition
  24. "/boot" : "20%",
  25. "/home" : "20%",
  26. "/opt" : "20%",
  27. "/tmp" : "20%",
  28. "/var" : "20%",
  29. "/var/log" : "20%"
  30. "/var/log/audit" : "20%",
  31. "/var/tmp" : "20%",
  32. "/var/www/html" : "20%",
  33. # Indexers:
  34. "/opt/splunk" : 5500,
  35. "/opt/splunkdata/hot" : local.splunk_hot,
  36. # Syslog Servers
  37. "/mnt/resource" : "20%",
  38. "/opt/syslog-ng" : 7000,
  39. # Docker Hosts
  40. "/opt/docker/containers" : "20%",
  41. "/opt/docker/overlay" : "20%",
  42. "/opt/docker/overlay2" : "20%",
  43. # VMRay
  44. "/opt/vmray" : "20%"
  45. }
  46. }
  47. resource "sensu_check" "check_dns_all" {
  48. for_each = local.dns_checks_all
  49. name = "check_dns_${each.key}"
  50. command = "check_dns --hostname=${each.key} --expected-address=${each.value} --warning=${local.sensu_checks["dns"]["warning"]} --critical=${local.sensu_checks["dns"]["critical"]}"
  51. namespace = "default"
  52. subscriptions = ["linux", ]
  53. handlers = local.default_handlers
  54. interval = 60
  55. publish = "true"
  56. runtime_assets = ["sensu-plugins-monitoring", ]
  57. }
  58. resource "sensu_check" "check_dns_private" {
  59. for_each = local.dns_checks_private
  60. name = "check_dns_${each.key}"
  61. command = "check_dns --hostname=${each.key} --expected-address=${each.value} --warning=${local.sensu_checks["dns"]["warning"]} --critical=${local.sensu_checks["dns"]["critical"]}"
  62. namespace = "default"
  63. subscriptions = ["private_dns_client", ]
  64. handlers = local.default_handlers
  65. interval = 60
  66. publish = "true"
  67. runtime_assets = ["sensu-plugins-monitoring", ]
  68. }
  69. # Systems that can't enumerate their mount points get
  70. # a single 'check all' disk space option
  71. resource "sensu_check" "check_disks_all" {
  72. name = "check_disk_all"
  73. # Checks all partitions except /snap/*
  74. command = "check_disk -c 20% -A --ignore-eregi-path '/snap/' --ignore-eregi-path '/opt/docker/.*' --ignore-eregi-path '/(sys|proc)/'"
  75. namespace = "default"
  76. subscriptions = ["check_disk_all"]
  77. handlers = local.default_handlers
  78. interval = 300
  79. publish = "true"
  80. runtime_assets = ["sensu-plugins-monitoring", ]
  81. }
  82. # Systems that enumerate their mount points subscribe to
  83. # particular checks with thresholds defined above.
  84. resource "sensu_check" "check_disks" {
  85. for_each = local.disk_thresholds
  86. name = "check_disk${replace(each.key, "/", "_")}"
  87. command = "check_disk -c ${each.value} -p ${replace(each.key, "root", "/")}"
  88. namespace = "default"
  89. subscriptions = ["check_disk${replace(each.key, "/", "_")}"]
  90. handlers = local.default_handlers
  91. interval = 300
  92. publish = "true"
  93. runtime_assets = ["sensu-plugins-monitoring", ]
  94. }
  95. #resource "sensu_check" "check_ping_interconnect-0" {
  96. # for_each = toset(local.interconnect-0)
  97. # name = "ping_interconnect-0-${index(local.interconnect-0, each.value) +1}"
  98. # command = "check_ping -H ${each.value} -w 500,80% -c 500,80% -4"
  99. # namespace = "default"
  100. # subscriptions = [ "interconnect-0", ]
  101. # handlers = local.default_handlers
  102. # interval = 60
  103. # publish = "true"
  104. # runtime_assets = [ "sensu-plugins-monitoring", ]
  105. #}
  106. #
  107. #resource "sensu_check" "check_ping_interconnect-1" {
  108. # for_each = toset(local.interconnect-1)
  109. # name = "ping_interconnect-1-${index(local.interconnect-1, each.value) +1}"
  110. # command = "check_ping -H ${each.value} -w 500,80% -c 500,80% -4"
  111. # namespace = "default"
  112. # subscriptions = [ "interconnect-1", ]
  113. # handlers = local.default_handlers
  114. # interval = 60
  115. # publish = "true"
  116. # runtime_assets = [ "sensu-plugins-monitoring", ]
  117. #}
  118. resource "sensu_check" "check_phantom_ports" {
  119. name = "phantom_ports"
  120. command = "check-ports.rb -h 0.0.0.0 -p 443"
  121. namespace = "default"
  122. subscriptions = ["phantom_ports", ]
  123. handlers = local.default_handlers
  124. interval = 60
  125. publish = "true"
  126. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  127. }
  128. resource "sensu_check" "check_portal_http" {
  129. name = "portal_http"
  130. command = "check-http.rb -u https://portal.${var.dns_info["public"]["zone"]}/api/health/ --response-code 200"
  131. namespace = "default"
  132. subscriptions = ["portal", ]
  133. handlers = local.default_handlers
  134. interval = 60
  135. publish = "true"
  136. runtime_assets = ["sensu-plugins-http", "sensu-ruby-runtime", ]
  137. }
  138. resource "sensu_check" "check_salt_master_ports" {
  139. name = "salt_master_ports"
  140. command = "check-ports.rb -h 0.0.0.0 -p 4505,4506"
  141. namespace = "default"
  142. subscriptions = ["salt_master_ports", ]
  143. handlers = local.default_handlers
  144. interval = 60
  145. publish = "true"
  146. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  147. }
  148. resource "sensu_check" "check_splunk_cm_ports" {
  149. name = "splunk_cm_ports"
  150. command = "check-ports.rb -h 0.0.0.0 -p 8089"
  151. namespace = "default"
  152. subscriptions = ["splunk_cm_ports", ]
  153. handlers = local.default_handlers
  154. interval = 60
  155. publish = "true"
  156. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  157. }
  158. resource "sensu_check" "check_splunk_ds_ports" {
  159. name = "splunk_ds_ports"
  160. command = "check-ports.rb -h 0.0.0.0 -p 8089"
  161. namespace = "default"
  162. subscriptions = ["splunk_ds_ports", ]
  163. handlers = local.default_handlers
  164. interval = 60
  165. publish = "true"
  166. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  167. }
  168. resource "sensu_check" "check_splunk_hf_ports" {
  169. name = "splunk_hf_ports"
  170. command = "check-ports.rb -h 0.0.0.0 -p 8089,8000"
  171. namespace = "default"
  172. subscriptions = ["splunk_hf_ports", ]
  173. handlers = local.default_handlers
  174. interval = 60
  175. publish = "true"
  176. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  177. }
  178. resource "sensu_check" "check_splunk_indexer_ports_moose" {
  179. name = "splunk_indexer_ports_moose"
  180. command = "check-ports.rb -h 0.0.0.0 -p 8089,9998,9887,8088"
  181. namespace = "default"
  182. subscriptions = ["splunk_indexer_ports_moose", ]
  183. handlers = local.default_handlers
  184. interval = 60
  185. publish = "true"
  186. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  187. }
  188. resource "sensu_check" "check_splunk_indexer_ports" {
  189. name = "splunk_indexer_ports"
  190. command = "check-ports.rb -h 0.0.0.0 -p 8089,9998,9887"
  191. namespace = "default"
  192. subscriptions = ["splunk_indexer_ports", ]
  193. handlers = local.default_handlers
  194. interval = 60
  195. publish = "true"
  196. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  197. }
  198. resource "sensu_check" "check_splunk_sh_ports" {
  199. name = "splunk_sh_ports"
  200. command = "check-ports.rb -h 0.0.0.0 -p 8089,8000"
  201. namespace = "default"
  202. subscriptions = ["splunk_sh_ports", ]
  203. handlers = local.default_handlers
  204. interval = 60
  205. publish = "true"
  206. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  207. }
  208. resource "sensu_check" "check_splunk_uf_ports" {
  209. name = "splunk_uf_ports"
  210. command = "check-ports.rb -h 0.0.0.0 -p 8089"
  211. namespace = "default"
  212. subscriptions = ["splunk", ]
  213. handlers = local.default_handlers
  214. interval = 60
  215. publish = "true"
  216. runtime_assets = ["sensu-plugins-network-checks", "sensu-ruby-runtime", ]
  217. }
  218. resource "sensu_check" "check_syslog-ng_service" {
  219. name = "syslog-ng_service"
  220. command = "check-process.rb -p syslog-ng"
  221. namespace = "default"
  222. subscriptions = ["syslog-ng_service", ]
  223. handlers = local.default_handlers
  224. interval = 60
  225. publish = "true"
  226. runtime_assets = ["sensu-plugins-process-checks", "sensu-ruby-runtime", ]
  227. }
  228. resource "sensu_check" "check_salt-minion_service" {
  229. name = "salt-minion_service"
  230. command = "check-process.rb -p salt-minion --critical-under 1"
  231. namespace = "default"
  232. subscriptions = ["salt-minion_service", ]
  233. handlers = local.default_handlers
  234. interval = 60
  235. publish = "true"
  236. runtime_assets = ["sensu-plugins-process-checks", "sensu-ruby-runtime", ]
  237. }
  238. # Don't detect the Splunk Universal Forwarder running as root.
  239. # Only look for Splunk Enterprise running as splunk user.
  240. resource "sensu_check" "check_splunk_service" {
  241. name = "splunk_service"
  242. command = "check-process.rb -p 'splunkd -p' --user splunk -C 2"
  243. namespace = "default"
  244. subscriptions = ["splunk_service", ]
  245. handlers = local.default_handlers
  246. interval = 60
  247. publish = "true"
  248. runtime_assets = ["sensu-plugins-process-checks", "sensu-ruby-runtime", ]
  249. }
  250. resource "sensu_check" "check_vault_service" {
  251. name = "vault_service"
  252. command = "check-process.rb -p vault"
  253. namespace = "default"
  254. subscriptions = ["vault_service", ]
  255. handlers = local.default_handlers
  256. interval = 60
  257. publish = "true"
  258. runtime_assets = ["sensu-plugins-process-checks", "sensu-ruby-runtime", ]
  259. }
  260. resource "sensu_check" "check_cribl_service" {
  261. name = "cribl_service"
  262. command = "check-process.rb -p cribl"
  263. namespace = "default"
  264. subscriptions = ["cribl_service", ]
  265. handlers = local.default_handlers
  266. interval = 60
  267. publish = "true"
  268. runtime_assets = ["sensu-plugins-process-checks", "sensu-ruby-runtime", ]
  269. }