checks.tf 10 KB

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