Commit 0ca906ca authored by Benoit Rat's avatar Benoit Rat

bin: create a tool to easily recompile all the information of a WRS

The script can let the user to stream directly to stdout so it does not
create any file, or we can decide to gzip (compress) this stream to a
file so that we can download it afterward.

NOTE: For the moment we do not include the local syslog as it is not
enabled by default in rsyslog.in.
parent 571f69db
#!/bin/sh
#
# wrs_logdump
#
# Benoit Rat (benoit<AT>sevensols.com)
# date 03-Dec-2018
# Copyright (c) 2018 Seven Solutions S.L (www.sevensols.com)
#
# GNU Lesser General Public License Usage
# This file may be used under the terms of the GNU Lesser
# General Public License version 2.1 as published by the Free Software
# Foundation and appearing in the file LICENSE.LGPL included in the
# packaging of this file. Please review the following information to
# ensure the GNU Lesser General Public License version 2.1 requirements
# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#########################################################################
help()
{
cat << EOF
Usage: $(basename $0) [Options]
Options:
-h) Show this little help
-a) Show all outputs (verbose version)
-s) Stream on stdout only (no file created)
-f) Provide filename to download
-c) Delete files previously generated
EOF
exit 0
}
sep()
{
echo ""
echo ""
printf "###=================================== %-15s ======###\n" "$1"
echo ""
echo ""
}
streamall()
{
echo ${FILEPATTERN}
sep "version"
wrs_version -t
sep "wr_mon"
wr_mon -w
sep "dot-config"
cat /wr/etc/dot-config
sep "network"
ifconfig -a
route -n
sep "memory"
cat /proc/meminfo
echo ""
free -m
sep "system"
cat /proc/cmdline
echo ""
lsmod
echo ""
cat /proc/interrupts
sep "dmesg"
dmesg
sep "shmem"
wrs_dump_shmem
##Print /wr/etc/xxx.in
for f in $(find /wr/etc/ -iname "*.in"); do
sep "$(basename $f)"
cat $f
done
sep "wr_mon (2nd step)"
wr_mon -w
sep "interrupts (2nd step)"
cat /proc/interrupts
}
cleanauto()
{
rm -v /tmp/wrs-*_dumplog.gz
}
compress()
{
streamall 2>&1 | gzip > ${FILENAME}
if [ "x$?" = "x0" ]; then
FILESIZE=$(du -k "${FILENAME}" | cut -f1)
echo "Dumplog had been compressed properly to ${FILENAME} (${FILESIZE}Kb)"
exit 0
else
exit $?
fi
}
hostid()
{
printf "wrs-%s" $(wrs_version -t 2>/dev/null | grep serial-number | cut -d" " -f2)
}
FILEPATTERN="$(hostid)_"$(date +"%Y%m%d-%H%M")
FILENAME="/tmp/${FILEPATTERN}_dumplog.gz"
while [ $# -ge 1 ]; do
case $1 in
-c) cleanauto;;
-s) STREAM=1;;
-v) VERBOSE=1;;
-f) FILENAME=$2; shift;;
-h) help; exit;;
*) echo "Wrong arguments $@"; help; exit;;
esac
shift
done
if [ "x${STREAM}" = "x1" ]; then
streamall
else
compress
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment