Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mlxreg-collect
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ query_sensor() {
local output=$(mlxreg --device $device --reg_name MVCR --indexes "sensor_index=$sensor_idx" --get 2>&1)

if [ $? -ne 0 ]; then
echo "$timestamp,$date_str,$device,$sensor_idx,ERROR,0.0,query_failed" >> "mlxreg-data/${device//://}.csv"
echo "$timestamp,$date_str,$device,$sensor_idx,ERROR,0.0,query_failed" >> "mlxreg-data/${device//:/_}.csv"
return 1
Comment thread
k-rister marked this conversation as resolved.
fi

Expand All @@ -66,7 +66,7 @@ query_sensor() {
local name_lo=$(echo "$output" | grep "^sensor_name_lo" | awk '{print $NF}')

if [ -z "$power_hex" ]; then
echo "$timestamp,$date_str,$device,$sensor_idx,ERROR,0.0,parse_failed" >> "mlxreg-data/${device//://}.csv"
echo "$timestamp,$date_str,$device,$sensor_idx,ERROR,0.0,parse_failed" >> "mlxreg-data/${device//:/_}.csv"
return 1
fi

Expand All @@ -78,12 +78,12 @@ query_sensor() {
local sensor_name=$(decode_sensor_name "$name_hi" "$name_lo")

# Write to CSV: timestamp,date,device,sensor_index,sensor_name,power_watts,status
echo "$timestamp,$date_str,$device,$sensor_idx,$sensor_name,$power_watts,OK" >> "mlxreg-data/${device//:}.csv"
echo "$timestamp,$date_str,$device,$sensor_idx,$sensor_name,$power_watts,OK" >> "mlxreg-data/${device//:/_}.csv"
}

# Create CSV headers for each device
for device in "${device_array[@]}"; do
csv_file="mlxreg-data/${device//:}.csv"
csv_file="mlxreg-data/${device//:/_}.csv"
echo "timestamp,date,device,sensor_index,sensor_name,power_watts,status" > "$csv_file"
echo "Created output file: $csv_file"
done
Expand Down
10 changes: 4 additions & 6 deletions mlxreg-post-process
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ def process_mlxreg_csv(filename: str, file_id: str, metrics: CDMMetrics):
"""
print(f'mlxreg-post-process: processing CSV: {filename}')

# Extract device name from filename (e.g., 0000b500.0.csv.xz -> 0000:b5:00.0)
# Extract device name from filename (e.g., 0000_03_00.0.csv.xz -> 0000:03:00.0)
device_from_filename = Path(filename).stem
if device_from_filename.endswith('.csv'):
device_from_filename = device_from_filename[:-4]

# Convert back to PCI format: insert colons
# Pattern: 0000b500.0 -> 0000:b5:00.0
match = re.match(r'^(\d{4})(\w{2})(\d{2})\.(\d)$', device_from_filename)
if match:
device_from_filename = f"{match.group(1)}:{match.group(2)}:{match.group(3)}.{match.group(4)}"
# Convert back to PCI format: replace underscores with colons
# Pattern: 0000_03_00.0 -> 0000:03:00.0
device_from_filename = device_from_filename.replace('_', ':')

# Open file (handle both compressed and uncompressed)
if filename.endswith('.xz'):
Expand Down