-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy patharmbian-debug
More file actions
executable file
·160 lines (147 loc) · 5.48 KB
/
armbian-debug
File metadata and controls
executable file
·160 lines (147 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
#
# armbian-debug
#
# Collect and upload system debug information for Armbian support.
# Part of the Armbian project - https://www.armbian.com
#
############################################################################
# Config:
declare -a paste_servers=("paste.armbian.com" "paste.next.armbian.com" "paste.armbian.de")
if [[ "${PASTE_SERVER_HOST}" != "" ]]; then
echo "Using custom paste server: '${PASTE_SERVER_HOST}'"
paste_servers=("${PASTE_SERVER_HOST}" "${paste_servers[@]}")
fi
# Set up colors if available
if test -t 1; then
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
BOLD="$(tput bold)"
NC='\033[0m' # No Color
fi
fi
Main() {
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Check if curl is available, install if not
if ! command -v curl > /dev/null 2>&1; then
echo "curl not found in PATH. Trying to install it..." >&2
if [ "$(id -u)" = "0" ]; then
apt-get -f -y install curl
else
echo "Please install curl: sudo apt-get install curl" >&2
exit 1
fi
fi
# 5 second countdown with option to force stdout output
force_stdout=false
echo -e "\n${BOLD}Collecting debug information for Armbian support${NC}"
echo -e "Press any key within 5 seconds to output to stdout instead of uploading..."
for i in {5..1}; do
echo -ne "\r$i seconds remaining... "
# Read with timeout (works in bash)
if read -s -n 1 -t 1; then
force_stdout=true
echo -e "\n${BOLD}Key pressed - will output to stdout${NC}\n"
break
fi
done
if [ "$force_stdout" = false ]; then
echo -e "\rStarting upload... "
fi
# Collect and process the info
if [ "$force_stdout" = true ]; then
# Output to stdout with line numbers
CollectSupportInfo |
sed -E 's/([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3})/XXX.XXX.\3\4/g' |
awk '!NF{$0=" "}1' | nl -
echo -e "\nPlease upload the ${BOLD}whole output${NC} above to an online pasteboard service\nand provide the URL in the forum where you have been asked for this.\n"
else
# Try to upload to paste servers
upload_success=false
for paste_server in "${paste_servers[@]}"; do
echo "Collecting info and sending to ${paste_server}..."
declare -i counter=0
{
LC_ALL=C date
echo "-----------------------------------------------------------------------------------------------------------------------------"
dmesg --color=always
echo "-----------------------------------------------------------------------------------------------------------------------------"
CollectSupportInfo || echo "Error collecting support info"
} |
sed -E 's/([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3})/XXX.XXX.\3\4/g' |
curl -s --fail --data-binary @- "https://${paste_server}/log"
# Save PIPESTATUS before any other command
pipe_status=("${PIPESTATUS[@]}")
# Check PIPESTATUS
for i in "${pipe_status[@]}"; do
counter=$((counter + 1))
if [[ $i -ne 0 ]]; then
echo "Failed (pipe ${counter} returned ${i})."
continue 2
fi
done
# If we get here, upload succeeded
upload_success=true
break
done
if [ "$upload_success" = true ]; then
echo -e "\n${BOLD}Upload successful!${NC} Please post the URL at the place where you have been asked for.\n"
else
echo -e "\n${BOLD}All upload attempts failed. Outputting to stdout instead:${NC}\n"
CollectSupportInfo |
sed -E 's/([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3})/XXX.XXX.\3\4/g' |
awk '!NF{$0=" "}1' | nl -
echo -e "\nPlease upload the ${BOLD}whole output${NC} above to an online pasteboard service\nand provide the URL in the forum where you have been asked for this.\n"
fi
fi
}
CollectSupportInfo() {
[[ -s /var/log/armbian-hardware-monitor.log ]] && cat /var/log/armbian-hardware-monitor.log || zcat /var/log/armbian-hardware-monitor.log.1.gz 2> /dev/null
[[ -f /boot/armbianEnv.txt ]] && LOGLEVEL=$(awk -F'=' '/^verbosity/ {print $2}' /boot/armbianEnv.txt)
LOGLEVEL=${LOGLEVEL:-1}
if [ "$LOGLEVEL" -gt 4 ]; then
VERBOSE='-v'
which lshw > /dev/null 2>&1 && (
echo -e "\n### lshw:"
lshw -quiet -sanitize -numeric
)
fi
lsusb > /dev/null 2>&1 && (
echo -e "\n### lsusb:\n"
lsusb ${VERBOSE} 2> /dev/null
echo ""
lsusb -t 2> /dev/null
)
lspci > /dev/null 2>&1 && (
echo -e "\n### lspci:\n"
lspci ${VERBOSE} 2> /dev/null
)
nvme > /dev/null 2>&1 && (
echo -e "\n### nvme:\n"
nvme list 2> /dev/null
)
[ -z "$SUDO_USER" ] || echo -e "\n### Group membership of $(groups "$SUDO_USER")"
echo -en "\n### Userland"
[[ -f /etc/armbian-release ]] && echo -en " generated with Armbian Build Framework"
echo -en ":\n"
echo -e "\n$(grep PRETTY_NAME /etc/os-release)"
echo -e "\n### Installed packages:\n\n$(dpkg -l | grep -E "openmediavault|armbian| linux-")"
echo -e "\n### Loaded modules:\n\n$(lsmod)"
[[ -f /var/log/nand-sata-install.log ]] && echo -e "\n### nand-sata-install.log:\n\n$(cat /var/log/nand-sata-install.log)"
echo -e "\n### Current sysinfo:\n\n$(command -v iostat >/dev/null 2>&1 && iostat -p ALL | grep -v "^loop")\n\n$(vmstat -w)\n\n$(free -h)\n\n$(zramctl 2> /dev/null)\n\n$(uptime)\n\n$(dmesg | tail -n 250)"
echo -e "\n"
if [[ "$(id -u)" -eq "0" ]]; then
for sysfsnode in /proc/sys/vm/*; do
sysctl "${sysfsnode/\/proc\/sys\/vm\//vm.}"
done
fi
echo -e "\n### interrupts:\n$(cat /proc/interrupts)"
ls /tmp/armbianmonitor_checks_* > /dev/null 2>&1 || return 0
for file in /tmp/armbianmonitor_checks_*; do
echo -e "\n### \c"
ls "${file}" | cut -f1 -d.
echo
cat "${file}"
done
} # CollectSupportInfo
Main "$@"