dietpi-wifi-monitor Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
mail2rst
Posts: 51
Joined: Fri Apr 13, 2018 4:53 pm

dietpi-wifi-monitor

Post by mail2rst »

My raspberry 3B connected with wifi. some times it loose wifi connection after long interval. then i start looking dietpi forum about this trouble
& find "dietpi-wifi-monitor.sh". i tried to install it with the help of old forum:

"https://community.roonlabs.com/t/wifi-d ... y/25850/20"

but it is not applicable to current dietpi software as there is no file "/DietPi/dietpi/func/dietpi-notify". so i have removed the file i created & service created by this guideline.
so my question is how to configure or reconfigure "dietpi-wifi-monitor.sh" as my rasspberry is working headless & when it loose wifi i have to restart it by removing power. which i feel guilty for small computer to do harsh reset.

please help me to configure this already available feature in dietpi. i already checked dietpi-software, dietpi-config etc. but there is no way is mentioned anywhere to reinstall/reconfigure this feature.
"/var/lib/dietpi/services/dietpi-wifi-monitor.sh"
thanks
User avatar
Joulinar
Posts: 2059
Joined: Sat Nov 16, 2019 12:49 am

Re: dietpi-wifi-monitor

Post by Joulinar »

Hi,

many thanks for your request. Basically you are referring to a 3 years old post and thinks have change in meantime. Nowadays dietpi-wifi-monitor is an own service that can be activated if needed

Code: Select all

systemctl enable dietpi-wifi-monitor.service
systemctl start dietpi-wifi-monitor.service
systemctl status dietpi-wifi-monitor.service
Status should looks like this

Code: Select all

root@DietPi3:~# systemctl status dietpi-wifi-monitor.service
● dietpi-wifi-monitor.service - DietPi-WiFi-Monitor
   Loaded: loaded (/etc/systemd/system/dietpi-wifi-monitor.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-05-30 22:22:29 CEST; 1s ago
  Process: 662 ExecStartPre=/boot/dietpi/func/obtain_network_details (code=exited, status=0/SUCCESS)
  Process: 668 ExecStartPre=/bin/dash -c [ -e /sys/class/net/wlan$(mawk "NR==2" /run/dietpi/.network) ] (code=exited, status=0/SUCCESS)
 Main PID: 670 (dietpi-wifi-mon)
    Tasks: 2 (limit: 2319)
   Memory: 1.4M
   CGroup: /system.slice/dietpi-wifi-monitor.service
           ├─670 /bin/bash /var/lib/dietpi/services/dietpi-wifi-monitor.sh
           └─677 sleep 10

May 30 22:22:29 DietPi3 systemd[1]: Starting DietPi-WiFi-Monitor...
May 30 22:22:29 DietPi3 systemd[1]: Started DietPi-WiFi-Monitor.
May 30 22:22:29 DietPi3 dietpi-wifi-monitor.sh[670]: Checking connection for: wlan0 via ping to default gateway every 10 seconds
root@DietPi3:~#
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
mail2rst
Posts: 51
Joined: Fri Apr 13, 2018 4:53 pm

Re: dietpi-wifi-monitor

Post by mail2rst »

Thanks Joulinar, for reply & clarify this. is there any way i can re-add or re install this function. as i already mentioned i one time delete these files after that with these older posts i try to heal my created trouble. i increased ping value to time =3600 second manually. & make a service


===========================================================================
/etc/systemd/system/dietpi-wifi-monitor.service

"
[Unit]
Description=Monitors loss of WiFi connection and automatically reconnects
After=network.target network-online.target

[Service]
Type=simple

ExecStart=/bin/bash /var/lib/dietpi/services/dietpi-wifi-monitor.sh

[Install]
WantedBy=multi-user.target

"
=============================================================================

system over all looks like working. but at initial boot this service not working but after "systemctl start dietpi-wifi-monitor.service" command it start working & status show online. please help me where i am wrong or guide me i can reset this module for my system. thanks


===============================================================================

root@DietPi:~# systemctl status dietpi-wifi-monitor.service
● dietpi-wifi-monitor.service - Monitors loss of WiFi connection and automatically reconnects
Loaded: loaded (/etc/systemd/system/dietpi-wifi-monitor.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-05-30 15:50:13 MDT; 1min 53s ago
Process: 368 ExecStart=/bin/bash /var/lib/dietpi/services/dietpi-wifi-monitor.sh (code=exited, status=1/FAILURE)
Main PID: 368 (code=exited, status=1/FAILURE)

May 30 15:50:12 DietPi systemd[1]: Started Monitors loss of WiFi connection and automatically reconnects.
May 30 15:50:13 DietPi bash[368]: mawk: cannot open /run/dietpi/.network (No such file or directory)
May 30 15:50:13 DietPi bash[368]: Checking connection for: wlan via ping to default gateway every 3600 seconds
May 30 15:50:13 DietPi bash[368]: Cannot find device "wlan"
May 30 15:50:13 DietPi bash[368]: ERROR: WiFi adapter has been unplugged: wlan. Exiting...
May 30 15:50:13 DietPi systemd[1]: dietpi-wifi-monitor.service: Main process exited, code=exited, status=1/FAILURE
May 30 15:50:13 DietPi systemd[1]: dietpi-wifi-monitor.service: Failed with result 'exit-code'.
root@DietPi:~# systemctl start dietpi-wifi-monitor.service
root@DietPi:~# systemctl status dietpi-wifi-monitor.service
● dietpi-wifi-monitor.service - Monitors loss of WiFi connection and automatically reconnects
Loaded: loaded (/etc/systemd/system/dietpi-wifi-monitor.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-05-30 15:52:21 MDT; 6s ago
Main PID: 808 (bash)
Tasks: 2 (limit: 2319)
Memory: 872.0K
CGroup: /system.slice/dietpi-wifi-monitor.service
├─808 /bin/bash /var/lib/dietpi/services/dietpi-wifi-monitor.sh
└─815 sleep 3600

May 30 15:52:21 DietPi systemd[1]: Started Monitors loss of WiFi connection and automatically reconnects.
May 30 15:52:21 DietPi bash[808]: Checking connection for: wlan0 via ping to default gateway every 3600 seconds
======================================================================================================
User avatar
Joulinar
Posts: 2059
Joined: Sat Nov 16, 2019 12:49 am

Re: dietpi-wifi-monitor

Post by Joulinar »

I would recommand to use the original service definition

root@DietPi3:~# cat /etc/systemd/system/dietpi-wifi-monitor.service

Code: Select all

# Monitors loss of WiFi connection and automatically reconnects
[Unit]
Description=DietPi-WiFi-Monitor
Wants=network-online.target
After=dietpi-boot.service network-online.target

[Service]
ExecStartPre=/boot/dietpi/func/obtain_network_details
ExecStartPre=/bin/dash -c '[ -e /sys/class/net/wlan$(mawk "NR==2" /run/dietpi/.network) ]'
ExecStart=/var/lib/dietpi/services/dietpi-wifi-monitor.sh

[Install]
WantedBy=multi-user.target
and download a new copy of the script from GitHub (2nd command is quite long)

Code: Select all

rm /var/lib/dietpi/services/dietpi-wifi-monitor.sh
wget https://raw.githubusercontent.com/MichaIng/DietPi/master/rootfs/var/lib/dietpi/services/dietpi-wifi-monitor.sh -O /var/lib/dietpi/services/dietpi-wifi-monitor.sh
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
mail2rst
Posts: 51
Joined: Fri Apr 13, 2018 4:53 pm

Re: dietpi-wifi-monitor

Post by mail2rst »

Thanks Joulinar,

After implementing your instructions. this module works perfectly on my system.

thanks you are always very very helpful.
Post Reply