feat(node_dump): Add an option to set max log file age
This commit is contained in:
parent
5302459a36
commit
cb3dce598c
|
@ -12,6 +12,8 @@ DUMP="log/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz"
|
||||||
CONF_DUMP="log/conf.dump"
|
CONF_DUMP="log/conf.dump"
|
||||||
SYSINFO="log/sysinfo.txt"
|
SYSINFO="log/sysinfo.txt"
|
||||||
|
|
||||||
|
LOG_MAX_AGE_DAYS=3
|
||||||
|
|
||||||
collect() {
|
collect() {
|
||||||
echo "========================================================"
|
echo "========================================================"
|
||||||
echo " $*"
|
echo " $*"
|
||||||
|
@ -20,6 +22,28 @@ collect() {
|
||||||
echo -e '\n'
|
echo -e '\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
echo "Collect information about the EMQ X node
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
|
||||||
|
bin/node_dump [-a DAYS]
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
|
||||||
|
-a n Set maximum age of collected log files in days (3 by default)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts "a:h" opt; do
|
||||||
|
case "${opt}" in
|
||||||
|
a) LOG_MAX_AGE_DAYS="${OPTARG}" ;;
|
||||||
|
h) show_help ;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Collect system info:
|
||||||
{
|
{
|
||||||
collect bin/emqx_ctl broker
|
collect bin/emqx_ctl broker
|
||||||
collect bin/emqx eval "'emqx_node_dump:sys_info()'"
|
collect bin/emqx eval "'emqx_node_dump:sys_info()'"
|
||||||
|
@ -36,12 +60,14 @@ collect() {
|
||||||
collect bin/emqx_ctl listeners
|
collect bin/emqx_ctl listeners
|
||||||
} > "${SYSINFO}"
|
} > "${SYSINFO}"
|
||||||
|
|
||||||
|
# Collect information about the configuration:
|
||||||
{
|
{
|
||||||
collect bin/emqx eval "'emqx_node_dump:app_env_dump()'"
|
collect bin/emqx eval "'emqx_node_dump:app_env_dump()'"
|
||||||
} > "${CONF_DUMP}"
|
} > "${CONF_DUMP}"
|
||||||
|
|
||||||
|
# Pack files
|
||||||
{
|
{
|
||||||
find log -mtime -3 \( -name '*.log.*' -or -name 'run_erl.log*' \)
|
find log -mtime -"${LOG_MAX_AGE_DAYS}" \( -name '*.log.*' -or -name 'run_erl.log*' \)
|
||||||
echo "${SYSINFO}"
|
echo "${SYSINFO}"
|
||||||
echo "${CONF_DUMP}"
|
echo "${CONF_DUMP}"
|
||||||
} | tar czf "${DUMP}" -T -
|
} | tar czf "${DUMP}" -T -
|
||||||
|
|
Loading…
Reference in New Issue