rename mod name, fix installer for perl mod
This commit is contained in:
parent
4e7396d719
commit
555b7ebd2b
@ -117,6 +117,7 @@ function install_packages {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Main configuration function to detect sensors and set up parameters
|
||||||
function configure {
|
function configure {
|
||||||
SENSORS_DETECTED=false
|
SENSORS_DETECTED=false
|
||||||
local sensorsOutput
|
local sensorsOutput
|
||||||
@ -127,7 +128,7 @@ function configure {
|
|||||||
|
|
||||||
install_packages
|
install_packages
|
||||||
|
|
||||||
#### Collect lm-sensors output ####
|
#### Collect sensor data ####
|
||||||
#region sensors collection
|
#region sensors collection
|
||||||
if [ "$DEBUG_REMOTE" = true ]; then
|
if [ "$DEBUG_REMOTE" = true ]; then
|
||||||
warn "Remote debugging is used. Sensor readings from dump file $DEBUG_JSON_FILE will be used."
|
warn "Remote debugging is used. Sensor readings from dump file $DEBUG_JSON_FILE will be used."
|
||||||
@ -532,49 +533,19 @@ insert_node_info() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Collect lm-sensors data
|
# Collect sensor data
|
||||||
collect_sensors_output() {
|
collect_sensors_output() {
|
||||||
local output_file="$1"
|
local output_file="$1"
|
||||||
local sensorsCmd
|
|
||||||
|
|
||||||
if [[ $DEBUG_REMOTE == true ]]; then
|
#region PveSensorInfoMod heredoc
|
||||||
sensorsCmd="cat \"$DEBUG_JSON_FILE\""
|
|
||||||
else
|
|
||||||
# Note: sensors -f (Fahrenheit) breaks fan speeds
|
|
||||||
sensorsCmd="sensors -j 2>/dev/null"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remember to reflect this in sanitize_sensors_output()
|
|
||||||
#region sensors heredoc
|
|
||||||
sed -i '/my \$dinfo = df('\''\/'\'', 1);/i\
|
sed -i '/my \$dinfo = df('\''\/'\'', 1);/i\
|
||||||
# Collect sensor data from lm-sensors\
|
# Collect sensor data from PveSensorInfoMod\
|
||||||
$res->{sensorsOutput} = `'"$sensorsCmd"'`;\
|
# Bad practice to add use here, but cleaner implementation would require several extensive modifications.\
|
||||||
\
|
use PVE::API2::GPUMonitor;\
|
||||||
# Sanitize JSON output to handle common lm-sensors parsing issues\
|
$res->{sensorsJSONOutput} = PVE::API2::GPUMonitor::get_sensors_stats();\
|
||||||
# Replace ERROR lines with placeholder values\
|
|
||||||
$res->{sensorsOutput} =~ s/ERROR:.+\\s(\\w+):\\s(.+)/\\"$1\\": 0.000,/g;\
|
|
||||||
$res->{sensorsOutput} =~ s/ERROR:.+\\s(\\w+)!/\\"$1\\": 0.000,/g;\
|
|
||||||
\
|
|
||||||
# Remove trailing commas before closing braces\
|
|
||||||
$res->{sensorsOutput} =~ s/,\\s*(\})/$1/g;\
|
|
||||||
\
|
|
||||||
# Replace NaN values with null for valid JSON\
|
|
||||||
$res->{sensorsOutput} =~ s/\\bNaN\\b/null/g;\
|
|
||||||
\
|
|
||||||
# Fix duplicate SODIMM keys by appending temperature sensor number with a space - handle both pretty and one-line JSON\
|
|
||||||
# Example: "SODIMM":{"temp3_input":34.0} becomes "SODIMM 3":{"temp3_input":34.0}\
|
|
||||||
$res->{sensorsOutput} =~ s/"SODIMM"\\s*:\\s*\\{\\s*"temp(\\d+)_input"/"SODIMM $1": {\\n "temp$1_input"/g;\
|
|
||||||
\
|
|
||||||
# Fix duplicate fans keys by appending fan number with a space - handle both pretty and one-line JSON\
|
|
||||||
# Example: "Processor Fan":{"fan2_input":1000,...} → "Processor Fan 2":{"fan2_input":1000,...}\
|
|
||||||
$res->{sensorsOutput} =~ s/"([^"]+)"\\s*:\\s*\{\\s*"fan(\\d+)_input"/"$1 $2": {\\n "fan$2_input"/g;\
|
|
||||||
\
|
|
||||||
# Format JSON output properly (workaround for lm-sensors >3.6.0 issues)\
|
|
||||||
$res->{sensorsOutput} =~ /^(.*)$/s;\
|
|
||||||
$res->{sensorsOutput} = `echo \\Q$1\\E | python3 -m json.tool 2>/dev/null || echo \\Q$1\E`;\
|
|
||||||
' "$NODES_PM_FILE"
|
' "$NODES_PM_FILE"
|
||||||
#endregion sensors heredoc
|
#endregion PveSensorInfoMod heredoc
|
||||||
info "Sensors' retriever added to \"$output_file\"."
|
info "Sensor data retriever added to \"$output_file\"."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Collect UPS data
|
# Collect UPS data
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user