I am loosing connection to my Raspberry Pi 3 in a very much random way.
I recently replaced Subsonic by Airsonic, and connection to Pi seemed to be much more stable since that exact day. But today, it happened one more time... as I was expecting! Time to troubleshoot has come.
Since I am using 2 tables to root my traffic, one of them is not updated on some interface up/down events. I made a small script called by cron every 5 minutes to understand things and rebooting Pi once a day to get the access back:
#!/usr/bin/env bash
# Script to monitor and restart wireless access point when needed
# Logging
date >> NetworkCheckLog
echo "wap_check_pmd: Checking if network connection is down..." >> NetworkCheckLog
echo "$ ip route show table main" >> NetworkCheckLog
ip route show table main >> NetworkCheckLog
echo "$ ip route show table 42" >> NetworkCheckLog
ip route show table 42 >> NetworkCheckLog
# First make sure we can resolve google, otherwise 'ping -w' would hang
if ! $(host -W5 www.google.com > /dev/null 2>&1); then
#Make a note in syslog
logger "wap_check_pmd: Network connection is down..."
date >> NetworkCheckLog
ifconfig >> NetworkCheckLog
echo "wap_check_pmd: Network connection is down..." >> NetworkCheckLog
exit
fi
Time when it got fucked:
Mon 6 Aug 08:55:01 CEST 2018
wap_check_pmd: Checking if network connection is down...
$ ip route show table main
0.0.0.0/1 via 10.8.7.1 dev tun0
default via 192.168.1.1 dev wlan0 src 192.168.1.200 metric 303
10.8.8.0/24 dev tun0 proto kernel scope link src 10.8.7.12 31.192.112.170 via 192.168.1.1 dev wlan0
128.0.0.0/1 via 10.8.7.1 dev tun0
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.200 metric 303
$ ip route show table 42 default via 192.168.1.1 dev wlan0 src 192.168.1.200 metric 303
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.200 metric 303
Mon 6 Aug 09:00:01 CEST 2018
wap_check_pmd: Checking if network connection is down...
$ ip route show table main
0.0.0.0/1 via 10.8.7.1 dev tun0
default via 192.168.1.1 dev wlan0 src 192.168.1.200 metric 303
10.8.8.0/24 dev tun0 proto kernel scope link src 10.8.7.12
128.0.0.0/1 via 10.8.7.1 dev tun0
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.200 metric 303
$ ip route show table 42
Mon 6 Aug 09:00:15 CEST 2018
wap_check_pmd: Network connection is down...
I then checked /var/log/syslog:
Aug 6 08:59:26 raspberrypi dhcpcd[382]: wlan0: carrier lost
[...]
Aug 6 08:59:26 raspberrypi dhcpcd[382]: wlan0: deleting default route via 192.168.1.1
Aug 6 08:59:26 raspberrypi dhcpcd[382]: wlan0: deleting route to 192.168.1.0/24
[...]
Aug 6 08:59:51 raspberrypi dhcpcd[382]: wlan0: carrier acquired
Use this command to read the current power saving mode of your Pi:
$ sudo iw wlan0 get power_save
Power save: on
And this one to turn power_save off:
$ sudo iw wlan0 set power_save off
To make this permanent add the following line to /etc/rc.local:
/sbin/iw dev wlan0 set power_save off
We will see if it helps :)
Update 27/10/2018
I choose to turn the power_save off as it originally was. But I came up with this script:
#!/bin/bash
#/home/pi/wap_check
# Script to monitor and restart wireless access point when needed
maxPloss=10 #Maximum percent packet loss before a restart
# Logging
# echo "$(date +"%d-%m-%y %H:%M:%S ") wap_check_pmd: Checking if network connection is down..." >> /home/pi/NetworkCheckLog
# If table 42 is empty, we lost raspberry
TABLE_42_eth0=$(ip route show table 42 | grep eth0)
TABLE_42_wlan0=$(ip route show table 42 | grep wlan0)
# addapt following "if" and TABLE_42_xxx variables above depending on your interfaces
if [[ -z "${TABLE_42_eth0}" ]] || [[ -z "${TABLE_42_wlan0}" ]]; then
# Loging
echo "$(date +"%d-%m-%y %H:%M:%S ") wap_check_pmd: Table 42 is (partialy?) empty! Trying to populate it:" >> /home/pi/NetworkCheckLog
logger "wap_check_pmd: Table 42 is (partialy?) empty! Trying to populate it."
# Purge table 42 just in case
sudo ip route flush table 42
# Filling up the table 42
ip route show table main | grep -v tun0 | while read LINE; do sudo ip route add $LINE table 42; done
sleep 1
ip route show table 42 >> /home/pi/NetworkCheckLog
fi
# IP cannot be the same, debian-transmission can go only through tun0
IP_VPN=$(sudo -u debian-transmission wget -qO- ifconfig.co)
IP_PUBLIC=$(wget -qO- ifconfig.co)
if [[ "${IP_VPN}" = "${IP_PUBLIC}" ]]; then
echo "$(date +"%d-%m-%y %H:%M:%S ") wap_check_pmd: Same IP for debian-transmission and pi: $(echo $IP_VPN) and $(echo $IP_PUBLIC)" >> /home/pi/NetworkCheckLog
logger "wap_check_pmd: Same IP for debian-transmission and pi..."
if [[ -n "${IP_PUBLIC}" ]]; then
echo "$(date +"%d-%m-%y %H:%M:%S ") wap_check_pmd: Rebooting. [1]" >> /home/pi/NetworkCheckLog
logger "wap_check_pmd: Rebooting. [1]"
sleep 1
sudo /sbin/reboot
exit
fi
fi
# Make sure we can resolve google, otherwise 'ping -w' would hang
if ! $(host -W5 www.google.com > /dev/null 2>&1); then
# Make a note in syslog
logger "wap_check_pmd: Network connection is down..."
echo "$(date +"%d-%m-%y %H:%M:%S ") wap_check_pmd: Rebooting. [2]" >> /home/pi/NetworkCheckLog
logger "wap_check_pmd: Rebooting. [2]"
# Restart device
sleep 1
sudo /sbin/reboot
exit
fi
# Initialize to a value that would force a restart
# (just in case ping gives an error and ploss doesn't get set)
ploss=101
# now ping google for 10 seconds and count packet loss
ploss=$(ping -q -w10 www.google.com | grep -o "[0-9]*%" | tr -d %) > /dev/null 2>&1
if [ "$ploss" -gt "$maxPloss" ]; then
logger "wap_check_pmd: Packet loss ($ploss%) exceeded $maxPloss"
echo "$(date +"%d-%m-%y %H:%M:%S ") wap_check_pmd: Packet loss ($ploss%) exceeded $maxPloss" >> /home/pi/NetworkCheckLog
# restart_networking
fi
I run this script every 5 minutes, line in my crontab file:
*/5 * * * * /bin/bash /home/pi/NetworkCheck.sh
Log file looks like this:
22-09-18 22:25:02 wap_check_pmd: Table 42 is empty! Trying to populate it:
22-09-18 22:26:55 wap_check_pmd: Same IP for debian-transmission and pi: and
22-09-18 22:27:09 wap_check_pmd: Rebooting. [2]
24-09-18 23:20:16 wap_check_pmd: Rebooting. [2]
25-09-18 22:26:10 wap_check_pmd: Packet loss (30%) exceeded 10
25-09-18 23:11:07 wap_check_pmd: Packet loss (16%) exceeded 10
04-10-18 02:55:12 wap_check_pmd: Packet loss (70%) exceeded 10
04-10-18 15:50:01 wap_check_pmd: Table 42 is empty! Trying to populate it:
default via 192.168.1.1 dev wlan0 src 192.168.1.200 metric 303
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.200 metric 303
04-10-18 19:20:12 wap_check_pmd: Packet loss (20%) exceeded 10
04-10-18 20:40:27 wap_check_pmd: Packet loss (30%) exceeded 10
04-10-18 20:55:21 wap_check_pmd: Packet loss (16%) exceeded 10
05-10-18 20:20:01 wap_check_pmd: Table 42 is empty! Trying to populate it:
default via 192.168.1.1 dev wlan0 src 192.168.1.200 metric 303
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.200 metric 303
05-10-18 20:52:25 wap_check_pmd: Packet loss (30%) exceeded 10
06-10-18 15:15:15 wap_check_pmd: Packet loss (30%) exceeded 10
07-10-18 08:55:02 wap_check_pmd: Same IP for debian-transmission and pi: and
16-10-18 19:21:53 wap_check_pmd: Same IP for debian-transmission and pi: and
16-10-18 19:22:07 wap_check_pmd: Rebooting. [2]
27-10-18 11:30:20 wap_check_pmd: Packet loss (20%) exceeded 10
#All big files goes to folder Mixes
for file in /path/to/Music/youtube/*; do
SIZE="$(stat --printf="%s" "$file")"
if (( $SIZE > 25000000 )); then
mv -f "$file" /path/to/Music/Mixes
fi
done
Source homemade. Now execute it with cron job by example.
Switching to yt-dlp
youtube-dl is notmaintained anymore. It now fails with "Unable to extract uploader id" error using version 2021.12.17. yt-dlp is a youtube-dl fork based on the now inactive youtube-dlc. The main focus of this project is adding new features and patches while also keeping up to date with the original project.
Use SSH to connect to Raspberry Pi. Run the following command to download the latest version of yt-dlp from GitHub repository:
$ sudo systemctl status airsonic
● airsonic.service - Airsonic Media Server
Loaded: loaded (/etc/systemd/system/airsonic.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-01-18 21:09:56 CET; 20min ago
Main PID: 538 (java)
Tasks: 33 (limit: 1597)
CPU: 3min 15.474s
CGroup: /system.slice/airsonic.service
└─538 /usr/bin/java -Xmx700m -Dairsonic.home=/var/airsonic -Dserver.context-path=/airsonic -Dserver.port=8080 -jar /var/airsonic/airsonic.war
Jan 18 21:11:50 raspberrypi java[538]: 2022-01-18 21:11:50.554 INFO --- l.l.StandardLockService : Successfully released change log lock
Jan 18 21:11:51 raspberrypi java[538]: 2022-01-18 21:11:51.540 INFO --- o.a.p.service.SettingsService : Java: 1.8.0_312, OS: Linux
Jan 18 21:11:53 raspberrypi java[538]: 2022-01-18 21:11:53.290 INFO --- org.airsonic.player.Application : Detected Tomcat web server
Jan 18 21:12:31 raspberrypi java[538]: 2022-01-18 21:12:31.557 INFO --- o.a.p.service.PodcastService : Automatic Podcast update scheduled to run every 24 hour(s), starting at Tue Jan 18 21:17:31 CET 2022
Jan 18 21:12:33 raspberrypi java[538]: 2022-01-18 21:12:33.840 INFO --- o.a.p.s.search.IndexManager : Index was found (index version 18).
Jan 18 21:12:33 raspberrypi java[538]: 2022-01-18 21:12:33.900 INFO --- o.a.p.s.MediaScannerService : Automatic media library scanning scheduled to run every 1 day(s), starting at 2022-01-19T03:00:00.887
Jan 18 21:13:03 raspberrypi java[538]: 2022-01-18 21:13:03.363 INFO --- org.airsonic.player.Application : Started Application in 154.011 seconds (JVM running for 170.609)
Jan 18 21:17:31 raspberrypi java[538]: 2022-01-18 21:17:31.553 INFO --- o.a.p.service.PodcastService : Starting scheduled Podcast refresh.
Jan 18 21:17:31 raspberrypi java[538]: 2022-01-18 21:17:31.565 INFO --- o.a.p.service.PodcastService : Completed scheduled Podcast refresh.
Jan 18 21:18:01 raspberrypi java[538]: 2022-01-18 21:18:01.772 INFO --- o.a.p.f.BootstrapVerificationFilter : Servlet container: Apache Tomcat/8.5.51
$
Using USB storage devices and FAT32&NTFS filesystems
Connect to router using SSH
# opkg update
# opkg install kmod-usb-storage
# opkg install usbutils
# lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
|__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
To add support of FAT32 and NTFS (not tested yet) usb flash/disk drives:
# opkg install kmod-fs-vfat ntfs-3g
Then go to the LuCI administration page, System > Mount points, and configure :
An improvement that could be useful is to design a parcel shelf (plage-arrière) in wood in order to put the gaz cooker on it and be able to cook at the back of the car during rainy days. We thankfully didn't get any rainy days except the very first one of the trip.
It could be nice to take two folding chairs to sit anywhere you stop. But I don't know where to store it while sleeping...
Verser la levure, le sel et le sucre dans un verre doseur. Ajouter 1/4 de litre d'eau tiède, bien mélanger. Couvrir d'un film plastique et laisser reposer environ 10 minutes (jusqu'à l'apparition d'une mousse brune bien épaisse en surface).
Verser la farine dans un grand saladier et y faire un puits.
Verser le mélange du verre doseur dans le saladier, mélanger à la main. Puis quand la pâte n'est plus collante pétrir environ 5 minutes à la main sur une surface farinée.Arroser d'un peu d'huile d'olive, puis pétrir à nouveau environ 5 minutes.
Laisser reposer au moins 1 h sous un linge humide dans un endroit tiède (à côté d'un radiateur, d'une cheminée ou d'un poêle en hiver).
Après repos, pétrir quelques instants puis diviser la pâte en trois boules égales (on peut en congeler).
Etaler la pâte sur une surface farinée.
Make the pizza
Switch on the oven at 180°C.
Spread mustard everywhere on the base.
Slice tomatoes and put it on the base.
Mix an egg with tomato paste and pour it on the tomatoes.
Disperse herbs and pepper on the tomatoes.
Grate cheese (Emmental) and disperse it.
Add sliced peperoni/salami.
Put the pizza in the oven for 20min.
If you compare with Insanity MAX:30 nutrition plan:
Am X 0 2 2 1 0
Dm X X 0 2 3 1
E 0 2 2 1 0 0
F 1 3 3 2 1 1
ms
Am Dm E Am
Больше нечего ловить - все, что надо я поймал,
Am Dm E Am
Надо сразу уходить, чтоб никто не привыкал.
Am Dm E Am
Ярко-желтые очки, два сердечка на брелке,
F Dm E E
Развеселые зрачки, твое имя на руке.
Припев:
Am Dm E Am
Районы, кварталы, жилые массивы,
F Dm E Am
Я ухожу, ухожу красиво.
Am Dm E Am
Районы, кварталы, жилые массивы,
F Dm E Am
Я ухожу, ухожу красиво.
Am Dm E Am
У тебя все будет класс, будут ближе облака,
Am Dm E Am
Я хочу как в первый раз и поэтому пока.
Am Dm E Am
Ярко-желтые очки, два сердечка на брелке,
F Dm E E
Развеселые зрачки, я шагаю налегке.
Припев:
Am Dm E Am
Районы, кварталы, жилые массивы,
F Dm E Am
Я ухожу, ухожу красиво.
Am Dm E Am
Районы, кварталы, жилые массивы,
F Dm E Am
Я ухожу, ухожу красиво.
Am Dm E Am
Вот и все никто не ждет и никто не в дураках,
Am Dm E Am
Кто-то любит, кто-то врет и летает в облаках.
Am Dm E Am
Ярко-желтые очки, два сердечка на брелке,
F Dm E E
Развеселые зрачки, я шагаю налегке.
Припев:
Am Dm E Am
Районы, кварталы, жилые массивы,
F Dm E Am
Я ухожу, ухожу красиво.
Am Dm E Am
Районы, кварталы, жилые массивы,
F Dm E Am
Я ухожу, ухожу красиво.
Am Dm E Am
Районы, кварталы, жилые массивы,
F Dm E Am
Я ухожу, ухожу красиво.
Am Dm E Am
Районы, кварталы, жилые массивы,
F Dm E Am
Я ухожу, ухожу красиво.
Capo 2
Am 0 0 2 2 1 0
C 0 3 2 0 1 0
Em 0 2 2 0 0 0
D 0 0 0 2 3 2
ms
Like the legend of the phoenix, huh
All ends with beginnings
What keeps the planets spinning, uh huh
The force from the beginning, huh, look
We've come too far
To give up who we are
So let's raise the bar
And our cups to the stars
She's up all night 'til the sun
I'm up all night to get some
She's up all night for good fun
I'm up all night to get lucky
We're up all night 'til the sun
We're up all night to get some
We're up all night for good fun
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
The present has no ribbon
Your gift keeps on giving
What is this I'm feeling?
If you want to leave, I'm with it, uh huh
We've come too far
To give up who we are
So let's raise the bar
And our cups to the stars
She's up all night 'til the sun
I'm up all night to get some
She's up all night for good fun
I'm up all night to get lucky
We're up all night 'til the sun
We're up all night to get some
We're up all night for good fun
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get
We're up all night to get
We're up all night to get
We're up all night to get
We're up all night to get
We're up all night to get
We're up all night to get
We're up all night to get
We're up all night to get together
We're up all night to get (Oh, we might get funked again)
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
(We're up all night to get lucky) We've come too far
(We're up all night to get lucky) To give up
(We're up all night to get lucky) Who we are
(We're up all night to get lucky) So let's
(We're up all night to get lucky) Raise the bar
(We're up all night to get lucky) And our cups
(We're up all night to get lucky) To the stars
(We're up all night to get lucky)
She's up all night 'til the sun
I'm up all night to get some
She's up all night for good fun
I'm up all night to get lucky
We're up all night 'til the sun
We're up all night to get some
We're up all night for good fun
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
We're up all night to get lucky
Bm 7 9 9 7 7 7
A 5 7 7 6 5 5
Em X 7 9 9 8 7
e|---------|
B|---------|
G|---------|
D|---------|
A|-7-------|
E|---7-9-8-|
ms
Spoken:
Te lo dije muy clarito
12 de la noche en La Habana, Cuba
11 de la noche en San Salvador, El Salvador
11 de la noche en Managua, Nicaragua
Me gustan los aviones, me gustas tú,
me gusta viajar, me gustas tú,
me gusta la mañana, me gustas tú,
me gusta el viento, me gustas tú,
me gusta soñar, me gustas tú,
me gusta la mar, me gustas tú,
Qué voy a hacer, je ne sais pas
qué voy a hacer, je ne sais plus,
qué voy a hacer, je suis perdu
¿qué horas son mi corazón?,
Me gusta la moto, me gustas tú,
me gusta correr, me gustas tú,
me gusta la lluvia, me gustas tú,
me gusta volver, me gustas tú,
me gusta marihuana, me gustas tú,
me gusta colombiana, me gustas tú,
me gusta la montaña, me gustas tú,
me gusta la noche (me gustas tú).
Qué voy a hacer, je ne sais pas
qué voy a hacer, je ne sais plus,
qué voy a hacer, je suis perdu
¿qué horas son mi corazón?,
Spoken: Doce, un minuto
Me gusta la cena, me gustas tú,
me gusta la vecina, me gustas tú,
(Spoken: Radio reloj: una de la mañana)
me gusta su cocina, me gustas tú,
me gusta camelar, me gustas tú,
me gusta la guitarra, me gustas tú,
me gusta el reggae, me gustas tú,
Qué voy a hacer, je ne sais pas
qué voy a hacer, je ne sais plus,
qué voy a hacer, je suis perdu
¿qué horas son mi corazón?,
Me gusta la canela, me gustas tú,
me gusta el fuego, me gustas tú,
me gusta menear, me gustas tú,
me gusta La Coruña, me gustas tú,
me gusta Malasaña, me gustas tú,
me gusta la castaña, me gustas tú,
me gusta Guatemala, me gustas tú.
Qué voy a hacer, je ne sais pas
qué voy a hacer, je ne sais plus,
qué voy a hacer, je suis perdu
¿qué hora son mi corazón?
(qué voy a hacer, je ne sais plus,
qué voy a hacer, je ne sais plus,
qué voy a hacer, je suis perdu),
¿qué hora son mi corazón...?
(qué voy a hacer, je ne sais plus,
qué voy a hacer, je ne sais plus,
qué voy a hacer, je suis perdu),
¿qué hora son mi corazón...?
¿qué hora son mi corazón...?
(¿qué hora son mi corazón...?)
¿qué hora son mi corazón...?
¿qué hora son mi corazón...?
¿qué hora son mi corazón...?
Spoken:
4 de la mañana
Alabim alabam alabim bom bam
alabim alabam alabim bom bam
obladi, oblada obladi da da
alabim alabam alabim bom bam
Spoken:
Radio reloj: 5 de la mañana.
No todo lo que es oro brilla; remedio chino e infalible...