mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 04:27:25 +01:00
Option to use MIG UUID as subtype-id in NvidiaCollector
This commit is contained in:
parent
826f364772
commit
d4c89a4206
@ -21,6 +21,7 @@ type NvidiaCollectorConfig struct {
|
|||||||
AddBoardNumberMeta bool `json:"add_board_number_meta,omitempty"`
|
AddBoardNumberMeta bool `json:"add_board_number_meta,omitempty"`
|
||||||
AddSerialMeta bool `json:"add_serial_meta,omitempty"`
|
AddSerialMeta bool `json:"add_serial_meta,omitempty"`
|
||||||
ProcessMigDevices bool `json:"process_mig_devices,omitempty"`
|
ProcessMigDevices bool `json:"process_mig_devices,omitempty"`
|
||||||
|
UseUuidForMigDevices bool `json:"use_uuid_for_mig_device,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NvidiaCollectorDevice struct {
|
type NvidiaCollectorDevice struct {
|
||||||
@ -49,6 +50,8 @@ func (m *NvidiaCollector) Init(config json.RawMessage) error {
|
|||||||
m.name = "NvidiaCollector"
|
m.name = "NvidiaCollector"
|
||||||
m.config.AddPciInfoTag = false
|
m.config.AddPciInfoTag = false
|
||||||
m.config.UsePciInfoAsTypeId = false
|
m.config.UsePciInfoAsTypeId = false
|
||||||
|
m.config.ProcessMigDevices = false
|
||||||
|
m.config.UseUuidForMigDevices = false
|
||||||
m.setup()
|
m.setup()
|
||||||
if len(config) > 0 {
|
if len(config) > 0 {
|
||||||
err = json.Unmarshal(config, &m.config)
|
err = json.Unmarshal(config, &m.config)
|
||||||
@ -1143,12 +1146,21 @@ func (m *NvidiaCollector) Read(interval time.Duration, output chan lp.CCMetric)
|
|||||||
for k, v := range m.gpus[i].tags {
|
for k, v := range m.gpus[i].tags {
|
||||||
migDevice.tags[k] = v
|
migDevice.tags[k] = v
|
||||||
}
|
}
|
||||||
m.gpus[i].tags["stype"] = "mig"
|
migDevice.tags["stype"] = "mig"
|
||||||
m.gpus[i].tags["stype-id"] = fmt.Sprintf("%d", j)
|
if !m.config.UseUuidForMigDevices {
|
||||||
|
migDevice.tags["stype-id"] = fmt.Sprintf("%d", j)
|
||||||
|
} else {
|
||||||
|
uuid, ret := nvml.DeviceGetUUID(mdev)
|
||||||
|
if ret != nvml.SUCCESS {
|
||||||
|
cclog.ComponentError(m.name, "Unable to get UUID for mig device at index", j, ":", err.Error())
|
||||||
|
} else {
|
||||||
|
migDevice.tags["stype-id"] = uuid
|
||||||
|
}
|
||||||
|
}
|
||||||
for k, v := range m.gpus[i].meta {
|
for k, v := range m.gpus[i].meta {
|
||||||
migDevice.meta[k] = v
|
migDevice.meta[k] = v
|
||||||
}
|
}
|
||||||
if _, ok := migDevice.meta["uuid"]; ok {
|
if _, ok := migDevice.meta["uuid"]; ok && !m.config.UseUuidForMigDevices {
|
||||||
uuid, ret := nvml.DeviceGetUUID(mdev)
|
uuid, ret := nvml.DeviceGetUUID(mdev)
|
||||||
if ret == nvml.SUCCESS {
|
if ret == nvml.SUCCESS {
|
||||||
migDevice.meta["uuid"] = uuid
|
migDevice.meta["uuid"] = uuid
|
||||||
|
Loading…
Reference in New Issue
Block a user