mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-10-31 09:05:05 +01:00 
			
		
		
		
	InfiniBandCollector: Scale raw readings from octets to bytes
This commit is contained in:
		| @@ -21,6 +21,7 @@ const IB_BASEPATH = "/sys/class/infiniband/" | ||||
| type InfinibandCollectorMetric struct { | ||||
| 	path  string | ||||
| 	unit  string | ||||
| 	scale int64 | ||||
| } | ||||
|  | ||||
| type InfinibandCollectorInfo struct { | ||||
| @@ -113,10 +114,10 @@ func (m *InfinibandCollector) Init(config json.RawMessage) error { | ||||
| 		// Check access to counter files | ||||
| 		countersDir := filepath.Join(path, "counters") | ||||
| 		portCounterFiles := map[string]InfinibandCollectorMetric{ | ||||
| 			"ib_recv":      {path: filepath.Join(countersDir, "port_rcv_data"), unit: "bytes"}, | ||||
| 			"ib_xmit":      {path: filepath.Join(countersDir, "port_xmit_data"), unit: "bytes"}, | ||||
| 			"ib_recv_pkts": {path: filepath.Join(countersDir, "port_rcv_packets"), unit: "packets"}, | ||||
| 			"ib_xmit_pkts": {path: filepath.Join(countersDir, "port_xmit_packets"), unit: "packets"}, | ||||
| 			"ib_recv":      {path: filepath.Join(countersDir, "port_rcv_data"), unit: "bytes", scale: 4}, | ||||
| 			"ib_xmit":      {path: filepath.Join(countersDir, "port_xmit_data"), unit: "bytes", scale: 4}, | ||||
| 			"ib_recv_pkts": {path: filepath.Join(countersDir, "port_rcv_packets"), unit: "packets", scale: 1}, | ||||
| 			"ib_xmit_pkts": {path: filepath.Join(countersDir, "port_xmit_packets"), unit: "packets", scale: 1}, | ||||
| 		} | ||||
| 		for _, counter := range portCounterFiles { | ||||
| 			err := unix.Access(counter.path, unix.R_OK) | ||||
| @@ -191,6 +192,8 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMetr | ||||
| 					fmt.Sprintf("Read(): Failed to convert Infininiband metrice %s='%s' to int64: %v", counterName, data, err)) | ||||
| 				continue | ||||
| 			} | ||||
| 			// Scale raw value | ||||
| 			v *= counterDef.scale | ||||
|  | ||||
| 			// Send absolut values | ||||
| 			if m.config.SendAbsoluteValues { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user