From fc51eb2f6d2e6d7ce54aa1ceb15c6c113178ebb9 Mon Sep 17 00:00:00 2001 From: jlecour Date: Wed, 6 Sep 2017 14:33:27 +0200 Subject: [PATCH] readonly et local pour alerts_wrapper --- HowtoNagiosChecksWrapper.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/HowtoNagiosChecksWrapper.md b/HowtoNagiosChecksWrapper.md index c78b2aff..c47feec5 100644 --- a/HowtoNagiosChecksWrapper.md +++ b/HowtoNagiosChecksWrapper.md @@ -127,15 +127,15 @@ Détail du script `alerts_wrapper` : ~~~{.bash} #!/bin/bash -check_file="/tmp/$1_alerts_disabled" +readonly check_file="/tmp/$1_alerts_disabled" shift -check_stdout=$($@) -check_rc=$? +readonly check_stdout=$($@) +readonly check_rc=$? if [ -e "${check_file}" ]; then - last_change=$(stat -c %Z "${check_file}") - limit=$(date --date '24 hours ago' +'%s') + local last_change=$(stat -c %Z "${check_file}") + local limit=$(date --date '24 hours ago' +'%s') if [ ${last_change} -le ${limit} ]; then rm "${check_file}" @@ -143,7 +143,7 @@ if [ -e "${check_file}" ]; then fi if [ -e "${check_file}" ]; then - formatted_last_change=$(date --date "@$(stat -c %Z "${check_file}")" +'%c') + local formatted_last_change=$(date --date "@$(stat -c %Z "${check_file}")" +'%c') echo "ALERTS DISABLED (since ${formatted_last_change}) - ${check_stdout}" if [ ${check_rc} = 0 ]; then