Get service information from two patterns
Get service name, the number of processes found, minimal and maximal.
This commit is contained in:
parent
cb55bb2f8e
commit
d7887bd72a
|
@ -11,7 +11,7 @@ red Fri Aug 10 15:35:26 CEST 2018 - Processes NOT ok
|
||||||
&green systemd-journald (found 1, req. between 1 and 1)
|
&green systemd-journald (found 1, req. between 1 and 1)
|
||||||
&green systemd-logind (found 1, req. between 1 and 1)
|
&green systemd-logind (found 1, req. between 1 and 1)
|
||||||
&green CRON (found 1, req. between 1 and 999)
|
&green CRON (found 1, req. between 1 and 999)
|
||||||
&yellow ATD (found 1, req. between 1 and 999)
|
&yellow ATD (found 0, req. between 1 and 999)
|
||||||
&green MTA-Stretch (found 1, req. between 1 and 1)
|
&green MTA-Stretch (found 1, req. between 1 and 1)
|
||||||
&green SSHD (found 3, req. between 1 and 20)
|
&green SSHD (found 3, req. between 1 and 20)
|
||||||
&green SSSD (found 1, req. between 1 and 1)
|
&green SSSD (found 1, req. between 1 and 1)
|
||||||
|
@ -83,13 +83,31 @@ fi
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# Get the list of processes with an error
|
# Get the list of processes with an error
|
||||||
echo "${BBALPHAMSG}" | grep -E "&(red|yellow)" | cut -d" " -f2 | tr '[:upper:]' '[:lower:]' > "${service_list}"
|
echo "${BBALPHAMSG}" | grep -E "&(red|yellow)" | cut -d" " -f2- | tr '[:upper:]' '[:lower:]' > "${service_list}"
|
||||||
|
|
||||||
# If any error on a process
|
# If any error on a process
|
||||||
if [ -s "${service_list}" ]; then
|
if [ -s "${service_list}" ]; then
|
||||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : process list — Some processes seems to be in error." >> "${debug_stdout}"
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : process list — Some processes seems to be in error." >> "${debug_stdout}"
|
||||||
while IFS= read -r process; do
|
while IFS= read -r line; do
|
||||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : while process loop — ${process} service need to be restarted." >> "${debug_stdout}"
|
## Pattern "req. between" {{{
|
||||||
|
if echo "${line}" | grep -q -E -- ".* \\(found .*, req. between .* and .*\\)" ; then
|
||||||
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : while process loop — Pattern \"req. between\"." >> "${debug_stdout}"
|
||||||
|
service_name="$(echo "${line}" | cut -d" " -f1)"
|
||||||
|
process_found="$(echo "${line}" | cut -d" " -f3 | tr -d ',')"
|
||||||
|
process_min="$(echo "${line}" | cut -d" " -f6)"
|
||||||
|
process_max="$(echo "${line}" | cut -d" " -f8 | tr -d ')')"
|
||||||
|
fi
|
||||||
|
## }}}
|
||||||
|
## Pattern "req. .* or more" {{{
|
||||||
|
if echo "${line}" | grep -q -E -- ".* \\(found .*, req. .* or more\\)" ; then
|
||||||
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : while process loop — Pattern \"req. .* or more\"." >> "${debug_stdout}"
|
||||||
|
service_name="$(echo "${line}" | cut -d" " -f1)"
|
||||||
|
process_found="$(echo "${line}" | cut -d" " -f3 | tr -d ',')"
|
||||||
|
process_min="$(echo "${line}" | cut -d" " -f5)"
|
||||||
|
process_max="nolimit"
|
||||||
|
fi
|
||||||
|
## }}}
|
||||||
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : while process loop — Found ${process_found} process(es) for ${service_name} service and require between ${process_min} and ${process_max}." >> "${debug_stdout}"
|
||||||
done < "${service_list}"
|
done < "${service_list}"
|
||||||
else
|
else
|
||||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : process list — No error on any process." >> "${debug_stdout}"
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : process list — No error on any process." >> "${debug_stdout}"
|
||||||
|
@ -101,5 +119,4 @@ fi
|
||||||
# Remove temp_dir if DEBUG is disable
|
# Remove temp_dir if DEBUG is disable
|
||||||
[ "${DEBUG}" -eq "0" ] || rm -rf -- "${temp_dir}"
|
[ "${DEBUG}" -eq "0" ] || rm -rf -- "${temp_dir}"
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue