-
Notifications
You must be signed in to change notification settings - Fork 164
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
debug: collect-info.sh enhancements #3467
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3467 +/- ##
=======================================
Coverage 20.29% 20.29%
=======================================
Files 198 198
Lines 45268 45268
=======================================
+ Hits 9188 9189 +1
+ Misses 35396 35395 -1
Partials 684 684 ☔ View full report in Codecov by Sentry. |
pkg/debug/scripts/collect-info.sh
Outdated
if [ ! -d "/persist" ]; then | ||
FIND=".log" | ||
|
||
if [ ! -z "$READ_LOGS_DEV" ]; then |
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.
@rouming , all these Yetus errors makes sense to fix.
|
||
exit | ||
fi | ||
|
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.
@rouming , some information that I still miss a lot from collect-info.sh is a list of /dev directory to see which file devices are present. I think we could take this opportunity to add this information (output of ls -l /dev
), would you mind to make this change as well in this PR?
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.
Yep, will add.
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.
The SC2156 is explitly ignored in the code, but yetus still complains. I don't have any desire to fight with the tool, so leave it as is.
arm64 build is failing due to eve-ipxe package. Maybe @jsfakian has some clue about this issue.... |
I tried it locally on my MacOS, and it seems to compile.
Could you try to restart the GitHub action to see if the problem continues? |
pkg/debug/scripts/collect-info.sh
Outdated
@@ -15,19 +15,26 @@ VERSION=7 | |||
# still attempt to install those packages. | |||
PKG_DEPS="procps tar dmidecode iptables dhcpcd" | |||
|
|||
DATE=$(date -Is) | |||
DATE=$(date "+%a-%d-%b-%Y-%H-%M-%S") |
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 have no issue with getting rid of the colons, but can we use a format which sorts properly (year, month, date) such as date "+%Y-%m-%d-%H-%M-%S"
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.
Of course
pkg/debug/scripts/collect-info.sh
Outdated
@@ -45,6 +58,30 @@ while getopts "vh" o; do | |||
esac | |||
done | |||
|
|||
# We are not on EVE? Switch to read-logs mode | |||
if [ ! -d "/persist" ]; then |
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.
Hmm - I have a /persist on my laptop.
Can we avoid making this assymption? E.g., by adding an -e (for extract) or -A (for All) for the case where you currently look for /persist?
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.
Let me do the opposite:
# We are not on EVE? Switch to read-logs mode
if [ -d "$SCRIPT_DIR/persist-newlog" ]; then
...
fi
The script is the part of the tarball. So the debugging procedure is the following:
tar -xf eve-info-v8-2023-09-27-08-45-19.tar.gz
./eve-info-v8-2023-09-27-08-45-19/collect-info.sh > all-logs.json
I would like to avoid any mode options, because the only thing you can do once the tarball is collected is to extract all the logs, collecting logs makes sense only when the script is on EVE. So there is no actually an option, no choice, the action is determined by the script placement. Ideally there should be another script, but I do not like this zoo of scripts as well.
8ce5607
to
7abd414
Compare
Exclude colon symbol from the date format which is the name of the result tarball, because tar utility complains with the following error on attempt to extract the folder: tar: Cannot connect to eve-info-v7-2023-09-22T14\: resolve failed Now the resulting tarball name will be as follows: eve-info-v8-2023-09-27-08-41-29.tar.gz which does not cause any nasty errors. Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
7abd414
to
f1c726f
Compare
Difference to the previous version:
|
f1c726f
to
7199bde
Compare
pkg/debug/scripts/collect-info.sh
Outdated
@@ -200,14 +201,18 @@ lsof > "$DIR/lsof" | |||
lsmod > "$DIR/lsmod" | |||
logread > "$DIR/logread" | |||
dmidecode > "$DIR/dmidecode" | |||
ls -la /dev > "$DIR/ls-la-dev" |
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.
there could be directories inside /dev as well, so I think it's better to add a -R: ls -lRa /dev
pkg/debug/scripts/collect-info.sh
Outdated
@@ -186,12 +186,13 @@ collect_pillar_backtraces() | |||
cp "${0}" "$DIR" | |||
|
|||
# Have to chroot, lsusb does not work from this container | |||
echo "- lsusb, dmesg, ps, lspci, lsblk, lshw, lsof, lsmod, logread, dmidecode" | |||
echo "- lsusb, dmesg, ps, lspci, lsblk, lshw, lsof, lsmod, logread, dmidecode, ls -la /dev, free" |
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 guess the "Subj." text in your commit message was left behind... you can remove it...
pkg/debug/scripts/collect-info.sh
Outdated
@@ -18,16 +18,24 @@ PKG_DEPS="procps tar dmidecode iptables dhcpcd" | |||
DATE=$(date "+%Y-%m-%d-%H-%M-%S") | |||
INFO_DIR="eve-info-v$VERSION-$DATE" | |||
TARBALL_FILE="/persist/$INFO_DIR.tar.gz" | |||
SCRIPT_DIR=$(dirname "$(readlink -f \"$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.
Please, fix yetus errors
7199bde
to
8600d25
Compare
pkg/debug/scripts/collect-info.sh
Outdated
# conversion. Also: | ||
# "-R (. as $line | try fromjson)" means ignore a line if is not a JSON, | ||
# "(nanos // 0)" means return 0 if nanos is null | ||
jq -R '(. as $line | try fromjson) | .timestamp_str.nanos = ((.timestamp.nanos // 0) + 1e9 | tostring | .[1:]) | .timestamp_str.human = (.timestamp.seconds | strftime("%B %d %Y %I:%M:%S")) | .timestamp_str = "\(.timestamp_str.human).\(.timestamp_str.nanos)"' |
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.
Could you please put to the comment an example of the transformed JSON entity? Something like:
{
"message": "Some log message",
"timestamp": {
"seconds": 1672444800,
"nanos": 123456789
},
"timestamp_str": {
"nanos": ".123456789",
"human": "January 01 2023 12:00:00"
}
}
It's a bit confusing with all the formats of the timestamps we have... The example will help to understand and to implement parsing scripts.
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.
Ii's a bit different, this is the output:
"timestamp": {
"seconds": 1677023830,
"nanos": 399834057
},
"timestamp_str": "February 21 2023 11:57:10.399834057"
Yes, I can describe why I create a new json entry and how it looks like.
8600d25
to
34bc9b5
Compare
34bc9b5
to
0f27088
Compare
Difference to the previous version:
|
pkg/debug/scripts/collect-info.sh
Outdated
@@ -122,12 +190,13 @@ collect_pillar_backtraces() | |||
cp "${0}" "$DIR" | |||
|
|||
# Have to chroot, lsusb does not work from this container | |||
echo "- lsusb, dmesg, ps, lspci, lsblk, lshw, lsof, lsmod, logread, dmidecode" | |||
echo "- lsusb, dmesg, ps, lspci, lsblk, lshw, lsof, lsmod, logread, dmidecode, ls -la /dev, free" |
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.
This string also needs to be updated: ls -la /dev
-> ls -lRa /dev
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.
Fixed. Now there are no excuses, Rene, not to approve :)
0f27088
to
cd9025e
Compare
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.
LGTM
We need a very simple command which can sort and read gzipped logs in one looooong sheet, which can be redirected to a JSON file and processed afterwards. Here it is: call collect-info.sh from the extracted tarball on your machine. collect-info.sh : reads all (device and all applications logs) and outputs in JSON collect-info.sh -d : reads device logs and outputs in JSON collect-info.sh -a UUID : reads application logs and outputs in JSON Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
…tputs Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
cd9025e
to
952e9ad
Compare
The PR does two things:
Change date format. Exclude colon symbol from the date format which is the name of the result tarball, because tar utility complains with the following error on attempt to extract the folder:
Now the resulting tarball name will be as follows:
which does not cause any nasty errors.
Add read-logs mode. We need a very simple command which can sort and read gzipped logs in one looooong sheet, which can be redirected to a JSON file and processed afterwards. Here it is: call collect-info.sh from the extracted tarball on your machine.
collect-info.sh : reads all (device and all applications logs) and outputs in JSON
collect-info.sh -d : reads device logs and outputs in JSON
collect-info.sh -a UUID : reads application logs and outputs in JSON
Add a few additional command and files outputs: ls -la /dev/, free, vmstat, iomem, /sys/fs/cgroup/memory