From b29000850e539c4e6717e9b339a5478b51a69aba Mon Sep 17 00:00:00 2001 From: Meliox Date: Sat, 15 Jun 2024 19:38:38 +0200 Subject: [PATCH] save-sensors-data argument --- pve-mod-gui-sensors.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 856c8c0..75885b3 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -54,7 +54,7 @@ function err { # Function to display usage information function usage { - msgb "\nUsage:\n$0 [install | uninstall]\n" + msgb "\nUsage:\n$0 [install | uninstall | save-sensors-data]\n" exit 1 } @@ -768,6 +768,20 @@ function restart_proxy { systemctl restart pveproxy } +function save_sensors_data { + local script_dir filepath + # Check + if (command -v sensors &>/dev/null); then + # Save sensors output to sensorsdata.json in the script directory + script_dir="$(dirname "$0")" + filepath="$script_dir/sensorsdata.json" + sensors -j > "$filepath" + msgb "Sensors data saved in $filepath" + else + err "Sensors in not installed. No file could be saved" + fi +} + # Process the arguments using a while loop and a case statement executed=0 while [[ $# -gt 0 ]]; do @@ -785,6 +799,12 @@ while [[ $# -gt 0 ]]; do uninstall_mod echo # add a new line ;; + save-sensors-data) + executed=$(($executed + 1)) + msgb "\nSaves the Sensors json output into a file that can be used for debugging..." + save_sensors_data + echo # add a new line + ;; esac shift done