Create log files and remove empty one at the end
This commit is contained in:
parent
aab15f81ba
commit
1cd251847b
|
@ -27,17 +27,14 @@ debug_stderr="${temp_dir}/debug.stderr"
|
|||
service_list="${temp_dir}/services.error.list"
|
||||
# }}}
|
||||
|
||||
# Temp dir for this alert {{{
|
||||
if [ ! -d "${temp_dir}" ] ; then
|
||||
mkdir -p -- "${temp_dir}"
|
||||
fi
|
||||
# }}}
|
||||
# Create log files
|
||||
touch "${debug_stdout}" "${debug_stderr}"
|
||||
|
||||
# Manage only libs probe {{{
|
||||
if [ "${BBSVCNAME}" = "libs" ]; then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${BBHOSTNAME} — ${BBSVCNAME} error" > "${debug_stdout}"
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${BBHOSTNAME} — ${BBSVCNAME} error" >> "${debug_stdout}"
|
||||
else
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${BBHOSTNAME} — ${BBSVCNAME} probe is not managed." > "${debug_stderr}"
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${BBHOSTNAME} — ${BBSVCNAME} probe is not managed." >> "${debug_stderr}"
|
||||
[ "${DEBUG}" -eq "0" ] || rm -rf -- "${temp_dir}"
|
||||
exit 0
|
||||
fi
|
||||
|
@ -108,7 +105,7 @@ if echo "${BBALPHAMSG}" | grep -qE "\\&yellow The following processes.*" ; then
|
|||
else
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : while bin_path loop — ${service_name} need to be restarted." >> "${debug_stdout}"
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : while bin_path loop — ssh -o StrictHostKeyChecking=no ${REMOTE_SSH_USER}@${BBHOSTNAME} sudo systemctl restart ${service_name}.service" >> "${debug_stdout}"
|
||||
ssh -o StrictHostKeyChecking=no ${REMOTE_SSH_USER}@${BBHOSTNAME} sudo systemctl restart ${service_name}.service >> "${debug_stdout}" 2> "${debug_stderr}"
|
||||
ssh -o StrictHostKeyChecking=no ${REMOTE_SSH_USER}@${BBHOSTNAME} sudo systemctl restart ${service_name}.service >> "${debug_stdout}" 2>> "${debug_stderr}"
|
||||
fi
|
||||
# }}}
|
||||
done < "${service_list}"
|
||||
|
@ -116,10 +113,14 @@ if echo "${BBALPHAMSG}" | grep -qE "\\&yellow The following processes.*" ; then
|
|||
# Also restart xymon-client service {{{
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test service — xymon-client also need to be restarted." >> "${debug_stdout}"
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test service — ssh -o StrictHostKeyChecking=no ${REMOTE_SSH_USER}@${BBHOSTNAME} sudo systemctl restart xymon-client.service" >> "${debug_stdout}"
|
||||
ssh -o StrictHostKeyChecking=no ${REMOTE_SSH_USER}@${BBHOSTNAME} sudo systemctl restart xymon-client.service >> "${debug_stdout}" 2> "${debug_stderr}"
|
||||
ssh -o StrictHostKeyChecking=no ${REMOTE_SSH_USER}@${BBHOSTNAME} sudo systemctl restart xymon-client.service >> "${debug_stdout}" 2>> "${debug_stderr}"
|
||||
# }}}
|
||||
fi
|
||||
|
||||
# Remove empty error file
|
||||
[ -s "${debug_stderr}" ] || rm -f "${debug_stderr}"
|
||||
|
||||
# Remove temp_dir if DEBUG is disable
|
||||
[ "${DEBUG}" -eq "0" ] || rm -rf -- "${temp_dir}"
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue