ast_coredumper: Refactor to better find things

The search for a running asterisk when --running is used
has been greatly simplified and in the event it doesn't
work, you can now specify a pid to use on the command
line with --pid.

The search for asterisk modules when --tarball-coredumps
is used has been enhanced to have a better chance of finding
them and in the event it doesn't work, you can now specify
--libdir on the command line to indicate the library directory
where they were installed.

The DATEFORMAT variable was renamed to DATEOPTS and is now
passed to the 'date' utility rather than running DATEFORMAT
as a command.

The coredump and output files are now renamed with DATEOPTS.
This can be disabled by specifying --no-rename.

Several confusing and conflicting options were removed:
--append-coredumps
--conffile
--no-default-search
--tarball-uniqueid

The script was re-structured to make it easier for follow.

Change-Id: I674be64bdde3ef310b6a551d4911c3b600ffee59
This commit is contained in:
George Joseph 2021-09-09 08:39:27 -06:00
parent 67d1f881eb
commit 8aea2e5929
3 changed files with 567 additions and 488 deletions

View File

@ -4,46 +4,55 @@
# "sourced" by bash and must adhere to bash semantics.
#
# A list of coredumps and/or coredump search patterns.
#
# The following settings are used by ast_coredumper
#
# COREDUMPS is a a list of coredumps and/or coredump
# search patterns.
#
# Bash extended globs are enabled and any resulting files
# that aren't actually coredumps are silently ignored
# so you can be liberal with the globs.
#
# If your patterns contains spaces be sure to only quote
# If your patterns contain spaces be sure to only quote
# the portion of the pattern that DOESN'T contain wildcard
# expressions. If you quote the whole pattern, it won't
# be expanded and the glob characters will be treated as
# literals.
#
# The exclusion of files ending ".txt" is just for
# demonstration purposes as non-coredumps will be ignored
# anyway.
COREDUMPS=(/tmp/core[-._]asterisk!(*.txt) /tmp/core[-._]$(hostname)!(*.txt))
# demonstration purposes as non-asterisk-coredumps will be
# ignored anyway.
COREDUMPS=( /tmp/core!(*.txt) )
# The directory to contain output files and work directories.
# OUTPUTDIR is the directory to contain output files and
# work directories.
# For output from existing core files, the default is the
# directory that the core file is found in. For core files
# produced from a running process, the default is /tmp.
OUTPUTDIR=/tmp
# Date command for the "running" coredump and tarballs.
# DATEFORMAT will be executed to get the timestamp.
# Don't put quotes around the format string or they'll be
# treated as literal characters. Also be aware of colons
# in the output as you can't upload files with colons in
# the name to Jira.
# DATEOPTS is passed to the 'date' utility and is
# used to set the timestamp used to create the
# name of the output files and to rename the coredump.
#
# Unix timestamp
#DATEFORMAT='date +%s.%N'
#
# Unix timestamp on *BSD/MacOS after installing coreutils
#DATEFORMAT='gdate +%s.%N'
# Beware of colons in the output as you can't upload
# files with colons in the name to Jira.
# The preferred timestamp format is readable GMT.
#
# Readable GMT
#DATEFORMAT='date -u +%FT%H-%M-%S%z'
DATEOPTS='-u +%FT%H-%M-%SZ'
#
# Unix timestamp
#DATEOPTS='+%s.%N'
#
# Readable Local time
DATEFORMAT='date +%FT%H-%M-%S%z'
#DATEOPTS='+%FT%H-%M-%S%z'
#
# The following settings are used by ast_loggrabber
#
# A list of log files and/or log file search patterns using the
# same syntax as COREDUMPS.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
Subject: ast_coredumper
New options:
--pid=<asterisk_pid>
Allows specification of an Asterisk instance when trying to
and the script can't determine it itself.
--libdir=<system library directory>
Allows specification of a non-standard installation directory
containing the Asterisk modules.
--(no-)rename
Renames the coredump and the output files with readable
timestamps. This is the default.
Removed unneeded or confusing options:
--append-coredumps
--conffile
--no-default-search
--tarball-uniqueid
Changed Variables:
COREDUMPS is now just "/tmp/core!(*.txt)"
DATEFORMAT is renamed to DATEOPTS and defaults to '-u +%FT%H-%M-%SZ'
Changed behavior:
If you use 'running' or 'RUNNING' you no longer need to specify
'--no-default-search' to ignore existing coredumps.