]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Add force check monitoring script
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 26 Jul 2018 11:16:55 +0000 (13:16 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 26 Jul 2018 11:22:56 +0000 (13:22 +0200)
modules/profile/manifests/monitoring.pp
modules/profile/templates/monitoring/force_check.sh.erb [new file with mode: 0644]

index 99956c3bc1bd88314b5fd88c58ff91eb93a1ca9f..ab8cc6210bdec07d5d2dfec8dda34a9ad14e979f 100644 (file)
@@ -2,6 +2,8 @@ class profile::monitoring (
   Optional[String] $naemon_url   = undef,
   Optional[String] $naemon_token = undef,
 ) inherits profile::monitoring::params {
+  $real_hostname = lookup("base_installation::real_hostname")
+
   ensure_packages(["naemon", "cnagios"], { ensure => latest })
 
   file { "/etc/naemon":
@@ -40,6 +42,12 @@ class profile::monitoring (
     enable => true,
   }
 
+  file { "/usr/local/sbin/i_naemon_force_check":
+    ensure  => present,
+    mode    => "0755",
+    content => template("profile/monitoring/force_check.sh.erb"),
+  }
+
   unless ($naemon_url == undef or empty($naemon_url)) {
     file { "/etc/naemon/send_nrdp.sh":
       ensure  => "file",
diff --git a/modules/profile/templates/monitoring/force_check.sh.erb b/modules/profile/templates/monitoring/force_check.sh.erb
new file mode 100644 (file)
index 0000000..e5b2a23
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+date=$(date +%s)
+host="<%= @real_hostname %>"
+service="$2"
+
+if [ -z "$service" ]; then
+  printf "[%lu] SCHEDULE_FORCED_HOST_SVC_CHECKS;$host;%lu\n" $date $date | sudo -u naemon tee /var/lib/naemon/naemon.cmd
+else
+  printf "[%lu] SCHEDULE_FORCED_SVC_CHECK;$host;$service;%lu\n" $date $date | sudo -u naemon tee /var/lib/naemon/naemon.cmd
+fi