From bf0edb7d7858df64782719f9e6bcc1ba2de57b0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Thu, 26 Jul 2018 13:16:55 +0200 Subject: [PATCH] Add force check monitoring script --- modules/profile/manifests/monitoring.pp | 8 ++++++++ .../profile/templates/monitoring/force_check.sh.erb | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 modules/profile/templates/monitoring/force_check.sh.erb diff --git a/modules/profile/manifests/monitoring.pp b/modules/profile/manifests/monitoring.pp index 99956c3..ab8cc62 100644 --- a/modules/profile/manifests/monitoring.pp +++ b/modules/profile/manifests/monitoring.pp @@ -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 index 0000000..e5b2a23 --- /dev/null +++ b/modules/profile/templates/monitoring/force_check.sh.erb @@ -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 -- 2.41.0