mirror of
https://github.com/richb-hanover/OpenWrtScripts.git
synced 2026-03-30 10:44:32 +02:00
Cleaned up script, final list of "standard commands"
This commit is contained in:
parent
d1c8877de3
commit
de9d6ec07a
1 changed files with 37 additions and 28 deletions
65
getstats.sh
65
getstats.sh
|
|
@ -1,9 +1,9 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# getstats.sh - Collect diagnostic information when troubles arise.
|
||||
# getstats.sh - Collect diagnostic information about OpenWrt.
|
||||
# Write the data to a file (usually /tmp/openwrtstats.txt)
|
||||
#
|
||||
# ***** To run this script *****
|
||||
# ***** To install and run this script *****
|
||||
#
|
||||
# SSH into your router and execute these statements.
|
||||
#
|
||||
|
|
@ -14,65 +14,74 @@
|
|||
# sh getstats.sh
|
||||
# You should see the results listed on-screen
|
||||
#
|
||||
# License: GPL Copyright (c) 2013-2016 Rich Brown
|
||||
#
|
||||
# Based on Sebastian Moeller's original from:
|
||||
# https://lists.bufferbloat.net/pipermail/cerowrt-devel/2014-April/002871.html
|
||||
#
|
||||
# The script defaults to writing stats in /tmp/openwrtstats.txt
|
||||
# Change for your circumstances
|
||||
|
||||
# Output file name
|
||||
out_fqn=/tmp/junk.txt
|
||||
# Redirect command
|
||||
outfile="2>&1 >>$out_fqn"
|
||||
# eval echo xx $outfile
|
||||
# File that will receive command results
|
||||
out_fqn=/tmp/openwrtstats.txt
|
||||
|
||||
# echo "Number of arguments is $#; $1"
|
||||
eval echo "===== Output from $0 at `date` =====" > $out_fqn
|
||||
# ------- 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
|
||||
echo "[ $1 ]" >> $out_fqn
|
||||
eval "$1" >> $out_fqn 2>> $out_fqn
|
||||
echo -e "\n" >> $out_fqn
|
||||
}
|
||||
|
||||
# ------- Main Routine -------
|
||||
|
||||
# Look to see if they're asking for help
|
||||
if [ "$1" == "-h" ]
|
||||
# Examine first argument to see if they're asking for help
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--help" ]
|
||||
then
|
||||
echo 'Usage: sh getstats.sh "command 1 to be executed" "command 2" "command 3" ... '
|
||||
echo 'Usage: sh $0 "command 1 to be executed" "command 2" "command 3" ... '
|
||||
echo ' '
|
||||
exit
|
||||
fi
|
||||
|
||||
# Handle the standard set of commands first
|
||||
|
||||
# Write a heading for the file
|
||||
|
||||
echo "===== $0 at `date` =====" > $out_fqn
|
||||
|
||||
|
||||
# Display the standard set of commands
|
||||
# These are read from the list delimited by "EOF"
|
||||
|
||||
while read LINE; do
|
||||
# echo "$LINE"
|
||||
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 /*
|
||||
ifconfig
|
||||
logread
|
||||
dmesg
|
||||
EOF
|
||||
|
||||
#logread
|
||||
#dmesg
|
||||
#cat /etc/openwrt_release
|
||||
|
||||
# extract options and their arguments into variables.
|
||||
# Extract arguments from the command line and display them.
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
display_command "$1"
|
||||
shift 1
|
||||
done
|
||||
|
||||
echo "Done... Stats written to ${out_fqn} (${0})"
|
||||
|
||||
# End the report
|
||||
echo "===== end of $0 =====" >> $out_fqn
|
||||
|
||||
|
||||
#cat $out_fqn
|
||||
echo "Done... Stats written to $out_fqn"
|
||||
echo " "
|
||||
clear
|
||||
#cat ${out_fqn}
|
||||
echo "Output is also in ${out_fqn}"
|
||||
|
||||
# Now press Ctl-D, then type "sh getstats.sh"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue