# Device Information Script

**URL:** <https://forum.alta.inc/t/device-information-script/5754>\
**Category:** General\
**Created:** [July 31, 2025, 1:54am UTC](https://forum.alta.inc/t/device-information-script/5754 "2025-07-31T01:54:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmszuch](https://forum.alta.inc/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jmszuch](https://forum.alta.inc/u/jmszuch)\
**Post date:** [July 31, 2025, 1:54am UTC](https://forum.alta.inc/t/device-information-script/5754/1 "2025-07-31T01:54:49Z")

</div>

Hopefully this is OK to post, but I’ve been tinkering with the idea of a script that could pull a bunch of information from an Alta Labs device, kinda like a support tool that some other vendors use to gather information to send to support. Although it’s mostly an information and log gathering tool at this point since I’m not much of a scripter!

Figured it was put together enough to post and see if it would help anyone or anyone else felt like tinkering with it. There’s probably some redundent commands or commands that pull excess information at this point but I didn’t feel like removing anything quite yet.

Credit to richb-hanover over here for the original script that I’ve just been tinkering with: [GitHub - richb-hanover/OpenWrtScripts: A set of scripts for maintaining and testing OpenWrt](https://github.com/richb-hanover/OpenWrtScripts?tab=readme-ov-file#getstatssh)

There’s some instructions in the script itself on putting it together, but generally I’ve done the following:

- Open the terminal
- Navigate to the cfg diretory `cd /cfg` since this will allow it to persist through reboots and things
- Run `cat > getstats.sh`
- Paste the contents of the script
- Press `Ctrl + D` a couple of times
- Run the script with `sh getstats.sh`
- Then it should spit out the file `/tmp/openwrtstats.txt` that can be further examined

And here’s the contents of the script itself plus an example of some of it’s output

```auto
#! /bin/sh
#
# getstats.sh - Collect diagnostic information about OpenWrt
# Write the data to a file (usually /tmp/openwrtstats.txt)
#
# Usage: sh getstats.sh ["command 1 to be executed" "command 2" "command 3" ...]
#
# *****To install and run this script*****
#
# SSH into your router and execute these statements. 
# 
# ssh root@192.168.1.1
# cd /tmp
# cat > getstats.sh 
# [paste in the contents of this file, then hit ^D]
# sh getstats.sh
# The results listed are written to the designated file
# (usually /tmp/openwrtstats.txt, unless redirected)
#
# License: GPL Copyright (c) 2013-2018 Rich Brown
#
# Based on Sebastian Moeller's original set of diagnostic info:
# https://lists.bufferbloat.net/pipermail/cerowrt-devel/2014-April/002871.html
# Based on alexmow's script to list user-installed packages
# https://forum.openwrt.org/t/script-to-list-installed-packages-for-simplifying-sysupgrade/7188/16

# File that will receive command results
out_fqn=/tmp/openwrtstats.txt

# ------- display_command() -------
# Format the command results into the output file
# Redirect both standard out and error out to that file.

display_command() { 
	echo "[$1]" >> $out_fqn
	eval "$1" >> $out_fqn 2>> $out_fqn
	echo -e "\n" >> $out_fqn
}

# ------- display_user_packages() ---------
# Display a list of all packages installed after the kernel was built

display_user_packages() {
  echo "[User-installed packages]" >> $out_fqn

  install_time=`opkg status kernel | awk '$1 == "Installed-Time:" { print $2 }'`
  opkg status | awk '$1 == "Package:" {package = $2} \
  $1 == "Status:" { user_inst = / user/ && / installed/ } \
  $1 == "Installed-Time:" && $2 != '$install_time' && user_inst { print package }' | \
  sort >> $out_fqn 2>> $out_fqn

  echo -e "\n" >> $out_fqn
} 

#--------dmesg---------
dmesg_human () {
	base=$(cut -d '.' -f1 /proc/uptime); 
	seconds=$(date +%s); 
	dmesg | sed 's/\]//;s/\[//;s/\([^.]\)\.\([^]*\)\(.*\)/\1\n\3/' | 
	while read first; do 
		read second; 
		first=`date +"%d/%m/%Y %H:%M:%S" --date="@$(($seconds - $base + $first))"`;
		printf "[%s] %s\n" "$first" "$second"; 
	done
}

#--------netstat--------
human_netstat() {
  awk '
    NR % 2 == 1 {
      prefix = $1
      for (i = 2; i <= NF; i++) header[i] = $i
    }
    NR % 2 == 0 {
      for (i = 2; i <= NF; i++)
        printf("%-25s %s\n", prefix " " header[i] ":", $i)
    }
  ' /proc/net/netstat
}

#-------modinfo----------
modinfo_dump() {
	for mod in $(lsmod | awk 'NR>1{print $1}'); do
	  echo "=== $mod ==="
	  modinfo "$mod"
	done
}

#------conntrack---------
conntrack_human() {
	conntrack -L -o timestamp -n | awk ' # scale raw packet/byte counts into K/M/G
  function human(v) {
    if (v >= 1e9) return sprintf("%.2fG", v/1e9)
    if (v >= 1e6) return sprintf("%.2fM", v/1e6)
    if (v >= 1e3) return sprintf("%.2fK", v/1e3)
    return v
  }

  {
    # split each key=value into kv array
    for (i=1; i<=NF; i++) {
      split($i, tmp, "=")
      kv[tmp[1]] = tmp[2]
    }

    # output aligned columns
    printf "%-23s %-5s %-21s -> %-21s %8s pkts %9s bytes\n",
      kv["timestamp"], kv["proto"],
      kv["src"]":"kv["sport"],
      kv["dst"]":"kv["dport"],
      human(kv["packets"]), human(kv["bytes"])

    delete kv
  }'

}

# ------- Main Routine -------

# Examine first argument to see if they're asking for help
if ["$1" == "-h"] || ["$1" == "--help"]
then
	echo 'Usage: sh $0 "command 1 to be executed" "command 2" "command 3" ... '
	echo ' '
	exit
fi

# Write a heading for the file

echo "===== $0 at `date` =====" > $out_fqn

# Display four sets of commands:
# 1. Common diagnostic commands
# 2. Additional user-supplied commands (from the command line)
# 3. User-installed opkg packages
# 4. Longer/less common diagnostic output

# 1. Display the common diagnostic commands
# These are read from the list delimited by "EOF"

while read LINE; do
    display_command "$LINE"
done << EOF
cat /etc/banner
date
cat /etc/openwrt_release
uname -a
uptime
top -b | head -n 20
du -sh / ; du -sh /*
cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/partitions
df -h
mount
EOF

# 2. Extract arguments from the command line and display them.
while [$# -gt 0] 
do
	display_command "$1" 
	shift 1
done

# 3. Display user-installed opkg packages
display_user_packages

# 4. Display the long/less frequently-needed commands

while read LINE; do
    display_command "$LINE"
done << EOF
cat /etc/config/network
cat /etc/config/dhcp
cat /etc/config/firewall
dmesg_human
cat /proc/net/dev
ip -s link
netstat -tuln
human_netstat
conntrack_human
display_command "lsmod"
display_command "modinfo_dump"
display_command "uci show firewall"
display_command "iptables-save"
display_command "ip6tables-save"
display_command "ip route"
display_command "arp -n"
display_command "ubus call system board"
display_command "ubus call system info"
display_command "ubus call network.interface.lan status"
display_command "uci show network"
display_command "wg show all"
display_command "ps | grep -E 'ipsec|openvpn'"
display_command "cat /var/log/messages | tail -n 100"
EOF

# End the report
echo "===== end of $0 =====" >> $out_fqn

#cat $out_fqn
echo "Done... Diagnostic information written to $out_fqn"
echo " "

# Now press Ctl-D, then type "sh getstats.sh"

```

---

<div class="post-metadata">

**Author:** ![jmszuch](https://forum.alta.inc/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jmszuch](https://forum.alta.inc/u/jmszuch)\
**Post date:** [July 31, 2025, 1:57am UTC](https://forum.alta.inc/t/device-information-script/5754/2 "2025-07-31T01:57:46Z")

</div>

And now some of that example output, although quite abreviated since I was hitting the character limit 😅

```auto
cat /tmp/openwrtstats.txt 
===== getstats.sh at Wed Jul 30 21:02:13 EDT 2025 =====
[cat /etc/banner]
--------------------------------------------------------------------

                |‾ ‾| /\ | ‾‾|‾‾ /\
                | /\ | / \ | | / \
                | / \ | / _\ |___ | /_ \
                | / \ |
                |_ _| L A B S

--------------------------------------------------------------------
  Shell access is provided solely for debugging assistance. Please
  be aware that Alta Labs is not responsible for commands that may
  damage the device, void the warranty, or extend functionality
  beyond Alta Labs' intended scope.

        Remember, with great power comes great responsibility.
--------------------------------------------------------------------

[date]
Wed Jul 30 21:02:13 EDT 2025

[cat /etc/openwrt_release]
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='21.02.1'
DISTRIB_REVISION='1.4h'
DISTRIB_TARGET='ipq95xx/generic'
DISTRIB_ARCH='aarch64_cortex-a73_neon-vfpv4'
DISTRIB_DESCRIPTION='OpenWrt 21.02.1 r16325-88151b8303'
DISTRIB_TAINTS='no-all busybox'

[uname -a]
Linux HomeRouter 5.4.213 #0 SMP PREEMPT Sun Oct 24 09:01:35 2021 aarch64 GNU/Linux

[uptime]
 21:02:13 up 14:27, load average: 0.02, 0.07, 0.06

[top -b | head -n 20]
Mem: 521608K used, 480708K free, 17768K shrd, 388K buff, 17980K cached
CPU: 0% usr 0% sys 0% nic 100% idle 0% io 0% irq 0% sirq
Load average: 0.03 0.07 0.07 2/152 4231
  PID PPID USER STAT VSZ %VSZ %CPU COMMAND
  723 2 root IW 0 0% 0% [kworker/0:3-eve]
12992 7361 suricata S 2194m 224% 0% {Suricata-Main} /.deb/lib/ld-linux-aarch64.so.1 /usr/bin/.suricata --user suricata --group suricata -i br-lan -i br-lan_11 -i br-lan_100
23755 1 nobody S 15196 2% 0% /usr/sbin/https-dns-proxy -r https://cloudflare-dns.com/dns-query -a 127.0.0.1 -p 5054 -b 1.1.1.1,1.0.0.1 -4 -u nobody -g nogroup
23756 1 nobody S 15112 2% 0% /usr/sbin/https-dns-proxy -r https://dns.google/dns-query -a 127.0.0.1 -p 5053 -b 8.8.8.8,8.8.4.4 -4 -u nobody -g nogroup
23757 1 nobody S 14920 1% 0% /usr/sbin/https-dns-proxy -r https://doh.opendns.com/dns-query -a 127.0.0.1 -p 5055 -b 208.67.222.222,208.67.220.220 -4 -u nobody -g nogroup
 8875 1 root SN 9348 1% 0% /usr/sbin/rcstats
 8783 1 root S 8424 1% 0% /usr/sbin/rc
 7332 1 root S 8128 1% 0% /usr/sbin/ips -n 1 -b 0
 7987 1 root S 6796 1% 0% /usr/sbin/route-swd
 3270 1 root S 6796 1% 0% /usr/sbin/filter
 8831 1 root SN 6796 1% 0% /usr/sbin/rcmon
10309 1 root S 6080 1% 0% /usr/sbin/uhttpd -f -h /www -r HomeRouter -x /cgi-bin -l /be -L /lib/sh/lua -t 60 -T 30 -k 20 -A 1 -n 3 -N 100 -D -p 0.0.0.0:80 -p [::]:80 -s 0.0.0.0:443 -s [::]:443 -C /etc/uhttpd.crt -K /etc/uhttpd.key -s 0.0.0.0:443 -s [::]:443 -q
 7029 1 dnsmasq S 3268 0% 0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01411c.pid
 5612 5516 root S 2180 0% 0% ip -6 monitor route
 5636 5515 root S 2180 0% 0% ip -4 monitor route
 3650 1 root S 1916 0% 0% /sbin/netifd

[du -sh / ; du -sh /*]
2.1G	/
2.0G	/a
724.0K	/bin
666.0K	/cfg
0	/dev
2.7M	/etc
4.0K	/init
16.0M	/lib
0	/lib64
0	/mnt
0	/overlay
0	/proc
4.0K	/rom
0	/root
700.0K	/sbin
0	/sys
1.2M	/tmp
70.0M	/usr
0	/var
612.0K	/www

[cat /proc/cpuinfo]
processor	: 0
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x1
CPU part	: 0xd09
CPU revision	: 0

processor	: 1
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x1
CPU part	: 0xd09
CPU revision	: 0

processor	: 2
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x1
CPU part	: 0xd09
CPU revision	: 0

processor	: 3
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x1
CPU part	: 0xd09
CPU revision	: 0

[cat /proc/meminfo]

[display_command "modinfo_dump"]
[modinfo_dump]

[display_command "ip route"]
[ip route]

[display_command "arp -n"]
[arp -n]

[display_command "ubus call system board"]
[ubus call system board]
{
	"initramfs": true,
	"kernel": "5.4.213",
	"hostname": "HomeRouter",
	"system": "ARMv8 Processor rev 0",
	"model": "Qualcomm Technologies, Inc. IPQ9574/Alta-Route10",
	"board_name": "qcom,ipq9574-alta-route10",
	"release": {
		"distribution": "OpenWrt",
		"version": "21.02.1",
		"revision": "1.4h",
		"target": "ipq95xx/generic",
		"description": "OpenWrt 21.02.1 r16325-88151b8303"
	}
}

[display_command "ubus call system info"]
[ubus call system info]
{
	"localtime": 1753909335,
	"uptime": 52055,
	"load": [
		1728,
		4864,
		4480
	],
	"memory": {
		"total": 1026371584,
		"free": 490483712,
		"shared": 18329600,
		"buffered": 536576,
		"available": 394588160,
		"cached": 18546688
	},
	"swap": {
		"total": 2147479552,
		"free": 1059581952
	}
}

[display_command "ubus call network.interface.lan status"]
[ubus call network.interface.lan status]
{
	"up": true,
	"pending": false,
	"available": true,
	"autostart": true,
	"dynamic": false,
	"uptime": 52042,
	"l3_device": "br-lan",
	"proto": "static",
	"device": "br-lan",
	"updated": [
		"addresses"
	],
	"metric": 0,
	"dns_metric": 0,
	"delegation": true,
	"ipv4-address": [

[display_command "uci show network"]
[uci show network]
network.loopback=interface
network.loopback.device='lo'
network.loopback.proto='static'
network.loopback.ipaddr='127.0.0.1'
network.loopback.netmask='255.0.0.0'
network.@device[0]=device
network.@device[0].name='eth3'
network.@device[0].mtu='1500'
network.wan=interface
network.wan.ifname='eth3'
network.wan.metric='200'
network.wan.dns_metric='200'
network.wan.proto='dhcp'
network.wan.norelease='1'

[display_command "wg show all" # WireGuard]
[wg show all]

[display_command "ps | grep -E 'ipsec|openvpn'"]
[ps | grep -E 'ipsec|openvpn']
 5065 root 1300 S grep -E ipsec|openvpn

[display_command "cat /var/log/messages | tail -n 100"]
[cat /var/log/messages | tail -n 100]

```

---

<div class="post-metadata">

**Author:** ![jmszuch](https://forum.alta.inc/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jmszuch](https://forum.alta.inc/u/jmszuch)\
**Post date:** [October 2, 2025, 2:08pm UTC](https://forum.alta.inc/t/device-information-script/5754/3 "2025-10-02T14:08:43Z")

</div>

Appending to my post here, it sounds like running `cat /cfg/config.json` might be a decent way to pulling a devices configuration to share if needed:

> [@Can' make IPSec VPN or Wireguard work anymore since several updates ago](https://forum.alta.inc/t/can-make-ipsec-vpn-or-wireguard-work-anymore-since-several-updates-ago/6085/5):
>
> It looks like charon is not running at all, which usually indicates that a VPN server is not configured. Can you grab the output of “cfg”, and send your (redacted) /cfg/config.json file via DM?

Copying the output into something like Visual Studio Code worked as a decent way to format the JSON into something more readable. Hopefully that proves helpful to someone somewhere down the line 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum.alta.inc/uploads/default/original/1X/087669c3d7c0a6495087b41d6f385a6771f2231c.png) [@system](https://forum.alta.inc/u/system)\
**Post date:** [June 11, 2026, 6:26am UTC](https://forum.alta.inc/t/device-information-script/5754/4 "2026-06-11T06:26:02Z")

</div>


