Greetings folks!
If you are working on device drivers for Linux/Android we do rely on dmesg for almost all of the times. But you know the dmesg buffer is limited, its circular buffer. So what ever overflows the buffer is lost for good (?). We feel need to increase the buffer size but its not trivial task and also most of the times enough is just not enough!
Here are some simple scripts for Linux to log dmesg continuously and dump into file and at the same time you can monitor changes in dmesg!
Give exe permissions to script and run as bellow,
$sudo ./ldmesg.sh
Now, dmesg is getting continuously logged in dmesg.log file in current directory. Next script needs to be run in another terminal tab/window which will monitor changes in dmesg (actually dmesg.log).
Give exe permissions to script and run as bellow,
$./mdmesg.sh
Image bellow shows dmesg being monitored.
For Android developers, here is ldmesg modified to use it over adb,
-- Cheers!!
If you are working on device drivers for Linux/Android we do rely on dmesg for almost all of the times. But you know the dmesg buffer is limited, its circular buffer. So what ever overflows the buffer is lost for good (?). We feel need to increase the buffer size but its not trivial task and also most of the times enough is just not enough!
Here are some simple scripts for Linux to log dmesg continuously and dump into file and at the same time you can monitor changes in dmesg!
Give exe permissions to script and run as bellow,
$sudo ./ldmesg.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# log dmesg to local dmesg.log file with human readable time stamp | |
while true; do | |
sleep 1 | |
dmesg -Tc >> dmesg.log; | |
done |
Give exe permissions to script and run as bellow,
$./mdmesg.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# monitor changes in dmesg (actually dmesg.log)on stdout | |
watch "cat dmesg.log | tail -20" |
For Android developers, here is ldmesg modified to use it over adb,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# log dmesg to local dmesg.log file with human | |
# readable time stamp for Android | |
while true; do | |
sleep 1 | |
adb shell dmesg -Tc >> dmesg.log; | |
done |
-- Cheers!!
0 comments:
Post a Comment