mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
231 lines
5.4 KiB
Bash
Executable file
231 lines
5.4 KiB
Bash
Executable file
#!/bin/sh
|
|
# shellcheck shell=dash
|
|
|
|
# Location of system report temporary directory
|
|
SRDIR="/tmp/system-report"
|
|
|
|
|
|
configure() {
|
|
local preconf_path
|
|
preconf_path="$(realpath "$0")"
|
|
|
|
if ! cmp -s /usr/sbin/system-report "${preconf_path}" >/dev/null; then
|
|
echo "iopsys-test system-report differs from included with firmware, symlinking"
|
|
ln -sf "${preconf_path}" /usr/sbin/system-report
|
|
fi
|
|
|
|
if ! cmp -s /rom/usr/sbin/system-report /usr/sbin/system-report >/dev/null && ! grep -Fq "/usr/sbin/system-report" /etc/sysupgrade.conf; then
|
|
echo "iopsys-test system-report differs from included with firmware, adding to sysupgrade.conf"
|
|
echo "/usr/sbin/system-report" >>/etc/sysupgrade.conf
|
|
fi
|
|
}
|
|
|
|
run() {
|
|
set -x
|
|
|
|
# Alias ubus to have a smaller 5-second timeout on all subsequent calls
|
|
ubus() { command ubus -t 5 "$@"; }
|
|
|
|
mkdir -p "$SRDIR"
|
|
|
|
SRCF="$SRDIR/config"
|
|
SRSY="$SRDIR/system"
|
|
SRNT="$SRDIR/network"
|
|
SRTR="$SRDIR/tr069"
|
|
SRMD="$SRDIR/mem_dump"
|
|
|
|
# Config
|
|
echo "Gathering configuration data"
|
|
{
|
|
cat /etc/banner
|
|
|
|
echo "Installed Packages"
|
|
opkg list-installed
|
|
|
|
echo "Database"
|
|
db show
|
|
|
|
echo "Configuration"
|
|
uci show
|
|
} > "$SRCF"
|
|
|
|
# System
|
|
echo "Gathering system information"
|
|
{
|
|
echo "System Info"
|
|
ubus call system info
|
|
|
|
echo "Board Info"
|
|
ubus call system board
|
|
|
|
echo "Running Processes"
|
|
top -b -n 1
|
|
|
|
echo "Kernel Parameters"
|
|
sysctl -A 2>/dev/null
|
|
|
|
echo "System Log"
|
|
timeout 5 logread -l 1000
|
|
|
|
echo "Driver Message"
|
|
timeout 5 dmesg
|
|
|
|
echo "PCI Devices"
|
|
lspci -k
|
|
|
|
echo "Installed Modules"
|
|
lsmod
|
|
|
|
echo "CPU Info"
|
|
cat /proc/cpuinfo
|
|
|
|
echo "Memory Info"
|
|
cat /proc/meminfo
|
|
|
|
echo "Slab Info"
|
|
cat /proc/slabinfo
|
|
|
|
echo "Firmware banks"
|
|
ubus call fwbank dump
|
|
} > "$SRSY"
|
|
|
|
# Network
|
|
echo "Gathering network state"
|
|
{
|
|
echo "Device Status"
|
|
ubus call network.device status
|
|
|
|
echo "Hosts Status"
|
|
ubus call hosts show
|
|
|
|
echo "Topology"
|
|
ubus call ieee1905.topology dump
|
|
|
|
echo "Network Status"
|
|
ubus call network.interface dump
|
|
|
|
if [ -d /sys/class/ieee80211 ]; then
|
|
echo "Wireless Status"
|
|
ubus call network.wireless status
|
|
|
|
echo "Wireless Radio Status"
|
|
ubus call wifi status
|
|
|
|
echo "Get radio scan"
|
|
for radio_if in $(ubus list 'wifi.radio.*'); do
|
|
ubus call "${radio_if}" scan
|
|
sleep 2
|
|
ubus call "${radio_if}" scanresults
|
|
done
|
|
|
|
echo "Get Assoc List"
|
|
interfaces=$(uci show wireless | grep "ifname=" | awk -F'[.,=]' '{print$2}')
|
|
for int in $interfaces; do
|
|
mode=$(uci get "wireless.${int}.mode")
|
|
if [ "$mode" = "ap" ] ; then
|
|
ap_int=$(uci get "wireless.${int}.ifname")
|
|
echo "Get assoc list"
|
|
ubus call "wifi.ap.${ap_int}" assoclist
|
|
echo "Get station info"
|
|
ubus call "wifi.ap.${ap_int}" stations
|
|
fi
|
|
done
|
|
|
|
fi
|
|
|
|
if [ "$(db get hw.board.hasVoice)" = 1 ]; then
|
|
echo "voice status"
|
|
ubus call voice.asterisk status
|
|
fi
|
|
|
|
echo "IPv4 Routes"
|
|
ip -d r
|
|
|
|
echo "IPv6 Routes"
|
|
ip -d -6 r
|
|
|
|
echo "Neighbor Table"
|
|
ip n
|
|
|
|
echo "ARP Table"
|
|
cat /proc/net/arp
|
|
|
|
echo "IGMP Snooping Table"
|
|
ubus call mcast stats
|
|
|
|
echo "Conntrack Table"
|
|
cat /proc/net/nf_conntrack
|
|
|
|
echo "Network Interface Status"
|
|
ip -d a
|
|
|
|
echo "IPv4 Firewall Status"
|
|
iptables -xvnL
|
|
|
|
echo "IPv6 Firewall Status"
|
|
ip6tables -xvnL
|
|
|
|
echo "Bridge Info"
|
|
brctl show
|
|
|
|
if [ -f /tmp/multiap.backhaul ]; then
|
|
echo "Multi-AP Backhaul status"
|
|
cat /tmp/multiap.backhaul
|
|
fi
|
|
|
|
echo "TCP/UDP listened ports"
|
|
netstat -tlnp
|
|
netstat -ulnp
|
|
|
|
echo "MAC layer firewall status"
|
|
ebtables -t broute -L
|
|
|
|
echo "MAC layer firewall status list"
|
|
ebtables -L
|
|
|
|
echo "IEEE1905 info"
|
|
ubus call ieee1905 info
|
|
|
|
if [ -f /usr/bin/iwinfo ]; then
|
|
echo "iwinfo interface details"
|
|
/usr/bin/iwinfo
|
|
fi
|
|
|
|
} > "$SRNT"
|
|
|
|
# TR-069
|
|
echo "Gathering TR-069 state"
|
|
{
|
|
echo "TR-069 status"
|
|
ubus call tr069 status
|
|
|
|
echo "get all TR-181 Parameters"
|
|
ubus call bbfdm get '{"path":"Device."}'
|
|
|
|
echo "TR-069 Option 43 URL"
|
|
uci -P /var/state -q get cwmp.acs.url
|
|
|
|
echo "TR-069 Logs"
|
|
[ -f /var/log/icwmp ] && cat /var/log/icwmp
|
|
} > "$SRTR"
|
|
|
|
# Firmware RAM dump (IOP-8118)
|
|
if [ -f /tmp/mem_dump ]; then
|
|
mv /tmp/mem_dump "$SRMD"
|
|
fi
|
|
|
|
REPORT_PATH="$(dirname "${SRDIR}")"
|
|
REPORT_DIRNAME="$(basename "${SRDIR}")"
|
|
FILENAME="${REPORT_PATH}/system-report-$(date +%Y-%m-%d).tar.gz"
|
|
tar -cz -C "${REPORT_PATH}" -f "${FILENAME}" "${REPORT_DIRNAME}"
|
|
echo "Report is located at ${FILENAME}"
|
|
|
|
#ubus send "system-report" "{ \"filename\" : \"$FILENAME\" }"
|
|
|
|
rm -r "$SRDIR"
|
|
}
|
|
|
|
case "${1:-}" in
|
|
configure) configure ;;
|
|
*) run ;;
|
|
esac
|