Fixes
This commit is contained in:
parent
064ca2f20a
commit
0be5f409aa
|
@ -116,6 +116,7 @@ function check() {
|
|||
fi
|
||||
|
||||
for check in $checks; do
|
||||
printf "\033[KChecking %s…\r" "${check}"
|
||||
err_msg=""
|
||||
if [ "${bypass_nrpe}" = "False" ]; then
|
||||
request_command="${check_nrpe_bin} -H ${server_address} -p ${server_port} -c check_${check} 2&>1"
|
||||
|
@ -169,14 +170,14 @@ function check() {
|
|||
esac
|
||||
|
||||
if [ -z "${1}" ] || [ "${1}" = "all" ]; then
|
||||
str_out="${str_out}${color}${check}\t${rc_str}\t${check_output}${nocolor}\n"
|
||||
str_out="${str_out}${color}${check}\t${rc_str}${nocolor}\t${check_output}\n"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "${1}" ] || [ "${1}" = "all" ]; then
|
||||
echo -e "${str_out}" | column -t -s $'\t'
|
||||
else
|
||||
echo -e "${str_out}${color}${check_output}${nocolor}" | sed 's/|/\n/g'
|
||||
echo -e "${str_out}${color}${nocolor}${check_output}" | sed 's/|/\n/g'
|
||||
exit "${rc}"
|
||||
fi
|
||||
}
|
||||
|
@ -206,7 +207,7 @@ function disable_alerts() {
|
|||
read -r message
|
||||
echo ''
|
||||
if [ -z "${message}" ]; then
|
||||
error "Error: disable message is mandatory."
|
||||
error "${red}Error:${nocolor} disable message is mandatory."
|
||||
fi
|
||||
else
|
||||
message="${2}"
|
||||
|
@ -222,13 +223,9 @@ function disable_alerts() {
|
|||
else
|
||||
check_txt="Check ${1}"
|
||||
fi
|
||||
main_msg="${check_txt} will be disabled for ${duration}${default_msg}."
|
||||
main_msg_len="${#main_msg}"
|
||||
line="$(printf '─%.0s' $(eval "echo {1.."${main_msg_len}"}"))"
|
||||
|
||||
echo_box "${check_txt} will be disabled for ${duration}${default_msg}."
|
||||
cat <<EOF
|
||||
┌${line}┐
|
||||
│${main_msg}│
|
||||
└${line}┘
|
||||
|
||||
Additional information:
|
||||
* Alerts history is kept in our monitoring system.
|
||||
|
@ -288,7 +285,7 @@ function enable_alerts() {
|
|||
read -r message
|
||||
echo ''
|
||||
if [ -z "${message}" ]; then
|
||||
error "Error: disable message is mandatory."
|
||||
error "${red}Error:${nocolor} disable message is mandatory."
|
||||
fi
|
||||
else
|
||||
message="${2}"
|
||||
|
@ -362,21 +359,38 @@ function warn_not_wrapped() {
|
|||
unwrappeds="$(not_wrapped_checks)"
|
||||
unwrapped_checks="$(comm -12 <(echo "${1}") <(echo "${unwrappeds}"))"
|
||||
if [ -n "${unwrapped_checks}" ]; then
|
||||
n_checks="$(echo "${1}" | wc -w)"
|
||||
n_unwrapped="$(echo "${unwrapped_checks}" | wc -w)"
|
||||
if [ "${n_unwrapped}" -eq 1 ]; then
|
||||
>&2 echo -e "${orange}Warning:${nocolor} ${unwrapped_checks} check is not wrapped, it will not be disabled."
|
||||
if [ "${n_unwrapped}" == "${n_checks}" ]; then
|
||||
if [ "${n_unwrapped}" -eq 1 ]; then
|
||||
error "${red}Error:${nocolor} ${1} check is not wrapped, it cannot be disabled."
|
||||
else
|
||||
error "${red}Error:${nocolor} these checks are not wrapped, they cannot be disabled: $(echo "${unwrapped_checks}" | xargs)"
|
||||
fi
|
||||
else
|
||||
>&2 echo -e -n "${orange}Warning:${nocolor} some checks are not configured, they will not be disabled:"
|
||||
for unwrapped in ${unwrapped_checks}; do
|
||||
>&2 echo -e -n " %s" "${unwrapped}"
|
||||
done
|
||||
>&2 echo -e -n "\n"
|
||||
if [ "${n_unwrapped}" -eq 1 ]; then
|
||||
>&2 echo -e "${orange}Warning:${nocolor} ${unwrapped_checks} check is not wrapped, it will not be disabled."
|
||||
else
|
||||
>&2 echo -e -n "${orange}Warning:${nocolor} some checks are not configured, they will not be disabled: $(echo "${unwrapped_checks}" | xargs)\n\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Warning: some checks have no alerts_wrapper, they will not be disabled: $(echo "${unwrapped_checks}" | xargs)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Echo a message in a box
|
||||
function echo_box() {
|
||||
# $1: message
|
||||
msg_len="${#1}"
|
||||
line="$(printf '─%.0s' $(eval "echo {1.."${msg_len}"}"))"
|
||||
cat <<EOF
|
||||
┌${line}┐
|
||||
│${1}│
|
||||
└${line}┘
|
||||
EOF
|
||||
}
|
||||
|
||||
# Echo which checks are enabled or disabled and time left
|
||||
function alerts_status() {
|
||||
# $1: check name, "all" or empty
|
||||
|
@ -421,7 +435,7 @@ function alerts_status() {
|
|||
*)
|
||||
color="${red}"
|
||||
esac
|
||||
str_out="${str_out}${color}${check}\t${status_str}\t${enable_str}${nocolor}\t${disable_msg}\n"
|
||||
str_out="${str_out}${color}${check}\t${status_str}${nocolor}\t${enable_str}\t${disable_msg}\n"
|
||||
done
|
||||
|
||||
echo -e "${str_out}" | column -t -s $'\t'
|
||||
|
|
|
@ -18,7 +18,7 @@ _nrpe_conf_lines='' # populated at the end of the file
|
|||
|
||||
function error() {
|
||||
# $1: error message
|
||||
>&2 echo "${1}"
|
||||
>&2 echo -e "${1}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue