Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ffho-packages
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Freifunk Hochstift
ffho-packages
Commits
88658d37
Commit
88658d37
authored
10 years ago
by
Michael Schwarz
Browse files
Options
Downloads
Patches
Plain Diff
Rewritten ffpb-debug with lua, implemented sending of stored report
parent
5fabad2c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ffpb/ffpb-debug/files/bin/ffpb-debug
+120
-80
120 additions, 80 deletions
ffpb/ffpb-debug/files/bin/ffpb-debug
ffpb/ffpb-debug/files/bin/ffpb-send-stored-debug
+0
-20
0 additions, 20 deletions
ffpb/ffpb-debug/files/bin/ffpb-send-stored-debug
with
120 additions
and
100 deletions
ffpb/ffpb-debug/files/bin/ffpb-debug
+
120
−
80
View file @
88658d37
#!/bin/
sh
#!/
usr/
bin/
lua
debugdata
=
""
ATH9K_DEBUGFS_DIR
=
"/sys/kernel/debug/ieee80211/phy0/ath9k"
local
=
false
while
getopts
l opt
do
case
$opt
in
l
)
local
=
true
;;
esac
done
-- wrapper for calling systemcommands
function
cmd
(
_command
)
local
f
=
io.popen
(
_command
)
local
l
=
f
:
read
(
"*a"
)
f
:
close
()
return
"--- START COMMAND "
..
_command
..
" ---\n"
..
l
..
"--- END COMMAND "
..
_command
..
" ---\n\n"
end
if
!
$local
;
then
export
tf
=
"
$(
mktemp
-t
ffpb-debug.XXXXXX
)
"
exec
3>&2
>
"
$tf
"
2>&1
fi
-- read contents of a given file
function
readFile
(
_file
)
local
f
=
io.open
(
_file
,
"r"
)
if
f
~=
nil
then
local
l
=
f
:
read
(
"*a"
)
f
:
close
()
return
"--- BEGIN OF FILE "
..
_file
..
" ---\n"
..
l
..
"--- END OF FILE "
..
_file
..
" ---\n\n"
else
return
""
end
end
sysinfo
()
{
echo
-en
"Hostname = "
uname
-n
echo
-en
"Gluon Release = "
cat
/lib/gluon/release
echo
-en
"Node Model = "
cat
/tmp/sysinfo/model
echo
-en
"Uptime = "
uptime
echo
-en
"Timestamp = "
date
}
-- iterate through list
function
list_iter
(
_table
)
local
i
=
0
local
n
=
table
.
getn
(
_table
)
return
function
()
i
=
i
+
1
if
i
<=
n
then
return
_table
[
i
]
end
end
end
cmd
()
{
echo
"--- START
$*
---"
"
$@
"
echo
"--- END (
$?
)
$*
---"
echo
}
localMode
=
false
read_file_content
()
{
echo
"--- START OF FILE CONTENT (
$*
) ---"
/bin/cat
"
$@
"
echo
"--- END OF FILE CONTENT (
$*
) ---"
echo
}
-- Should we enter local mode?
if
arg
[
1
]
==
'-l'
then
localMode
=
true
end
cmd sysinfo
cmd ip addr show
cmd ip route show
cmd iw phy phy0 info
cmd iw dev wlan0 info
cmd iw dev wlan0 station dump
cmd iw dev wlan0-1 station dump
cmd /usr/bin/iwinfo phy0 scan
cmd /usr/bin/iwinfo wlan0 info
cmd /usr/bin/iwinfo wlan0-1 info
cmd /usr/bin/iwinfo wlan0 assoclist
cmd /usr/bin/iwinfo wlan0-1 assoclist
if
[
-d
$ATH9K_DEBUGFS_DIR
]
;
then
# data required for gluon "wifi blackout" bug-reports as requested in
# https://github.com/freifunk-gluon/gluon/issues/130
for
filename
in
reset queues interrupt
;
do
read_file_content
"
${
ATH9K_DEBUGFS_DIR
}
/
${
filename
}
"
done
sleep
10
&&
read_file_content
"
${
ATH9K_DEBUGFS_DIR
}
/interrupt"
# ... and some additional debug data
for
filename
in
ani base_eeprom dma dump_nfcal misc modal_eeprom phy_err recv xmit
;
do
read_file_content
"
${
ATH9K_DEBUGFS_DIR
}
/
${
filename
}
"
done
fi
cmd batctl gwl
cmd batctl tl
killall
-USR1
fastd 2>/dev/null
cmd logread
-- search for existing debugreport.txt
local
debugFile
=
io.open
(
"/tmp/debugreport.txt"
,
"r"
)
if
debugFile
==
nil
then
-- no existing debugreport, let's generate a new one
-- inform the User ;)
print
(
'Hello, i will gather some information about your node now.'
)
print
(
'This may take some seconds, please stand by.'
)
-- first of all, collect some generic information about the system
debugdata
=
debugdata
..
cmd
(
"uname -n"
)
debugdata
=
debugdata
..
cmd
(
"cat /lib/gluon/release"
)
debugdata
=
debugdata
..
cmd
(
"cat /tmp/sysinfo/model"
)
debugdata
=
debugdata
..
cmd
(
"uptime"
)
debugdata
=
debugdata
..
cmd
(
"date"
)
-- now get some information about the network status
debugdata
=
debugdata
..
cmd
(
"ip addr show"
)
debugdata
=
debugdata
..
cmd
(
"ip route show"
)
-- get wireless status
debugdata
=
debugdata
..
cmd
(
"iw phy phy0 info"
)
debugdata
=
debugdata
..
cmd
(
"iw dev wlan0 info"
)
debugdata
=
debugdata
..
cmd
(
"iw dev wlan0 station dump"
)
debugdata
=
debugdata
..
cmd
(
"iw dev wlan0-1 station dump"
)
debugdata
=
debugdata
..
cmd
(
"iwinfo phy0 scan"
)
debugdata
=
debugdata
..
cmd
(
"iwinfo wlan0 info"
)
debugdata
=
debugdata
..
cmd
(
"iwinfo wlan0-1 info"
)
debugdata
=
debugdata
..
cmd
(
"iwinfo wlan0 assoclist"
)
debugdata
=
debugdata
..
cmd
(
"iwinfo wlan0-1 assoclist"
)
-- try to get some more information about wlan hardware status
_files
=
{
"reset"
,
"queues"
,
"interrupt"
}
for
file
in
list_iter
(
_files
)
do
debugdata
=
debugdata
..
readFile
(
ATH9K_DEBUGFS_DIR
..
"/"
..
file
)
end
-- sleep ten seconds and read interrupt again
os.execute
(
"sleep 10"
)
debugdata
=
debugdata
..
readFile
(
ATH9K_DEBUGFS_DIR
..
"/interrupt"
)
_files
=
{
"ani"
,
"base_eeprom"
,
"dma"
,
"dump_nfcal"
,
"misc"
,
"modal_eeprom"
,
"phy_err"
,
"recv"
,
"xmit"
}
for
file
in
list_iter
(
_files
)
do
debugdata
=
debugdata
..
readFile
(
ATH9K_DEBUGFS_DIR
..
"/"
..
file
)
end
-- get batman status
debugdata
=
debugdata
..
cmd
(
"batctl gwl"
)
debugdata
=
debugdata
..
cmd
(
"batctl tl"
)
-- finally get fastd status
os.execute
(
"killall -USR1 fastd 2>/dev/null"
)
debugdata
=
debugdata
..
cmd
(
"logread"
)
-- write debugreport to file
debugFile
=
io.open
(
"/tmp/debugreport.txt"
,
"w"
)
debugFile
:
write
(
debugdata
)
debugFile
:
close
()
else
print
(
'I found an old debugreport.'
)
end
if
$local
;
then
echo
"No information has been sent to the ffpb-team."
-- if local mode is requested print the report, otherwise send it to the admin team
siteConfig
=
require
(
"gluon.site_config"
)
if
localMode
then
print
(
'As requested, i will not send the report, here it is:'
)
print
(
debugdata
)
os.exit
(
0
)
else
exec
>
&3 2>&1
print
(
'Sending report to Admin-Team ...'
)
local
reportSent
=
false
local
port
=
siteConfig
.
debugserver
.
port
for
host
in
list_iter
(
siteConfig
.
debugserver
.
host
)
do
print
(
'Trying '
..
host
)
if
os.execute
(
"cat /tmp/debugreport.txt | nc "
..
host
..
" "
..
port
)
and
reportSent
==
false
then
reportSent
=
true
end
end
echo
"Sending report (stored in
$tf
) to ffpb-team ..."
HOST
=
$(
lua
-e
'print(require("gluon.site_config").debugserver.host)'
)
PORT
=
$(
lua
-e
'print(require("gluon.site_config").debugserver.port)'
)
code
=
`
gzip
-c
$tf
| nc
$HOST
$PORT
`
if
[
$?
-eq
0
]
;
then
echo
"Report-ID:
$code
"
if
reportSent
then
print
()
os.execute
(
"rm /tmp/debugreport.txt"
)
print
(
'Report was sent, the Adminteam has been informed.'
)
print
(
'My job is done, good bye'
)
else
echo
"Failed to send report :( but storing the file and sending it later
\o
/"
mkdir
-p
/var/cache/ff/debug
gzip
-c
"
$tf
"
>
/var/cache/ff/debug/stored.ff-debug.gz
fi
#TODO: rm "$tf"
fi
print
(
'Sorry, i could\'
t
send
the
report
.
I
will
try
it
again
')
print('
when
this
script
will
be
invoked
the
next
time
.
')
print('
Good
bye
')
end
end
This diff is collapsed.
Click to expand it.
ffpb/ffpb-debug/files/bin/ffpb-send-stored-debug
deleted
100755 → 0
+
0
−
20
View file @
5fabad2c
#!/bin/sh
#
# Stefan Kloepping <northalpha@c3pb.de>
# -- Do 29 Mai 21:21:55 2014
#
stored_debug_file
=
'/var/cache/ff/debug/stored.ff-debug.gz'
#if file is not present, there is nothing to do
if
[
!
-f
"{
$stored_debug_file
}"
]
;
then
exit
0
fi
#send stored debug data to server
HOST
=
$(
lua
-e
'print(require("gluon.site_config").debugserver.host)'
)
PORT
=
$(
lua
-e
'print(require("gluon.site_config").debugserver.port)'
)
code
=
$(
nc
$HOST
$PORT
<
"
${
stored_debug_file
}
"
)
if
[
$?
=
0
]
;
then
echo
"Report number:
${
code
}
"
>
/var/cache/ff/debug/lastreport.code
rm
-f
--
"
${
stored_debug_file
}
"
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment