From 3c634b7dc3885db4f1f2ac78be18dc27cadec17d Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Tue, 22 Sep 2020 01:38:34 +0900 Subject: [PATCH 1/2] Deploy `check_file_ script. --- cookbooks/consul/files/usr/local/bin/check_file | 9 +++++++++ cookbooks/consul/monitoring.rb | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 cookbooks/consul/files/usr/local/bin/check_file diff --git a/cookbooks/consul/files/usr/local/bin/check_file b/cookbooks/consul/files/usr/local/bin/check_file new file mode 100644 index 0000000..8622cee --- /dev/null +++ b/cookbooks/consul/files/usr/local/bin/check_file @@ -0,0 +1,9 @@ +#!/bin/bash + +TARGET=$1 + +if [ -f ${TARGET} ]; then + exit 1 +fi + +exit 0 diff --git a/cookbooks/consul/monitoring.rb b/cookbooks/consul/monitoring.rb index c9bfde4..63944de 100644 --- a/cookbooks/consul/monitoring.rb +++ b/cookbooks/consul/monitoring.rb @@ -1,3 +1,9 @@ +remote_file '/usr/local/bin/check_file' do + owner 'root' + group 'root' + mode '755' +end + %w(reboot-required).each do |conf| remote_file "/etc/consul.d/check-#{conf}.json" do owner 'root' From 7ba084b71f3ebafb65899fbd959b938fd01b9b57 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Tue, 22 Sep 2020 01:40:45 +0900 Subject: [PATCH 2/2] Use `/usr/local/bin/check_file`. --- cookbooks/consul/files/etc/consul.d/check-reboot-required.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbooks/consul/files/etc/consul.d/check-reboot-required.json b/cookbooks/consul/files/etc/consul.d/check-reboot-required.json index 55a514f..0046b7d 100644 --- a/cookbooks/consul/files/etc/consul.d/check-reboot-required.json +++ b/cookbooks/consul/files/etc/consul.d/check-reboot-required.json @@ -2,7 +2,7 @@ "check": { "id": "reboot-required", "name": "Check for Reboot Required", - "args": ["/usr/lib/nagios/plugins/check_file", "/var/run/reboot-required"], + "args": ["/usr/local/bin/check_file", "/var/run/reboot-required"], "interval": "86400s", "timeout": "10s" }