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 Support for GPU Clock Frequencies (sclk and mclk) in hwmon Collector #3093

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions collector/fixtures/e2e-64k-page-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,10 @@ node_hwmon_fan_target_rpm{chip="nct6779",sensor="fan2"} 27000
# HELP node_hwmon_fan_tolerance Hardware monitor fan element tolerance
# TYPE node_hwmon_fan_tolerance gauge
node_hwmon_fan_tolerance{chip="nct6779",sensor="fan2"} 0
# HELP node_hwmon_freq_freq_mhz Hardware monitor for GPU frequency in MHz
# TYPE node_hwmon_freq_freq_mhz gauge
node_hwmon_freq_freq_mhz{chip="hwmon4",sensor="mclk"} 300
node_hwmon_freq_freq_mhz{chip="hwmon4",sensor="sclk"} 214
# HELP node_hwmon_in_alarm Hardware sensor alarm status (in)
# TYPE node_hwmon_in_alarm gauge
node_hwmon_in_alarm{chip="nct6779",sensor="in0"} 0
Expand Down Expand Up @@ -984,8 +988,10 @@ node_hwmon_pwm_weight_temp_step_tol{chip="nct6779",sensor="pwm1"} 0
# TYPE node_hwmon_sensor_label gauge
node_hwmon_sensor_label{chip="hwmon4",label="foosensor",sensor="temp1"} 1
node_hwmon_sensor_label{chip="hwmon4",label="foosensor",sensor="temp2"} 1
node_hwmon_sensor_label{chip="platform_applesmc_768",label="Left side ",sensor="fan1"} 1
node_hwmon_sensor_label{chip="platform_applesmc_768",label="Right side ",sensor="fan2"} 1
node_hwmon_sensor_label{chip="hwmon4",label="mclk",sensor="freq2"} 1
node_hwmon_sensor_label{chip="hwmon4",label="sclk",sensor="freq1"} 1
node_hwmon_sensor_label{chip="platform_applesmc_768",label="Left side",sensor="fan1"} 1
node_hwmon_sensor_label{chip="platform_applesmc_768",label="Right side",sensor="fan2"} 1
node_hwmon_sensor_label{chip="platform_coretemp_0",label="Core 0",sensor="temp2"} 1
node_hwmon_sensor_label{chip="platform_coretemp_0",label="Core 1",sensor="temp3"} 1
node_hwmon_sensor_label{chip="platform_coretemp_0",label="Core 2",sensor="temp4"} 1
Expand Down
10 changes: 8 additions & 2 deletions collector/fixtures/e2e-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,10 @@ node_hwmon_fan_target_rpm{chip="nct6779",sensor="fan2"} 27000
# HELP node_hwmon_fan_tolerance Hardware monitor fan element tolerance
# TYPE node_hwmon_fan_tolerance gauge
node_hwmon_fan_tolerance{chip="nct6779",sensor="fan2"} 0
# HELP node_hwmon_freq_freq_mhz Hardware monitor for GPU frequency in MHz
# TYPE node_hwmon_freq_freq_mhz gauge
node_hwmon_freq_freq_mhz{chip="hwmon4",sensor="mclk"} 300
node_hwmon_freq_freq_mhz{chip="hwmon4",sensor="sclk"} 214
# HELP node_hwmon_in_alarm Hardware sensor alarm status (in)
# TYPE node_hwmon_in_alarm gauge
node_hwmon_in_alarm{chip="nct6779",sensor="in0"} 0
Expand Down Expand Up @@ -1006,8 +1010,10 @@ node_hwmon_pwm_weight_temp_step_tol{chip="nct6779",sensor="pwm1"} 0
# TYPE node_hwmon_sensor_label gauge
node_hwmon_sensor_label{chip="hwmon4",label="foosensor",sensor="temp1"} 1
node_hwmon_sensor_label{chip="hwmon4",label="foosensor",sensor="temp2"} 1
node_hwmon_sensor_label{chip="platform_applesmc_768",label="Left side ",sensor="fan1"} 1
node_hwmon_sensor_label{chip="platform_applesmc_768",label="Right side ",sensor="fan2"} 1
node_hwmon_sensor_label{chip="hwmon4",label="mclk",sensor="freq2"} 1
node_hwmon_sensor_label{chip="hwmon4",label="sclk",sensor="freq1"} 1
node_hwmon_sensor_label{chip="platform_applesmc_768",label="Left side",sensor="fan1"} 1
node_hwmon_sensor_label{chip="platform_applesmc_768",label="Right side",sensor="fan2"} 1
node_hwmon_sensor_label{chip="platform_coretemp_0",label="Core 0",sensor="temp2"} 1
node_hwmon_sensor_label{chip="platform_coretemp_0",label="Core 1",sensor="temp3"} 1
node_hwmon_sensor_label{chip="platform_coretemp_0",label="Core 2",sensor="temp4"} 1
Expand Down
26 changes: 23 additions & 3 deletions collector/fixtures/sys.ttar
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,26 @@ Lines: 1
100000
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/hwmon/hwmon4/freq1_input
Lines: 1
214000000
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/hwmon/hwmon4/freq1_label
Lines: 1
sclk
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/hwmon/hwmon4/freq2_input
Lines: 1
300000000
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/hwmon/hwmon4/freq2_label
Lines: 1
mclk
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/hwmon/hwmon5
SymlinkTo: ../../devices/platform/bogus.0/hwmon/hwmon5/
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -1337,7 +1357,7 @@ Mode: 444
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/nvme/nvme0/model
Lines: 1
Samsung SSD 970 PRO 512GB
Samsung SSD 970 PRO 512GB
Mode: 444
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/nvme/nvme0/serial
Expand Down Expand Up @@ -2750,7 +2770,7 @@ Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/applesmc.768/fan1_label
Lines: 1
Left side
Left side
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/applesmc.768/fan1_manual
Expand Down Expand Up @@ -2784,7 +2804,7 @@ Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/applesmc.768/fan2_label
Lines: 1
Right side
Right side
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/applesmc.768/fan2_manual
Expand Down
11 changes: 10 additions & 1 deletion collector/hwmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
hwmonSensorTypes = []string{
"vrm", "beep_enable", "update_interval", "in", "cpu", "fan",
"pwm", "temp", "curr", "power", "energy", "humidity",
"intrusion",
"intrusion", "freq",
}
)

Expand Down Expand Up @@ -357,6 +357,15 @@ func (c *hwMonCollector) updateHwmon(ch chan<- prometheus.Metric, dir string) er
continue
}

if sensorType == "freq" && element == "input" {
if label, ok := sensorData["label"]; ok {
sensorLabel := cleanMetricName(label)
desc := prometheus.NewDesc(name+"_freq_mhz", "Hardware monitor for GPU frequency in MHz", hwmonLabelDesc, nil)
ch <- prometheus.MustNewConstMetric(
desc, prometheus.GaugeValue, parsedValue/1000000.0, append(labels[:len(labels)-1], sensorLabel)...)
}
continue
}
// fallback, just dump the metric as is

desc := prometheus.NewDesc(name, "Hardware monitor "+sensorType+" element "+element, hwmonLabelDesc, nil)
Expand Down