GithubHelp home page GithubHelp logo

mainsail-crew / sonar Goto Github PK

View Code? Open in Web Editor NEW
60.0 7.0 14.0 127 KB

Sonar is a small Keepalive daemon for MainsailOS.

License: GNU General Public License v3.0

Makefile 2.23% Shell 97.77%
mainsailos wifi raspberry-pi

sonar's People

Contributors

fire1ce avatar fjpanag avatar kwadfan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonar's Issues

Reassociating WiFi connection exits with error 255

What happened

The WiFi connection stopped working and reassociating the wifi connection does not work

What did you expect to happen

The WiFi connection to recover

How to reproduce

Install MainsailOS on Raspberry Pi 4
Update all system packages

Additional information

journalctl

Jun 13 08:53:21 mainsailos-sp systemd[1]: Starting Sonar - A WiFi Keepalive daemon...
Jun 13 08:53:21 mainsailos-sp systemd[1]: Started Sonar - A WiFi Keepalive daemon.
Jun 13 08:53:21 mainsailos-sp sudo[10608]:     root : PWD=/home/pi/sonar ; USER=pi ; COMMAND=/usr/bin/git describe --always --tags
Jun 13 08:53:21 mainsailos-sp sudo[10608]: pam_unix(sudo:session): session opened for user pi(uid=1000) by (uid=0)
Jun 13 08:53:21 mainsailos-sp sudo[10608]: pam_unix(sudo:session): session closed for user pi
Jun 13 08:53:21 mainsailos-sp sonar[10596]: Sonar - A WiFi Keepalive daemon
Jun 13 08:53:21 mainsailos-sp sonar[10596]: Version: v0.1.2
Jun 13 08:53:21 mainsailos-sp sonar[10596]: Prepare Startup ...
Jun 13 08:53:21 mainsailos-sp sonar[10596]: INFO: Print Configfile: '/home/pi/printer_data/config/sonar.conf'
Jun 13 08:53:21 mainsailos-sp sonar[10596]:                 [sonar]
Jun 13 08:53:21 mainsailos-sp sonar[10596]:                 enable: true
Jun 13 08:53:21 mainsailos-sp sonar[10596]:                 debug_log: true
Jun 13 08:53:21 mainsailos-sp sonar[10596]:                 persistant_log: false
Jun 13 08:53:21 mainsailos-sp sonar[10596]:                 target: auto
Jun 13 08:53:21 mainsailos-sp sonar[10596]:                 count: 3
Jun 13 08:53:21 mainsailos-sp sonar[10596]:                 interval: 60
Jun 13 08:53:21 mainsailos-sp sonar[10596]:                 restart_treshold: 10
Jun 13 08:53:21 mainsailos-sp sonar[10596]: INFO: Checking Dependencys
Jun 13 08:53:22 mainsailos-sp sonar[10596]: Dependency: 'crudini' found in /usr/bin/crudini.
Jun 13 08:53:23 mainsailos-sp sonar[10687]: ping: : Name or service not known
Jun 13 08:53:23 mainsailos-sp sonar[10596]: Connection lost,  not reachable!
Jun 13 08:53:23 mainsailos-sp sonar[10596]: Restarting network in 10 seconds.
Jun 13 08:53:33 mainsailos-sp sonar[10712]: ping: : Name or service not known
Jun 13 08:53:33 mainsailos-sp sonar[10596]: Reassociate WiFi connection ...
Jun 13 08:53:33 mainsailos-sp sonar[10596]: ERROR: Error 255 occured on line 149
Jun 13 08:53:33 mainsailos-sp sonar[10596]: ERROR: Stopping sonar.
Jun 13 08:53:33 mainsailos-sp sonar[10596]: Goodbye ...
Jun 13 08:53:33 mainsailos-sp systemd[1]: sonar.service: Main process exited, code=exited, status=1/FAILURE
Jun 13 08:53:33 mainsailos-sp systemd[1]: sonar.service: Failed with result 'exit-code'.
Jun 13 08:53:33 mainsailos-sp systemd[1]: sonar.service: Consumed 1.648s CPU time.
Jun 13 08:53:38 mainsailos-sp systemd[1]: sonar.service: Scheduled restart job, restart counter is at 45418.
Jun 13 08:53:38 mainsailos-sp systemd[1]: Stopped Sonar - A WiFi Keepalive daemon.
Jun 13 08:53:38 mainsailos-sp systemd[1]: sonar.service: Consumed 1.648s CPU time.

sonar.conf documentation lacking

What happened

After creating sonar.conf according to documentation if there is no [sonar] section there, parameters are not read correctly. At least, please provide info in readme.md. Preferably, more detailed logs.

Also, because declaring read-only variables, changes in config require sudo service sonar --full-restart to make effects.

What did you expect to happen

At least, please provide info in readme.md. Preferably, more detailed logs.

How to reproduce

create sonnar config as below:

enable: true
debug_log: true
target: 192.168.99.1
count: 2
interval: 360
restart_treshold: 1
persistant_log: true

Additional information

No response

BREAKING CHANGE: Renamed option disable_service to enable

What happened

I decided to rename the option because of double negation.

So, please update your config file accordingly if you have setup one.

Please use enable: true to enable the service, otherwise use enable: false

See README.md for details.

What did you expect to happen

Users will create Issues :)

How to reproduce


Additional information

No response

Sonar does not recognize gateway during boot.

What happened

I am using MainsailOS on a Raspberry Pi 4, and I enabled sonar.

Right from the start, I had issues with sonar constantly restarting the network.
I have configured target to auto.

It is supposed to ping my gateway in this configuration (192.168.1.1), but it fails to do so.
Manually restarting sonar.service solves the issue, and the correct gateway is properly recognized.

What did you expect to happen

Sonar to properly recognize the gateway, or automatically restart in case of this error.

In any case, proceeding with target being undefined seems wrong.

How to reproduce

Vanilla installation of MainsailOS, with sonar enabled.
Set target to auto and restart the system.

After boot, sonar will try to ping "nothing".

Additional information

Here is sonar's log:

-- Boot 387dbda3bed946d396890161c55c2364 --
Oct 15 17:05:12 voron systemd[1]: Starting Sonar - A WiFi Keepalive daemon...
Oct 15 17:05:12 voron systemd[1]: Started Sonar - A WiFi Keepalive daemon.
Oct 15 17:05:26 voron sudo[600]:     root : PWD=/home/pi/sonar ; USER=pi ; COMMAND=/usr/bin/git describe --always --tags
Oct 15 17:05:26 voron sudo[600]: pam_unix(sudo:session): session opened for user pi(uid=1000) by (uid=0)
Oct 15 17:05:26 voron sudo[600]: pam_unix(sudo:session): session closed for user pi
Oct 15 17:05:27 voron sonar[552]: Sonar - A WiFi Keepalive daemon
Oct 15 17:05:27 voron sonar[552]: Version: v0.1.2
Oct 15 17:05:27 voron sonar[552]: Prepare Startup ...
Oct 15 17:05:27 voron sonar[552]: INFO: Checking Dependencys
Oct 15 17:05:27 voron sonar[552]: Dependency: 'crudini' found in /usr/bin/crudini.
Oct 15 17:05:29 voron sonar[828]: ping: : Name or service not known
Oct 15 17:05:29 voron sonar[552]: Connection lost,  not reachable!
Oct 15 17:05:29 voron sonar[552]: Restarting network in 10 seconds.
Oct 15 17:05:39 voron sonar[1160]: ping: : Name or service not known
Oct 15 17:05:39 voron sonar[552]: Reassociate WiFi connection ...
Oct 15 17:05:39 voron sonar[552]: Restarting dhcpcd service ...
Oct 15 17:05:39 voron sonar[552]: Waiting 10 seconds to re-establish connection ...
Oct 15 17:05:49 voron sonar[1570]: ping: : Name or service not known
Oct 15 17:05:49 voron sonar[552]: Reassociate WiFi connection ...
Oct 15 17:05:49 voron sonar[552]: Restarting dhcpcd service ...
Oct 15 17:05:50 voron sonar[552]: Waiting 10 seconds to re-establish connection ...
Oct 15 17:06:00 voron sonar[1923]: ping: : Name or service not known
Oct 15 17:06:00 voron sonar[552]: Reassociate WiFi connection ...
Oct 15 17:06:00 voron sonar[552]: Restarting dhcpcd service ...
Oct 15 17:06:01 voron sonar[552]: Waiting 10 seconds to re-establish connection ...
Oct 15 17:06:11 voron sonar[552]: WARN: Reconnect failed after 3 retries ...
Oct 15 17:06:11 voron sonar[552]: Attempt paused for 60 seconds.

Sonar can’t find its config file

What happened

I built the rpi ssd card from the downloadable image just before Christmas as per voron build instructions. I was having a lot of trouble with my wifi constantly dropping connections every few minutes. Anyway after a lot of false starts when I thought I had a wifi problem I eventually found sonar to be the culprit.
Looking at the sonar.conf file in the klipper dashboard it should have been disabled but in fact it wasn’t finding its conf file because it’s looking for it in the wrong place. The libs/core.sh file uses the path ${BASE_USER_HOME}/klipper_config/sonar.conf when in fact it should have been looking in printer_data/config/sonar.conf. Now that I’ve changed the code it finds its config file and honours the disabled state which means my wifi stays up for more than a few minutes at a time. The problem is in a couple of places in core.sh

What did you expect to happen

I expected sonar not to run as it was not enabled in its sonar.conf file in the klipper printer_data/config folder but it runs anyway and in anycase the default options is uses when it can’t find the config file keep killing the wifi connection

How to reproduce

Just install the mailsailos image on a clean ssd card and fire it up. Sonar will ignore all changes to,it’s config file through the mainsail gui

Additional information

No response

Still lost connection no matter what

What happened

Sonar is clearly will setup but i still loose the connection. Any other thing i can check?

What did you expect to happen

Connection not lost after correct setup

How to reproduce

Just setup Sonar in the correct standard way on raspberry pi w2

Additional information

log
[07/10/22 12:08:40] sonar: Reached 192.168.1.1, Triptime: min/avg/max/mdev = 5.007/5.075/5.131/0.051 ms
[07/10/22 12:09:43] sonar: Reached 192.168.1.1, Triptime: min/avg/max/mdev = 5.004/5.137/5.387/0.186 ms
[07/10/22 12:10:45] sonar: Reached 192.168.1.1, Triptime: min/avg/max/mdev = 4.152/4.818/5.381/0.513 ms
[07/10/22 12:11:48] sonar: Reached 192.168.1.1, Triptime: min/avg/max/mdev = 4.874/4.927/5.027/0.090 ms
[07/10/22 12:12:51] sonar: Reached 192.168.1.1, Triptime: min/avg/max/mdev = 4.833/4.833/4.833/0.000 ms
[07/10/22 12:13:54] sonar: Reached 192.168.1.1, Triptime: min/avg/max/mdev = 4.793/4.911/5.032/0.113 ms
[07/10/22 12:14:56] sonar: Reached 192.168.1.1, Triptime: min/avg/max/mdev = 1.853/2.037/2.157/0.132 ms
[07/10/22 12:16:00] sonar: Reached 192.168.1.1, pipe 3
[07/10/22 12:17:04] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:18:09] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:19:22] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:20:26] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:21:32] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:22:37] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:23:43] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:24:48] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:25:54] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:27:00] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:28:05] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:29:11] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:30:14] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:31:19] sonar: Reached 192.168.1.1, pipe 2
[07/10/22 12:32:32] sonar: Connection lost, 192.168.1.1 not reachable!
[07/10/22 12:32:32] sonar: Restarting network in 10 seconds.
[07/10/22 12:33:08] sonar: Waiting 10 seconds to re-establish connection.
[07/10/22 12:34:18] sonar: Connection lost, 192.168.1.1 not reachable!
[07/10/22 12:34:18] sonar: Restarting network in 10 seconds.
[07/10/22 12:34:41] sonar: Waiting 10 seconds to re-establish connection.
[07/10/22 12:35:51] sonar: Connection lost, 192.168.1.1 not reachable!
[07/10/22 12:35:51] sonar: Restarting network in 10 seconds.
[07/10/22 12:36:13] sonar: Waiting 10 seconds to re-establish connection.
[07/10/22 12:37:24] sonar: Connection lost, 192.168.1.1 not reachable!
[07/10/22 12:37:24] sonar: Restarting network in 10 seconds.

Wifi Crashing

What happened

Sporadically while printing the Wifi looses connection and the Host cannot be reached (through WebUI or SSH)

What did you expect to happen

Wifi to keep running

How to reproduce

just wait and within a couple hours the wifi goes down. A reboot of the host is the only way to bring the wifi back

Additional information

sonar (1).log
I have tried with sonar enabled and disabled (as the other user issue suggested). I seem to be getting a couple different errors in the Sonar Log.
Running MainsailOS, on a Pi4
Errors I get are:
Error 1 occured on line 162
Error 255 occured on line 158
Error 254 occured on line 158

Fails if device does not have eth

What happened

Fails to run due to /sys/class/net/eth0/operstate not existing on devices that do not have ethernet such as the pi zero 2 w. Looking at the journalctl -u sonar it outputs the following error cat: /sys/class/net/eth0/operstate: No such file or directory

What did you expect to happen

journalctl reports no errors on fresh boot

How to reproduce

enable sonar on raspberry pi zero 2 w

Additional information

Apr 28 09:50:26 mainsail systemd[1]: Starting Sonar - A WiFi Keepalive daemon...
Apr 28 09:50:26 mainsail systemd[1]: Started Sonar - A WiFi Keepalive daemon.
Apr 28 09:50:27 mainsail sonar[614]: Sonar - A WiFi Keepalive daemon
Apr 28 09:50:28 mainsail sonar[633]: Version: v0.0.1
Apr 28 09:50:28 mainsail sonar[638]: Prepare Startup ...
Apr 28 09:50:28 mainsail sonar[643]: INFO: Checking Dependencys
Apr 28 09:50:29 mainsail sonar[660]: Dependency: 'logger' found in /usr/bin/logger.
Apr 28 09:50:29 mainsail sonar[590]: cat: /sys/class/net/eth0/operstate: No such file or directory

Wifi does not reconnect after wlan0 down and wlan0 up

What happened

When the keepalive function is run, wifi does not reconnect.

What did you expect to happen

Wifi should reconnect.

How to reproduce

Not sure this is easily reproducible cause it could be due to my router setup, etc. An easy fix is to add the following command after ifconfig wlan0 up:
dhclient wlan0

Additional information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.