Browse Source

Merge pull request #283 from mdr-engineering/feature/ftd_na_PathSpecificSensuChecks

Changes Sensu Disk Checks to be Individual Per-Disk
Frederick Damstra 4 years ago
parent
commit
c9bec0faa0
1 changed files with 33 additions and 9 deletions
  1. 33 9
      base/sensu-configuration/checks.tf

+ 33 - 9
base/sensu-configuration/checks.tf

@@ -16,6 +16,27 @@ locals {
     "dnstest.pvt.xdr.accenturefederalcyber.com": "10.10.10.10",
     "10.10.10.10": "dnstest.pvt.xdr.accenturefederalcyber.com.",
   }
+
+  standard_paths = {
+    "root": "20%",
+    "/tmp": "20%",
+    "/home": "20%",
+    "/var": "20%",
+    "/var/tmp": "20%",
+    "/var/log": "20%"
+    "/var/log/audit": "20%",
+    "/opt": "20%",
+    "/boot": "20%",
+  }
+
+  indexer_paths = {
+    "/opt/splunk": 5000,
+    "/opt/splunkdata/hot": local.splunk_hot,
+  }
+
+  syslog_paths = {
+    "/opt/syslog-ng": 7000
+  }
 }
 
 resource "sensu_check" "check_dns_all" {
@@ -42,9 +63,10 @@ resource "sensu_check" "check_dns_private" {
   runtime_assets = [ "sensu-plugins-monitoring", ]
 }
 
-resource "sensu_check" "check_disk_base" {
-  name           = "check_disk_base"
-  command        = "check_disk -c 250 -p /var -C -c 500 -p /var/log -C -c 1000 -p /var/log/audit -C -c 2000 -p /opt -C -c 500 -p /boot -C -c 1000 -p /"
+resource "sensu_check" "check_disk_standard_paths" {
+  for_each       = local.standard_paths
+  name           = "check_disk_base_${ replace(each.key, "/", "_") }"
+  command        = "check_disk -c ${ each.value } -p ${ replace(each.key, "root", "/") }"
   namespace      = "default"
   subscriptions  = [ "linux", ]
   handlers       = [ "victorops", "logfile", ]
@@ -53,9 +75,10 @@ resource "sensu_check" "check_disk_base" {
   runtime_assets = [ "sensu-plugins-monitoring", ]
 }
 
-resource "sensu_check" "check_disk_indexer" {
-  name           = "check_disk_indexer"
-  command        = "check_disk -c ${local.splunk_hot} -p /opt/splunkdata/hot -C -c 5000 -p /opt/splunk"
+resource "sensu_check" "check_disk_indexer_paths" {
+  for_each       = local.indexer_paths
+  name           = "check_disk_indexer_${ replace(each.key, "/", "_") }"
+  command        = "check_disk -c ${ each.value } -p ${ replace(each.key, "root", "/") }"
   namespace      = "default"
   subscriptions  = [ "check_disk_indexer", ]
   handlers       = [ "victorops", "logfile", ]
@@ -64,9 +87,10 @@ resource "sensu_check" "check_disk_indexer" {
   runtime_assets = [ "sensu-plugins-monitoring", ]
 }
 
-resource "sensu_check" "check_disk_syslog" {
-  name           = "check_disk_syslog"
-  command        = "check_disk -c 7000 -p /opt/syslog-ng"
+resource "sensu_check" "check_disk_syslog_paths" {
+  for_each       = local.syslog_paths
+  name           = "check_disk_syslog_${ replace(each.key, "/", "_") }"
+  command        = "check_disk -c ${ each.value } -p ${ replace(each.key, "root", "/") }"
   namespace      = "default"
   subscriptions  = [ "check_disk_syslog", ]
   handlers       = [ "victorops", "logfile", ]