-
Notifications
You must be signed in to change notification settings - Fork 59
tools: sof-kernel-log-check: use journalctl command to query kernel log #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,9 @@ fi | |
| func_lib_setup_kernel_last_line() | ||
| { | ||
| # shellcheck disable=SC2034 # external script will use it | ||
| KERNEL_LAST_LINE=$(wc -l /var/log/kern.log|awk '{print $1;}') | ||
| KERNEL_LAST_LINE=$(journalctl --dmesg --no-pager -n 1 -o short-iso-precise|awk '/kernel/ {print $1;}') | ||
| KERNEL_LAST_LINE=${KERNEL_LAST_LINE:0:-5} | ||
| KERNEL_LAST_LINE=${KERNEL_LAST_LINE/T/ } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be a comment explaining what this removes and why. It's surprising to drop such a critical piece of information. |
||
| } | ||
|
|
||
| SOF_LOG_COLLECT=0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,39 @@ | ||
| #!/bin/bash | ||
|
|
||
| begin_line=${1:-1} | ||
| begin_time="${@:-0}" | ||
| declare err_str ignore_str project_key | ||
| err_str="error|failed|timed out|panic|oops" | ||
| ignore_str="error: debugfs write failed to idle -16|error: status|iteration [01]" | ||
| project_key="sof-audio" | ||
|
|
||
| [[ ! "$err_str" ]] && echo "Missing error keyword list" && exit 0 | ||
| # dmesg KB size buffer size | ||
| #dmesg_config_define=$(awk -F '=' '/CONFIG_LOG_BUF_SHIFT/ {print $2;}' /boot/config-$(uname -r)) | ||
| #dmesg_buffer_size=$( echo $(( (1<<$dmesg_config_define) / 1024 )) ) | ||
| # kernel file log buffer size | ||
| #kernel_buffer_size=$(du -k /var/log/kern.log |awk '{print $1;}') | ||
| # now decide using which to catch the kernel log | ||
| #[[ $kernel_buffer_size -lt $dmesg ]] && cmd="dmesg" || cmd="sed -n '$begin_line,\$p' /var/log/kern.log" | ||
| [[ ! "$err_str" ]] && { | ||
| echo "Missing error keyword list" | ||
| exit 0 | ||
| } | ||
|
|
||
| # confirm begin_line is number, if it is not the number, direct using dmesg | ||
| [[ "${begin_line//[0-9]/}" ]] && begin_line=0 | ||
| [[ "$begin_line" -eq 0 ]] && cmd="dmesg" || cmd="sed -n '$begin_line,\$p' /var/log/kern.log" | ||
|
|
||
| #echo "run $0 with parameter '$*' for check kernel message error" | ||
| if [ "X$begin_time" == "X0" ]; then | ||
| cmd="dmesg" | ||
| else | ||
| date -d "$begin_time" +'%F %T' > /dev/null || { | ||
| echo "Error parameter for date: $begin_time" | ||
| echo "Support date format: date +'%F %T'" | ||
| exit 0 | ||
| } | ||
| cmd="journalctl --dmesg --no-pager --no-hostname -o short-precise --since='$begin_time'" | ||
| fi | ||
|
|
||
| if [ "$ignore_str" ]; then | ||
| err=$(eval $cmd|grep 'Call Trace' -A5 -B3)$(eval $cmd | grep $project_key | grep -E "$err_str"|grep -vE "$ignore_str") | ||
| err=$("$cmd" |grep 'Call Trace' -A5 -B3)$("$cmd" | grep $project_key | grep -E "$err_str"|grep -vE "$ignore_str") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please submit these cleanups first and separately so they don't noise the functional changes later. |
||
| else | ||
| err=$(eval $cmd|grep 'Call Trace' -A5 -B3)$(eval $cmd | grep $project_key | grep -E "$err_str") | ||
| err=$("$cmd" |grep 'Call Trace' -A5 -B3)$("$cmd" | grep $project_key | grep -E "$err_str") | ||
| fi | ||
|
|
||
| if [ "$err" ]; then | ||
| echo `date -u '+%Y-%m-%d %T %Z'` "[ERROR]" "Caught dmesg error" | ||
| echo "$(date -u '+%F %T %Z') [ERROR] Caught dmesg error" | ||
| echo "===========================>>" | ||
| echo "$err" | ||
| echo "<<===========================" | ||
| builtin exit 1 | ||
| exit 1 | ||
| fi | ||
|
|
||
| builtin exit 0 | ||
| exit 0 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my system this prints the boot time (uptime -s) which doesn't seem to match what was before.
Should this simply be
KERNEL_LAST_LINE=$(date)?I like that you're trying to save a lot of changed lines by keeping the KERNEL_LAST_LINE name the same, however there should be a big fat warning comment saying "This is not a line anymore"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rename the whole thing as KERNEL_LAST_TIMESTAMP in PR #354