Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ansible_lza_rosetta_app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
ansible_lza_rosetta_app
Commits
fd6a5ffa
Commit
fd6a5ffa
authored
2 years ago
by
Jörg Sachse
Browse files
Options
Downloads
Patches
Plain Diff
doc: show help, show manpage, create manpage file
parent
c747a3fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
files/error-summary.sh
+101
-37
101 additions, 37 deletions
files/error-summary.sh
with
101 additions
and
37 deletions
files/error-summary.sh
+
101
−
37
View file @
fd6a5ffa
...
@@ -4,15 +4,52 @@
...
@@ -4,15 +4,52 @@
# AUTHORS:
# AUTHORS:
# - Jörg Sachse (<Joerg.Sachse@slub-dresden.de>)
# - Jörg Sachse (<Joerg.Sachse@slub-dresden.de>)
# - Jens Steidl (<Jens.Steidl@slub-dresden.de>)
# - Jens Steidl (<Jens.Steidl@slub-dresden.de>)
# INVOCATION:
# ./error_summary.sh [-h] [-n NUM] [-d DAYS] [-w] [-c]
#hh error_summary.sh - aggregate Rosetta Errors by error type
#hh
#hh Usage: error_summary.sh [-h] [-V] [-m] [-n NUM] [-d DAYS] [-w] [-c]
#hh
#hh Options:
#hh You can use the following CLI arguments to configure the behaviour of
#hh error-summary.sh. Please note that the CLI arguments need to be space
#hh separated. Combining arguments like "-cw" is currently NOT supported.
#hh
#hh -h, --help
#hh Show this help and exit.
#hh -V, --version
#hh Show version number and exit.
#hh -m, --man, --manpage, --manual
#hh Create a manpage from this help section and exit.
#hh Requires "help2man".
#hh -M, --showman
#hh Print the Manpage.
#hh Requires "help2man".
#hh -n, --chars NUMBER_OF_CHARS
#hh Set max length of error message lines.
#hh Default: 200
#hh -d, --days NUMBER_OF_DAYS
#hh Set how many days back the error summary should go through the
#hh logs.
#hh Default: 10
#hh -w, --warn
#hh Count Warnings as well as Errors.
#hh Default: unset (only count Errors)
#hh -c, --class
#hh Instead of a fixed message length, summarize and print errors
#hh by their respective Java class names. If this option is set,
#hh "-n|--chars" is ignored.
#hh Defaut: unset (use message length)
#hh
#hh Examples:
#hh error-summary.sh -n 50 -w -d 15 Cut messages after 50 characters, count warnings as well, filter logs from the last 15 days.
#hh error-summary.sh -w -c Count Erros AND Warnings, count messages by their respective Java class names.
### DEFAULTS
### DEFAULTS
HOW_MANY_CHARS
=
200
HOW_MANY_CHARS
=
200
HOW_MANY_DAYS
=
10
HOW_MANY_DAYS
=
10
WARN
=
""
# Default: do not filter for Warnings, only show Errors
WARN
=
""
# Default: do not filter for Warnings, only show Errors
FILTER_STRING
=
" (ERROR
${
WARN
}
)
\s
+
\[
.{0,
${
HOW_MANY_CHARS
}
}"
# get correct log path, this differs between servers
# get correct log path, this differs between servers
if
[[
-d
"/operational_shared/logs/
${
HOSTNAME
}
.slub-dresden.de/"
]]
;
then
if
[[
-d
"/operational_shared/logs/
${
HOSTNAME
}
.slub-dresden.de/"
]]
;
then
...
@@ -28,43 +65,66 @@ for REQUIREMENT in ${REQUIREMENTS}; do
...
@@ -28,43 +65,66 @@ for REQUIREMENT in ${REQUIREMENTS}; do
done
done
### CLI ARGUMENTS
### FUNCTIONS
# for ARG in "$@"; do
while
[[
$#
-gt
0
]]
;
do
case
${
1
}
in
-h
|
--help
)
echo
"call help function here"
exit
0
;;
-n
|
--chars
)
HOW_MANY_CHARS
=
"
${
2
}
"
shift
;
shift
;
;;
-d
|
--days
)
HOW_MANY_DAYS
=
"
${
2
}
"
shift
;
shift
;
;;
-w
|
--warn
)
COUNT_WARNINGS
=
"true"
shift
;
;;
-c
|
--class
)
PRINT_ONLY_CLASSNAMES
=
"true"
shift
;
;;
*
)
echo
"'
${
1
}
' is not a valid parameter. Please use '
$(
basename
"
${
0
}
"
)
--help'. Exiting."
exit
1
;;
esac
done
# Don't just call this function "help()", as that's a reserved command in Bash.
comment_help
()
{
sed
-rn
's/^#hh ?//;T;p'
"
$0
"
}
create_manpage
(){
# https://www.gnu.org/software/help2man/
help2man
--section
1
--source
=
"SLUB Dresden"
--no-info
"
${
0
}
"
|
gzip
>
./
"
$(
basename
"
${
0
}
"
".sh"
)
.gz"
}
### FUNCTIONS
show_manpage
(){
help2man
--section
1
--source
=
"SLUB Dresden"
--no-info
"
${
0
}
"
| man
-l
-
}
# thx @Steidl!
get_cli_args
(){
# grep -o "STARTZEICHENKETTE..\{ANZAHL_ZEICHEN_NACH_STARTZEICHENKETTE\}" | sort | uniq -c | sort -nr
while
[[
$#
-gt
0
]]
;
do
case
${
1
}
in
-h
|
--help
)
comment_help
exit
0
;;
-V
|
--version
)
echo
"
$(
basename
"
${
0
}
"
)
v1.0.0"
echo
-e
"
\n\n
Copyright (C)
\n
"
echo
"This software is licensed under the GNU General Public License version 3 (GNU GPLv3)."
exit
0
;;
-m
|
--man
|
--manpage
|
--manual
)
create_manpage
exit
0
;;
-M
|
--showman
)
show_manpage
exit
0
;;
-n
|
--chars
)
HOW_MANY_CHARS
=
"
${
2
}
"
shift
;
shift
;
;;
-d
|
--days
)
HOW_MANY_DAYS
=
"
${
2
}
"
shift
;
shift
;
;;
-w
|
--warn
)
COUNT_WARNINGS
=
"true"
shift
;
;;
-c
|
--class
)
PRINT_ONLY_CLASSNAMES
=
"true"
shift
;
;;
*
)
echo
"'
${
1
}
' is not a valid parameter. Please use '
$(
basename
"
${
0
}
"
)
--help'. Exiting."
exit
1
;;
esac
done
}
set_filter_string
(){
set_filter_string
(){
if
[[
"
${
COUNT_WARNINGS
}
"
==
"true"
]]
;
then
if
[[
"
${
COUNT_WARNINGS
}
"
==
"true"
]]
;
then
...
@@ -78,6 +138,8 @@ set_filter_string(){
...
@@ -78,6 +138,8 @@ set_filter_string(){
fi
fi
}
}
# thx @Steidl!
# grep -o "STARTZEICHENKETTE..\{ANZAHL_ZEICHEN_NACH_STARTZEICHENKETTE\}" | sort | uniq -c | sort -nr
get_last_n_days
(){
get_last_n_days
(){
LOGFILES
=
"
$(
find
"
${
SERVER_LOG_DIR
}
/"
-maxdepth
1
-mtime
-
"
${
HOW_MANY_DAYS
}
"
-name
"server.log*"
)
"
LOGFILES
=
"
$(
find
"
${
SERVER_LOG_DIR
}
/"
-maxdepth
1
-mtime
-
"
${
HOW_MANY_DAYS
}
"
-name
"server.log*"
)
"
for
LOGFILE
in
${
LOGFILES
}
;
do
for
LOGFILE
in
${
LOGFILES
}
;
do
...
@@ -97,12 +159,14 @@ get_last_n_days(){
...
@@ -97,12 +159,14 @@ get_last_n_days(){
### MAIN
### MAIN
get_cli_args
"
${
@
}
"
echo
""
echo
""
echo
"USING THE FOLLOWING SETTINGS:"
echo
"USING THE FOLLOWING SETTINGS:"
echo
-e
"
\t
SERVERNAME: '
${
HOSTNAME
}
'"
echo
-e
"
\t
SERVERNAME: '
${
HOSTNAME
}
'"
echo
-e
"
\t
FILTERING LOGS FROM
$(
date
-d
"
${
HOW_MANY_DAYS
}
days ago"
+%Y-%m-%d
)
UNTIL
$(
date
-d
today +%Y-%m-%d
)
"
echo
-e
"
\t
FILTERING LOGS FROM
$(
date
-d
"
${
HOW_MANY_DAYS
}
days ago"
+%Y-%m-%d
)
UNTIL
$(
date
-d
today +%Y-%m-%d
)
"
echo
-e
"
\t
HOW MANY CHARACTERS:
${
HOW_MANY_CHARS
}
"
echo
-e
"
\t
HOW MANY CHARACTERS:
${
HOW_MANY_CHARS
}
"
echo
-en
"
\t
COUNT WARNINGS: "
;
[[
"
${
WARN
}
"
==
"
|WARN
"
]]
&&
echo
"yes"
||
echo
"no"
echo
-en
"
\t
COUNT WARNINGS: "
;
[[
"
${
COUNT_WARNINGS
}
"
==
"
true
"
]]
&&
echo
"yes"
||
echo
"no"
set_filter_string
set_filter_string
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment