[icinga-checkins] icinga.org: icinga-vagrant/master: icinga2x: Add default mysql database size checks

git at icinga.org git at icinga.org
Wed Jul 27 21:26:33 CEST 2016


Module: icinga-vagrant
Branch: master
Commit: 30c7ab34bf4bb597958df6f2e3c0ab80ec179ab6
URL:    https://git.icinga.org/?p=icinga-vagrant.git;a=commit;h=30c7ab34bf4bb597958df6f2e3c0ab80ec179ab6

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Wed Jul 27 21:26:05 2016 +0200

icinga2x: Add default mysql database size checks

---

 .../etc/icinga2/conf.d/additional_services.conf    |   32 ++++++++++++++++++++
 icinga2x/files/etc/icinga2/conf.d/hosts.conf       |   10 ++++++
 2 files changed, 42 insertions(+)

diff --git a/icinga2x/files/etc/icinga2/conf.d/additional_services.conf b/icinga2x/files/etc/icinga2/conf.d/additional_services.conf
index abb38c8..412166b 100644
--- a/icinga2x/files/etc/icinga2/conf.d/additional_services.conf
+++ b/icinga2x/files/etc/icinga2/conf.d/additional_services.conf
@@ -19,3 +19,35 @@ apply Service for (dns_check => config in host.vars.dns_checks) {
 
   vars += config
 }
+
+apply Service "db-size-" for (db_name => config in host.vars.databases) {
+  check_interval = 1m
+  retry_interval = 30s
+
+  check_command = "mysql_health"
+
+  if (config.mysql_health_username) {
+    vars.mysql_healt_username = config.mysql_health_username
+  } else {
+    vars.mysql_health_username = "root"
+  }
+  if (config.mysql_health_password) {
+    vars.mysql_healt_password = config.mysql_health_password
+  } else {
+    vars.mysql_health_password = "icingar0xx"
+  }
+
+  vars.mysql_health_mode = "sql"
+  vars.mysql_health_name = "select sum(data_length + index_length) / 1024 / 1024 from information_schema.tables where table_schema = '" + db_name + "';"
+  vars.mysql_health_name2 = "db_size"
+  vars.mysql_health_units = "MB"
+
+  if (config.mysql_health_warning) {
+    vars.mysql_health_warning = config.mysql_health_warning
+  }
+  if (config.mysql_health_critical) {
+    vars.mysql_health_critical = config.mysql_health_critical
+  }
+
+  vars += config
+}
diff --git a/icinga2x/files/etc/icinga2/conf.d/hosts.conf b/icinga2x/files/etc/icinga2/conf.d/hosts.conf
index c2b7588..3520a5f 100644
--- a/icinga2x/files/etc/icinga2/conf.d/hosts.conf
+++ b/icinga2x/files/etc/icinga2/conf.d/hosts.conf
@@ -86,6 +86,16 @@ object Host NodeName {
     http_uri = "/repos/icinga/"
   }
 
+  /* database checks */
+  vars.databases["icinga"] = {
+    mysql_health_warning = 4096 //MB
+    mysql_health_critical = 8192 //MB
+  }
+  vars.databases["icingaweb2"] = {
+    mysql_health_warning = 4096 //MB
+    mysql_health_critical = 8192 //MB
+  }
+
   /* random checks */
   vars.random = [ 1, 2, 3, 4, 5 ]
 



More information about the icinga-checkins mailing list