Skip to content

Commit 05bd127

Browse files
Merge pull request jenningsloy318#52 from dylngg/add_model
Add chassis model, manufacturer, and part number in metadata metric
2 parents 42a8382 + 51b9c14 commit 05bd127

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

collector/chassis_collector.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
var (
1717
ChassisSubsystem = "chassis"
1818
ChassisLabelNames = []string{"resource", "chassis_id"}
19+
ChassisModel = []string{"resource", "chassis_id", "manufacturer", "model", "part_number"}
1920
ChassisTemperatureLabelNames = []string{"resource", "chassis_id", "sensor", "sensor_id"}
2021
ChassisFanLabelNames = []string{"resource", "chassis_id", "fan", "fan_id", "fan_unit"}
2122
ChassisPowerVoltageLabelNames = []string{"resource", "chassis_id", "power_voltage", "power_voltage_id"}
@@ -41,6 +42,14 @@ var (
4142
nil,
4243
),
4344
},
45+
"chassis_model_info": {
46+
desc: prometheus.NewDesc(
47+
prometheus.BuildFQName(namespace, ChassisSubsystem, "model_info"),
48+
"organization responsible for producing the chassis, the name by which the manufacturer generally refers to the chassis, and a part number assigned by the organization that is responsible for producing or manufacturing the chassis",
49+
ChassisModel,
50+
nil,
51+
),
52+
},
4453
"chassis_temperature_sensor_state": {
4554
desc: prometheus.NewDesc(
4655
prometheus.BuildFQName(namespace, ChassisSubsystem, "temperature_sensor_state"),
@@ -343,6 +352,12 @@ func (c *ChassisCollector) Collect(ch chan<- prometheus.Metric) {
343352
ch <- prometheus.MustNewConstMetric(c.metrics["chassis_state"].desc, prometheus.GaugeValue, chassisStatusStateValue, ChassisLabelValues...)
344353
}
345354

355+
chassisManufacturer := chassis.Manufacturer
356+
chassisModel := chassis.Model
357+
chassisPartNumber := chassis.PartNumber
358+
ChassisModelLabelValues := []string{"chassis", chassisID, chassisManufacturer, chassisModel, chassisPartNumber}
359+
ch <- prometheus.MustNewConstMetric(c.metrics["chassis_model_info"].desc, prometheus.GaugeValue, 1, ChassisModelLabelValues...)
360+
346361
chassisThermal, err := chassis.Thermal()
347362
if err != nil {
348363
chassisLogContext.WithField("operation", "chassis.Thermal()").WithError(err).Error("error getting thermal data from chassis")

0 commit comments

Comments
 (0)