Git Product home page Git Product logo

highvolt-dev / tmo-monitor Goto Github PK

View Code? Open in Web Editor NEW
88.0 14.0 16.0 87 KB

A lightweight, cross-platform Python 3 script that can monitor the T-Mobile Home Internet Nokia, Arcadyan, and Sagecom 5G Gateways for 4G/5G bands, cellular site (tower), and internet connectivity and reboots as needed or on-demand.

License: MIT License

Python 92.09% Shell 7.91%
tmobile t-mobile isp monitoring monitor monitoring-tool windows linux osx macosx

tmo-monitor's Introduction

tmo-monitor logo

tmo-monitor

A lightweight, cross-platform Python 3 script that can monitor the T-Mobile Home Internet Nokia, Arcadyan, and Sagecom 5G Gateways for 4G/5G bands, cellular site (tower), and internet connectivity and reboots as needed or on-demand.

By default, checks for n41 5G signal and connectivity to google.com via ping.

Getting Started

Install dependencies

pip3 install .

The command will then be available anywhere as tmo-monitor.py.

Windows

  1. On Windows, open the folder where you downloaded the project.
  2. Click File > Open Windows PowerShell
  3. Run the above pip3 install . command.
  4. To use, either:
    • Run cmd.exe within PowerShell first
    • Open cmd.exe (Command Prompt) instead of PowerShell
    • Run python bin/tmo-monitor.py in PowerShell from inside the project directory

When in doubt, consult this document or run tmo-monitor.py --help.

Usage

Command line usage

usage: tmo-monitor.py [-h] [--connectivity-check {ping,http}]
                      [-I INTERFACE]
                      [--http-target HTTP_TARGET] [--status-code {[100,600)}]
                      [-H PING_HOST] [--ping-count PING_COUNT] [--ping-interval PING_INTERVAL] [-6]
                      [-R] [-r]
                      [--skip-bands] [--skip-5g-bands] [--skip-connectivity-check] [--skip-enbid]
                      [--uptime UPTIME]
                      [-4 {B2,B4,B5,B12,B13,B25,B26,B41,B46,B48,B66,B71}] [-5 {n41,n71}]
                      [--enbid ENBID]
                      [--print-config]
                      [--logfile LOGFILE] [--log-all] [--log-delta] [--syslog]
                      [--model {NOK5G21,ARCKVD21,FAST5688W}]
                      [username] [password]

Check T-Mobile Home Internet cellular band(s) and connectivity and reboot if necessary

positional arguments:
  username              the username (most likely "admin")
  password              the administrative password (will be requested at runtime if not passed as argument)

optional arguments:
  -h, --help            show this help message and exit
  --connectivity-check {ping,http}
                        type of connectivity check to perform (defaults to ping)
  -I INTERFACE, --interface INTERFACE
                        the network interface to use for ping. pass the source IP on Windows
  --http-target HTTP_TARGET
                        the URL to perform a http check against (defaults to https://google.com/generate_204)
  --status-code {[100,600)}
                        expected HTTP status code for http connectivity check (defaults to 204)
  -H PING_HOST, --ping-host PING_HOST
                        the host to ping (defaults to google.com)
  --ping-count PING_COUNT
                        how many ping health checks to perform (defaults to 1)
  --ping-interval PING_INTERVAL
                        how long in seconds to wait between ping health checks (defaults to 10)
  -6, --ping-6          use IPv6 ping
  -R, --reboot          skip health checks and immediately reboot gateway
  -r, --skip-reboot     skip rebooting gateway
  --skip-bands          skip check for connected 4g band
  --skip-5g-bands       skip check for connected 5g band
  --skip-connectivity-check, --skip-ping
                        skip connectivity check
  --skip-enbid          skip check for connected eNB ID
  --uptime UPTIME       how long the gateway must be up before considering a reboot (defaults to 90 seconds)
  -4 {B2,B4,B5,B12,B13,B25,B26,B41,B46,B48,B66,B71}, --4g-band {B2,B4,B5,B12,B13,B25,B26,B41,B46,B48,B66,B71}
                        the 4g band(s) to check
  -5 {n41,n71}, --5g-band {n41,n71}
                        the 5g band(s) to check (defaults to n41)
  --enbid ENBID         check for a connection to a given eNB ID
  --print-config        output configuration settings
  --logfile LOGFILE     output file for logging
  --log-all             always write connection details to logfile
  --log-delta           write connection details to logfile on change
  --syslog              log to syslog
  --model {NOK5G21,ARCKVD21,FAST5688W}
                        the gateway model (defaults to NOK5G21)

Options

Gateway Model

Gateway Model: --model

By default, the script will assume the silver-colored Nokia NOK5G21 gateway is being used.

Valid values are NOK5G21 for the Nokia gateway, ARCKVD21 for the square, black-colored Arcadyan gateway without top vent holes, or FAST5688W for the square, black-colored Sagecom gateway with top vent holes.

Connectivity check

Mode: --connectivity-check Defaults to ping. Can instead use a HTTP(S) based health check with the http value. The http health check defaults to checking https://google.com/generate_204 and checking its status code.

Interface: -I --interface Can be used to specify the network interface used by the ping command. Useful if T-Mobile Home Internet is not your default network interface: e.g., this is running on a dual WAN router. On Windows, pass the source IP address to use. http connectivity checks will be dictated by system routing rules.

HTTP check

Target: --http-target Defaults to https://google.com/generate_204 - both http and https targets are supported by the http value of the --connectivity-check flag.

Status Code: --status-code Defaults to 204 for use with https://google.com/generate_204 - in most common use cases, a 200 status code is expected instead. Expects a numeric value between 100-599 (inclusive).

Ping options

ping checks are the default connectivity check in tmo-monitor. It's possible to use HTTP(S)-based checks instead. Refer to the --connectivity-check flag.

Ping Host: -H --ping-host Defaults to google.com - override if you'd like to ping an alternate host to determine internet connectivity. Must specify a host if flag is provided - you can simply omit the flag if you'd like to use the default google.com ping check.

Ping Count: --ping-count Defaults to 1 - override if you'd like to perform multiple ping checks before rebooting. Short-circuits if a successful ping is encountered. Will reboot if all fail.

Ping Interval: --ping-interval Defaults to 10 seconds - override if you'd like to use a different interval.

Ping v6: -6 --ping-6 Use IPv6 ping.

Reboot options

Reboot: -R --reboot Skip health checks and immediately reboot gateway.

Skip Reboot: -r --skip-reboot Skip rebooting gateway.

Skip Bands: --skip-bands Skip check for connected 4g band.

Skip 5g Bands: --skip-5g-bands Skip check for connected 5g band.

Skip Ping: --skip-connectivity-check --skip-ping Skip check for successful connectivity check.

Uptime Threshold: --uptime Defaults to 90 seconds - Specify a required uptime for an implicit reboot to occur. Intended to allow sufficient time to establish a connection and stabilize band selection. Setting is used to avoid boot looping, but is not respected when the --reboot flag is used.

Connection configuration

4G Band Checking: -4 --4g-band Specify a 4G band you expect the gateway to be connected to. Repeat the flag to allow multiple acceptable bands. Case-sensitive.

5G Band Checking: -5 --5g-band Defaults to n41 - Specify a 5G band you expect the gateway to be connected to. Repeat the flag to allow multiple acceptable bands. Case-sensitive.

eNB ID: --enbid Specify the desired cell site you expect the gateway to be connected to. Expects a numeric eNB ID to be provided. cellmapper.net is a helpful resource for finding eNB ID values for nearby cell sites.

General settings

Logfile: --logfile LOGFILE Output file for logging. Defaults to tmo-monitor.log

Log all: --log-all Always write connection details to logfile. Checks all configuration settings.

Log delta: --log-delta Write connection details to logfile on change of any configuration setting or long ping time.

Default settings

  • Username == admin
  • Password -> interactive prompt
  • 5G band == n41
  • Reboot on failure to ping google.com

Environment (.env) options

The script is normally run in batch mode, such as scheduled through a cron job. Interactive command-line options are meant to be used as overrides to defaults or environment settings.

A common usage pattern would be to configure the script using a .env file to reboot on 5G band and wifi check. When messing with the settings, a user might want to specify --skip-reboot. When a user knows that the reboot is needed they might specify --reboot for an immediate reboot.

  • Default settings have the lowest precendence.
  • Environment settings--whether in the shell environment or a .env file--override the defaults
  • Command line options have the highest precedence and override both default settings and environment settings

Environment settings are meant to be declarative. They fall into four categories:

  • Login settings (username, password)
  • Configuration settings
    • Ping settings (target host/interface, number of pings, interval)
    • Connection settings (preferred band, eNB ID, etc.)
  • Reboot settings: request reboot on any number of failed checks.
    • Skip reboot overrides all reboot requests
    • Reboot interval overrides all reboot requests
    • There is no "reboot immediately" option
  • General settings:
    • Default output/silent mode (not yet implemented)
    • Logging settings

Exit Status

tmo-monitor uses the following exit status codes:

  • Clean execution: 0
  • GENERAL_ERROR: 1
  • CONFIGURATION_ERROR: 2
  • API_ERROR: 3
  • REBOOT_PERFORMED: 4

Roadmap

(Not yet implemented):

  • Alternate connectivity checks
  • systemd service configuration

Tip

Run this script with either a cronjob or as a systemd service to implement periodic recurring T-Mobile Home Internet health checks with automatic rebooting.

tmo-monitor's People

Contributors

andrewpardoe avatar benkesselring avatar delikat avatar highvolt-dev avatar hugoh 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmo-monitor's Issues

Add Linting Rules

Add linting rules for better consistency of code. Incorporate in GitHub Actions.

Submit to PyPI

Submit to PyPI for expanded user reach and a more accessible route to using the script via pip install.

Add --silent flag

Add --silent flag to suppress output to stdout. This will prevent cron from needing to redirect output.

Credential Reuse

Provide method(s) for credentials to be re-used.

Because web api authentication uses hashing and app api authentication uses cleartext passwords, cannot simply just use hashed value.

Options include storing password in cleartext or encrypted at rest and providing the decryption key at runtime, e.g. with an environment variable. If storing in cleartext, should ensure read permissions are as strict as possible.

Multiple consecutive pings in x time before you reboot due to drop outs or latency (due to bad weather etc)

At given times of the day and especially in bad weather you can experience "drop outs" that can last for 20-30 seconds. Right now this will trigger a reboot that adds another 2 minutes into the process. If the monitor was to do 4 pings 10 seconds apart before triggering a reboot this would allow for those moments of drop out or latency.

This seemed to be different enough from the "enhance ping" issue where it talks about multiple hosts vs multiple pings across a timeframe interval.

Boot Loop Prevention

Add statefulness to prevent boot loops so that a given number of consecutive failures or a failure of a certain duration causes different behavior than endlessly rebooting.

could not query site and could not post login

I am running the latest code. This morning, my internet dropped out. When I looked at logs I got the following:

2022/01/11 07:00:04 [INFO] 4G: B2 | 5G: n41 | eNB ID: 28646 | Avg Ping: 44 ms | Uptime: 158930 sec
2022/01/11 07:05:01 [CRITICAL] Could not post login request, exiting.
2022/01/11 07:05:01 [CRITICAL] Could not query site info, exiting.
2022/01/11 07:06:09 [ERROR] Could not ping google.com.
2022/01/11 07:06:09 [CRITICAL] Could not query modem uptime, exiting.
2022/01/11 07:06:17 [CRITICAL] Could not post login request, exiting.
2022/01/11 07:06:17 [CRITICAL] Could not query site info, exiting.
2022/01/11 07:06:43 [CRITICAL] Could not post login request, exiting.
2022/01/11 07:06:43 [CRITICAL] Could not query site info, exiting.

Any ideas why? I was able to log into my gateway from my laptop, so it was still on my local network. As soon as the reboot was complete, everything was fine and things were being logged like normal again.

2022/01/11 07:10:03 [INFO] 4G: B66 | 5G: n41 | eNB ID: 28646 | Avg Ping: 59 ms | Uptime: 94 sec
2022/01/11 07:12:46 [INFO] 4G: B66 | 5G: n41 | eNB ID: 28646 | Avg Ping: 84 ms | Uptime: 257 sec

not seeing .env in 2.0.0beta 4

Running on a raspberry pi, It is not seeing the .env file when I run python3 bin/tmo-monitor.py

I put the .env in the bin folder, then second guessed myself and put in in the tmo-monitor-2.0.0-beta4 folder. No luck either way.

Version 2 Beta Feedback

Substantial work from @AndrewPardoe has lead to a new upcoming major version release, 2.0. This issue is intended to track any feedback regarding this release.

Specifically:

  • .env file and configuration override nuances
  • logging behavior
  • ping behavior (the ping implementation was slightly changed when extracting latency information for logging) - need to confirm that no regressions are introduced, particularly with Windows in the case of a "Network not reachable" edge case.

Arcaydyan enBID coming up wrong

When I remove the first six characters (T-Mobile ID), then divide the remaining 8 digit number by 256, the tower ID matched what cellmapper.net showed for my connected tower. Discard the numbers after the decimal point, to get the correct enBID. I would be amenable to letting you ssh into my Linux Box, running Fedora 35, if you care to test it with a live unit. I do appreciate this effort you are putting out, for all of us who are using the Arc box. Using CGI on LTE tab, as the source, peel off the first 6 characters, then divide the remaining 8 digit number by 256, drop the characters after the decimal point, should give cell tower enBID that match the stuff reported to cellmapper.net. Hope this helps. Great work on this tool.

Add logging of stats

Add logging of status checks so that the output can be used for analysis or with time series databases, graphing, and monitoring tools.

Add ability to specify output format (e.g. json)

Logging to email, telegram...somewhere

Have you considered allowing for an email or some other options that just basically says the gateway was rebooted? Email would have the timestamp. Might indicate if the issue is overheating. telegram-cli would have been perfect except it gives an error on pi and needs to have 2 lines commented out in the source then recompiled.

Add Predefined Band Groups

Add pre-defined band groups, e.g. low-band, mid-band, Sprint, T-Mobile, anchor bands (i.e. B2/B66), etc.

A more detailed installation procedure?

I have a pi with a fresh install of the latest version.

What do I need to do to install and then run this script?

I can run pip3 and, after a while, it returns a string of command line options.

I am a noob at python.

Have you looked at this...

https://github.com/geerlingguy/internet-pi

I have been running it for 3 months. It works with any ISP.

My TMHI was terrible during the day until about 3 weeks ago. Speeds are not great but very usable.

Thanks for sharing your work.

Dennis

internet=pi output...

Internet_connection_-_Grafana

32 0 Mbs

pip3 install .

Sorry, Python noob here.

On an uppdated RaspberryPi
Python 3.9.2
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)
pip3 install .
yields
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.

Help

Do I need to download the project and unpack it in the home directory?

Unit Tests?

I see there are no unit tests.

Before I jump in head first writing tests, would you find it useful for this project?

Script fails if not connected to 5G band

Executing:

tmo-monitor.py --ping-count 3 -4 B2 -5 n41 -5 n71 --model ARCKVD21

When the Ark device isn't connected to a 5g band, the JSON no longer contains a 5g section in the output, resulting in the following error:

2022/08/05 10:04:00 [DEBUG] Starting new HTTP connection (1): 192.168.12.1:80
2022/08/05 10:04:00 [DEBUG] http://192.168.12.1:80 "GET /TMI/v1/gateway?get=all HTTP/1.1" 200 906
Traceback (most recent call last):
File "/home/treddy/.local/bin/tmo-monitor.py", line 83, in
signal_info = gw_control.get_signal_info()
File "/home/treddy/.local/lib/python3.9/site-packages/tmo_monitor/gateway/arcadyan.py", line 69, in get_signal_info
nr_info = info['signal']['5g']['bands']
KeyError: '5g'

Output from gateway endpoint:

{
"device": {
"friendlyName": "5G Gateway",
"hardwareVersion": "R01",
"isEnabled": true,
"isMeshSupported": true,
"macId": "",
"manufacturer": "Arcadyan",
"manufacturerOUI": "001A2A",
"model": "KVD21",
"name": "5G Gateway",
"role": "gateway",
"serial": "",
"softwareVersion": "1.00.16",
"type": "HSID",
"updateState": "latest"
},
"signal": {
"4g": {
"bands": [
"b12"
],
"bars": 5.0,
"cid": 22,
"eNBID": ,
"rsrp": -73,
"rsrq": -6,
"rssi": -67,
"sinr": 17
},
"generic": {
"apn": "FBB.HOME",
"hasIPv6": true,
"registration": "registered",
"roaming": false
}
},
"time": {
"daylightSavings": {
"isUsed": false
},
"localTime": 1659687085,
"localTimeZone": "<-06>6",
"upTime": 306
}
}

Crashes Immediately on macOS

macOS 12.4
Python 3.9.13
tmo-monitor 2.0.0 beta6

All dependencies installed, as far as I know. The main script crashes with:

$ ./bin/tmo-monitor.py Password: 2022/06/20 18:42:29 [DEBUG] Starting new HTTP connection (1): 192.168.12.1:80 2022/06/20 18:42:29 [DEBUG] http://192.168.12.1:80 "GET /fastmile_radio_status_web_app.cgi HTTP/1.1" 200 3318 Traceback (most recent call last): File "/Users/Administrator/Downloads/tmo-monitor-2.0.0-beta6/./bin/tmo-monitor.py", line 83, in <module> signal_info = gw_control.get_signal_info() File "/usr/local/lib/python3.9/site-packages/tmo_monitor/gateway/nokia.py", line 141, in get_signal_info info = signal_request.json() File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 910, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Enhanced Bootloop Prevention

Follow-up to #10

Bootloop prevention is currently implemented with an uptime check.

Add statefulness to prevent boot loops so that a given number of consecutive failures or a failure of a certain duration causes different behavior than endlessly rebooting.

Possible 5G band restart regression in v2 beta

edit2: oops ๐Ÿคฆ I completely missed that the .env file now contains flags to reboot based on 4G/5G bands, default false. Might be worth adding these flags as CLI overrides since this is a change from the default behavior of v1? I can send a PR if the maintainers are open to it :)

original issue below
Just pulled the latest version and restarting based on 5G bands isn't working. My router is camping on n71 but running with -5 n41 doesn't cause a restart like it does on the v1 branch.

edit: I'm running MacOS 12.0.1

Logs:

> ./tmo-monitor.py admin [redacted] -5 n41 --print-config --log-all --logfile /dev/stdout
Password:
Script configuration:
  Login info:
    Username: admin
    Password: [redacted]
  Ping configuration:
    Host: google.com
    Count: 1
    Interval: 10
  Connection configuration:
    Secondary band: ['n41']
  Reboot settings:
    Reboot now: False
    Skip reboot: False
    Min uptime: 90
  Reboot on:
  General settings:
    Log file: /dev/stdout
    Log all: True
    Log delta: False

eNB ID check passed, on 27120.
Camping on B66.
Camping on n71.
No reboot necessary.
4G: B66 | 5G: n71 | eNB ID: 27120 | Avg Ping:  ms | Uptime: 223 sec
2022/01/08 02:36:36 [INFO] 4G: B66 | 5G: n71 | eNB ID: 27120 | Avg Ping:  ms | Uptime: 223 sec

Thanks for all your work on this! My trashcan is finally usable ๐Ÿ™

Use technique other than ping to assess connection status

It looks like T-Mobile started blocking pings, and so the connection looks down even when it's not. This broke this tool for me โ€“ I'm assuming for others too.

We should add a different mechanism, such as DNS lookup or HTTP request.

How is the ping count supposed to be formatted?

I tried various choices and it looks to me like every time it's still only doing 1 ping.

pi@p314:~ $ /home/pi/tmo-monitor-main/tmo-monitor.py --ping-count 3 --skip-bands admin password
PING google.com (142.250.64.238) 56(84) bytes of data.
64 bytes from mia07s57-in-f14.1e100.net (142.250.64.238): icmp_seq=1 ttl=109 time=47.3 ms

--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 47.275/47.275/47.275/0.000 ms

No reboot necessary.
pi@p314:~ $ /home/pi/tmo-monitor-main/tmo-monitor.py --skip-bands --ping-count=1 admin password
PING google.com (142.250.64.238) 56(84) bytes of data.
64 bytes from mia07s57-in-f14.1e100.net (142.250.64.238): icmp_seq=1 ttl=109 time=54.8 ms

--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 54.781/54.781/54.781/0.000 ms

No reboot necessary.
pi@p314:~ $ /home/pi/tmo-monitor-main/tmo-monitor.py --skip-bands --ping-count=3 admin password
PING google.com (142.250.64.238) 56(84) bytes of data.
64 bytes from mia07s57-in-f14.1e100.net (142.250.64.238): icmp_seq=1 ttl=109 time=39.6 ms

--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 39.575/39.575/39.575/0.000 ms

Windows Compatibility

The script is not currently compatible with Windows due to its ping implementation. Conditionally translate ping flags to Windows equivalents. Check output for indications that Destination Host Unreachable.

For now, running with --skip-ping will work on Windows if that feature is not needed.

Could not post reboot request

Using Nokia 5G "trashcan" on firmware 1.2104.00.0286

2022/06/15 00:20:38 [DEBUG] Starting new HTTP connection (1): 192.168.12.1:80
2022/06/15 00:20:39 [DEBUG] http://192.168.12.1:80 "GET /dashboard_device_info_status_web_app.cgi HTTP/1.1" 200 649
2022/06/15 00:20:39 [INFO] Reboot requested.
2022/06/15 00:20:39 [INFO] Rebooting.
2022/06/15 00:20:39 [DEBUG] Starting new HTTP connection (1): 192.168.12.1:80
2022/06/15 00:20:39 [DEBUG] http://192.168.12.1:80 "GET /login_web_app.cgi?nonce HTTP/1.1" 200 369
2022/06/15 00:20:39 [DEBUG] Starting new HTTP connection (1): 192.168.12.1:80
2022/06/15 00:20:39 [DEBUG] http://192.168.12.1:80 "POST /login_web_app.cgi HTTP/1.1" 200 32
2022/06/15 00:20:39 [CRITICAL] Could not post reboot request, exiting.
(program terminates here)

Doesn't seem to be able to reboot the router, so it just exits?

Also all of this happens within a few seconds, it's not like it sends an initial reboot command then waits for the router, then fails.

Feature request: support for IPv6

IPv4 addresses are supported at ping hosts (e.g., 8.8.8.8), but IPv6 (e.g., 2001:4860:4860::8888) isn't on Linux as it requires the use of ping6 instead of ping.

It would be nice to support both.

Ping checks fail on macOS

When running latest main on macOS 12.0.1, ping checks fail with:

PING google.com (142.250.191.238): 56 data bytes
64 bytes from 142.250.191.238: icmp_seq=0 ttl=110 time=239.159 ms

--- google.com ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 239.159/239.159/239.159/0.000 ms

Traceback (most recent call last):
  File "/Users/adelikat/src/tmo-monitor/./tmo-monitor.py", line 417, in <module>
    ping_ms = tc_control.ping(config.ping['ping_host'], config.ping['ping_count'],
  File "/Users/adelikat/src/tmo-monitor/./tmo-monitor.py", line 157, in ping
    result = ping_time(i)
  File "/Users/adelikat/src/tmo-monitor/./tmo-monitor.py", line 154, in ping_time
    return round(float(ping_ms.group(1)))
AttributeError: 'NoneType' object has no attribute 'group'

This happens because macOS prints stddev instead of mdev.

Arcadyan gateway doesn't always provide all signal information

When the Arcadyan gateway returns the status of the signal, it doesn't always provide both 4g and 5g bands if not connected. For example, my gateway pulls this currently:

{ "device": { "friendlyName": "5G Gateway", "hardwareVersion": "R01", "isEnabled": true, "isMeshSupported": true, "macId": MACADDRESS, "manufacturer": "Arcadyan", "manufacturerOUI": "001A2A", "model": "KVD21", "name": "5G Gateway", "role": "gateway", "serial": SERIAL, "softwareVersion": "1.00.16", "type": "HSID", "updateState": "latest" }, "signal": { "4g": { "bands": [ "b66" ], "bars": 2.0, "cid": 3, "eNBID": 778528, "rsrp": -116, "rsrq": -13, "rssi": -103, "sinr": 0 }

When this happens, there is a key error for ['signal']['5g']['bands'].

Python 3.x compatibility

capture_output kwarg for subprocess.run was introduced in Python 3.7 - instead use stdout=subprocess.PIPE, stderr=subprocess.PIPE

Reported by reddit user /u/Tractor_Boy_500

No module named 'tailer'

I downloaded the 2.0.4 zip release and upgraded over my older working release.

pi@p314:~/tmo-monitor-main/bin $ ./tmo-monitor.py
Traceback (most recent call last):
File "./tmo-monitor.py", line 8, in
import tailer
ModuleNotFoundError: No module named 'tailer'

More Robust Ping Health Check

Allow specifying multiple ping hosts, with the ability to reboot if either any or all of them fail (flags can specify the behavior).

Support .env files & major refactoring of argument parsing

Hey there! First, thanks for the script!

I wanted to add (local) logging, but before I hacked on it I figured I'd add support for .env files and clean up the argument parsing a bit. I tried not to change the semantics but I haven't thoroughly tested yet.

What I've got is a pretty major refactor that's just one commit behind your repo's status.

https://github.com/AndrewPardoe/tmo-monitor/blob/config/tmo-monitor.py

If you like the refactor, I'm happy to integrate your multiple ping logic & submit a PR to merge everything back. If you don't like the refactor, I'll probably maintain a fork. I'm still testing so I haven't created a PR yet.

Please LMK.

Ping check fails on Windows

The ping command on Windows has different output than on Linux which causes parsing issues:

Approximate round trip times in milli-seconds:
    Minimum = 39ms, Maximum = 46ms, Average = 42ms

Handle DNS Failures

Handle DNS failures in a more explicit way.

Pinging an IP address (e.g. 1.1.1.1 or 8.8.8.8) can indicate whether there is network connectivity regardless of DNS functionality.

Likewise, more explicitly checking that DNS resolution is working may be a desirable but separate health check.

Provide an option to explicitly force IPv4 ping

I had issues when my Linux system didn't apparently handle IPv6 pings to Google very well, and for some reason tmo_monitor/gateway/base.py wanted to use IPv6 ping. It would be really nice to either explicitly force ping -4 by default, or allow the user to specify ping -4 as a command line option.

In my configuration I wanted to make double sure it didn't use IPv6 ping, so I just hardcoded base.py to add the -4 flag...

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.