Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic network diag script #1583

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Add basic network diag script #1583

wants to merge 11 commits into from

Conversation

XK9274
Copy link
Member

@XK9274 XK9274 commented May 13, 2024

Summary

A network check suite, quite basic for now but will help with debugging network issues as it grows. Designed to be called from the Tweaks -> Advanced -> Diagnostics menu however, can be called on the cmdline.

Will address: #1317 when complete

Waiting on Schmurtz to come back to check this over, we agreed on spidering for checking websites but this script can do almost all of it, just need to check the baked in domains/IP addresses against users who have issues in blocked regions (mostly China)

Examples

Through tweaks

When running as standalone through tweaks it will use the diagnostics framework, the script will generate an output similar to the below, which will be pushed through the exporter to an archive called log_export.7z on the SD root, containing some log files but most importantly these check results:


2024-05-13 21:50:44 - ================================ Hardware and config checks ================================
2024-05-13 21:50:44 - Check successful: Found 3 USB devices connected.
2024-05-13 21:50:44 - 8188fu driver is loaded and active.
2024-05-13 21:50:44 - WiFi is enabled, proceeding with network checks.
2024-05-13 21:50:44 - Active network interfaces found: wlan0
2024-05-13 21:50:44 - DNS Resolvers found: 192.168.1.254
2024-05-13 21:50:44 - Ping to DNS resolver 192.168.1.254 successful.
2024-05-13 21:50:44 - Network check complete for wlan0: IP 192.168.1.215, Subnet Mask 255.255.255.0, Gateway 192.168.1.254, DNS Resolvers: 192.168.1.254

2024-05-13 21:50:44 - ================================ Network Ping Tests ================================
2024-05-13 21:50:44 - Starting ping test for Google DNS: 8.8.8.8
2024-05-13 21:50:44 - Ping to 8.8.8.8 (Google DNS) successful.

2024-05-13 21:50:44 - Starting ping test for Cloudflare DNS: 1.1.1.1
2024-05-13 21:50:44 - Ping to 1.1.1.1 (Cloudflare DNS) successful.

2024-05-13 21:50:44 - Starting ping test for OpenDNS: 208.67.222.222
2024-05-13 21:50:44 - Ping to 208.67.222.222 (OpenDNS) successful.

2024-05-13 21:50:44 - ================================ Service and Game Site Checks ================================
2024-05-13 21:50:44 - Checking website availability: https://github.com
2024-05-13 21:50:45 - Website https://github.com is up.

2024-05-13 21:50:45 - Checking website availability: https://www.baidu.com
2024-05-13 21:50:47 - Website https://www.baidu.com is up.

2024-05-13 21:50:47 - Checking website availability: https://www.naver.com
2024-05-13 21:50:49 - Website https://www.naver.com is up.

2024-05-13 21:50:49 - Checking website availability: https://www.uol.com.br
2024-05-13 21:50:50 - Website https://www.uol.com.br is up.

2024-05-13 21:50:50 - Checking website availability: https://www.timesofindia.indiatimes.com
2024-05-13 21:50:51 - Website https://www.timesofindia.indiatimes.com is up.

2024-05-13 21:50:51 - Checking website availability: http://lobby.libretro.com/
2024-05-13 21:50:52 - Website http://lobby.libretro.com/ is up.

2024-05-13 21:50:52 - Checking website availability: https://www.lexaloffle.com/bbs/cpost_lister3.php?cat=7
2024-05-13 21:50:53 - Website https://www.lexaloffle.com/bbs/cpost_lister3.php?cat=7 is up.

2024-05-13 21:50:53 - ================================ Download Tests ================================
2024-05-13 21:50:53 - Testing download from: https://raw.githubusercontent.com/OnionUI/Themes/main/release/M%20by%20tenlevels.zip
2024-05-13 21:50:53 - Download test for https://raw.githubusercontent.com/OnionUI/Themes/main/release/M%20by%20tenlevels.zip was successful. Status code: 200

2024-05-13 21:50:53 - Testing download from: https://github.com/OnionUI/Ports-Collection/releases/latest/download/Sonic.Mania.7z
2024-05-13 21:50:54 - Download test for https://github.com/OnionUI/Ports-Collection/releases/latest/download/Sonic.Mania.7z was successful. Status code: 200

2024-05-13 21:50:54 - Testing download from: https://www.lexaloffle.com/bbs/cpost_lister3.php?cat=7
2024-05-13 21:50:54 - Download test for https://www.lexaloffle.com/bbs/cpost_lister3.php?cat=7 was successful. Status code: 200

2024-05-13 21:50:54 - ================================ RetroAchievements API Check ================================
2024-05-13 21:50:54 - Checking RetroAchievements API availability
2024-05-13 21:50:55 - API check was successful, returned 401 unauthorized. Status code: 401

2024-05-13 21:50:55 - ================================ Firmware DNS Check ================================
2024-05-13 21:50:55 - Firmware supports DNS, testing...

2024-05-13 21:50:55 - DNS resolution test for google.co.uk successful.

2024-05-13 21:50:55 - ================================ System Network Configuration ================================
2024-05-13 21:50:55 - Collecting network configuration information
2024-05-13 21:50:55 - ================================ Summary of Network Checks ================================
2024-05-13 21:50:55 - Ping Test Results: 3 successful out of 3 attempts.
2024-05-13 21:50:55 - Website Availability: 7 successful out of 7 checks.
2024-05-13 21:50:55 - Download Test Results: 3 successful out of 3 attempts.
2024-05-13 21:50:55 - Ping replies from all DNS providers - OK
2024-05-13 21:50:55 - Website checks - All sites are reachable
2024-05-13 21:50:55 - Download tests - All downloads successful
2024-05-13 21:50:55 - Executing exporter utility.
(util_exporter) 2024-05-13 21:50:55: Exporting and archiving logs
(util_exporter) 2024-05-13 21:50:55: Moving runtime logs
(util_exporter) 2024-05-13 21:50:56: Exported to: /mnt/SDCARD/log_export.7z
2024-05-13 21:50:56 - Network checks complete.


On cmdline

It can also be called on cmdline to expose the checks to other processes, returning a 0 on success and non-zero on failure:

./util_netcheck.sh perform_ping 8.8.8.8 "Google DNS" # Quick ping, when on cmdline the second arg can be anything
./util_netcheck.sh check_website https://github.com # Spider a website
./util_netcheck.sh test_download "https://raw.githubusercontent.com/OnionUI/Themes/main/release/M%20by%20tenlevels.zip" # Test run a download
./util_netcheck.sh check_firmware_for_dns_issue # Check if the device has a firmware capable of DNS, then test DNS 
./util_netcheck.sh check_network_complete # Checks if the current network is "complete" (IP/Subnet/Gateway/DNS all valid)
./util_netcheck.sh check_retroachievements_api # Checks if the Cheevos API replies to a failed request as expected
/mnt/SDCARD/.tmp_update/script/diagnostics # ./util_netcheck.sh check_website https://github.com
2024-05-13 20:53:59 - Active network interfaces found: wlan0
2024-05-13 20:53:59 - Proceeding, valid adaptor found
2024-05-13 20:53:59 - Checking website availability: https://github.com
2024-05-13 20:54:00 - Website https://github.com is up.

/mnt/SDCARD/.tmp_update/script/diagnostics # echo $?
0
/mnt/SDCARD/.tmp_update/script/diagnostics # ./util_netcheck.sh check_website https://github2222.com
2024-05-13 20:54:39 - Active network interfaces found: wlan0
2024-05-13 20:54:39 - Proceeding, valid adaptor found
2024-05-13 20:54:39 - Checking website availability: https://github2222.com
Failed to establish connection
2024-05-13 20:54:39 - Website https://github2222.com is down.

/mnt/SDCARD/.tmp_update/script/diagnostics # echo $?
1

@XK9274 XK9274 added the enhancement New or improved feature label May 13, 2024
@XK9274 XK9274 added this to the v4.4 milestone May 13, 2024
@XK9274 XK9274 requested a review from schmurtzm May 13, 2024 21:01
@XK9274 XK9274 self-assigned this May 13, 2024
@XK9274 XK9274 linked an issue May 13, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New or improved feature
Projects
Status: 💣 Test
Development

Successfully merging this pull request may close these issues.

Improve network check in update_networking.sh
1 participant