Skip to content

Commit d388474

Browse files
fix: remove buildHOST from makefile, add redfish_chassis_temperature_sensor_health metric jenningsloy318#73
1 parent 5213d49 commit d388474

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ VERSION ?= $(shell cat VERSION)
1111
REVERSION ?=$(shell git log -1 --pretty="%H")
1212
BRANCH ?=$(shell git rev-parse --abbrev-ref HEAD)
1313
TIME ?=$(shell date --rfc-3339=seconds)
14-
HOST ?=$(shell hostname)
1514
DOCKER := $(shell { command -v podman || command -v docker; } 2>/dev/null)
1615

1716

1817
all: fmt style build docker-build docker-rpm
19-
18+
2019
style:
2120
@echo ">> checking code style"
2221
! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
@@ -31,9 +30,9 @@ check_license:
3130
exit 1; \
3231
fi
3332

34-
build: |
33+
build: |
3534
@echo ">> building binaries"
36-
$(GO) build -o build/redfish_exporter -ldflags '-X "main.Version=$(VERSION)" -X "main.BuildRevision=$(REVERSION)" -X "main.BuildBranch=$(BRANCH)" -X "main.BuildTime=$(TIME)" -X "main.BuildHost=$(HOSTNAME)"'
35+
$(GO) build -o build/redfish_exporter -ldflags '-X "main.Version=$(VERSION)" -X "main.BuildRevision=$(REVERSION)" -X "main.BuildBranch=$(BRANCH)" -X "main.BuildTime=$(TIME)"'
3736

3837
docker-build-centos7:
3938
$(DOCKER) run -v `pwd`:/go/src/github.com/jenningsloy318/redfish_exporter -w /go/src/github.com/jenningsloy318/redfish_exporter docker.io/jenningsloy318/prom-builder:centos7 /bin/bash -c "yum update -y && make build"
@@ -62,9 +61,9 @@ docker-rpm:
6261

6362
fmt:
6463
@echo ">> format code style"
65-
$(GOFMT) -w $$(find . -path ./vendor -prune -o -name '*.go' -print)
64+
$(GOFMT) -w $$(find . -path ./vendor -prune -o -name '*.go' -print)
6665

6766
clean:
6867
rm -rf $(BIN_DIR)
6968

70-
.PHONY: all style check_license fmt build fmt build rpm docker-build docker-rpm
69+
.PHONY: all style check_license fmt build fmt build rpm docker-build docker-rpm

collector/chassis_collector.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func createChassisMetricMap() map[string]Metric {
4646
addToMetricMap(chassisMetrics, ChassisSubsystem, "model_info", "organization responsible for producing the chassis, the name by which the manufacturer generally refers to the chassis, and a part number and sku assigned by the organization that is responsible for producing or manufacturing the chassis", ChassisModel)
4747

4848
addToMetricMap(chassisMetrics, ChassisSubsystem, "temperature_sensor_state", fmt.Sprintf("status state of temperature on this chassis component,%s", CommonStateHelp), ChassisTemperatureLabelNames)
49+
addToMetricMap(chassisMetrics, ChassisSubsystem, "temperature_sensor_health", fmt.Sprintf("status health of temperature on this chassis component,%s", CommonStateHelp), ChassisTemperatureLabelNames)
4950
addToMetricMap(chassisMetrics, ChassisSubsystem, "temperature_celsius", "celsius of temperature on this chassis component", ChassisTemperatureLabelNames)
5051

5152
addToMetricMap(chassisMetrics, ChassisSubsystem, "fan_health", fmt.Sprintf("fan health on this chassis component,%s", CommonHealthHelp), ChassisFanLabelNames)
@@ -264,11 +265,15 @@ func parseChassisTemperature(ch chan<- prometheus.Metric, chassisID string, chas
264265
chassisTemperatureSensorName := chassisTemperature.Name
265266
chassisTemperatureSensorID := chassisTemperature.MemberID
266267
chassisTemperatureStatus := chassisTemperature.Status
267-
// chassisTemperatureStatusHealth :=chassisTemperatureStatus.Health
268-
chassisTemperatureStatusState := chassisTemperatureStatus.State
269-
// chassisTemperatureStatusLabelNames :=[]string{BaseLabelNames,"temperature_sensor_name","temperature_sensor_member_id")
270268
chassisTemperatureLabelvalues := []string{"temperature", chassisID, chassisTemperatureSensorName, chassisTemperatureSensorID}
271269

270+
chassisTemperatureStatusHealth :=chassisTemperatureStatus.Health
271+
if chassisTemperatureStatusHealthValue, ok := parseCommonStatusHealth(chassisTemperatureStatusHealth); ok {
272+
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_temperature_sensor_health"].desc, prometheus.GaugeValue, chassisTemperatureStatusHealthValue, chassisTemperatureLabelvalues...)
273+
}
274+
275+
chassisTemperatureStatusState := chassisTemperatureStatus.State
276+
// chassisTemperatureStatusLabelNames :=[]string{BaseLabelNames,"temperature_sensor_name","temperature_sensor_member_id")
272277
// ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_temperature_status_health"].desc, prometheus.GaugeValue, parseCommonStatusHealth(chassisTemperatureStatusHealth), chassisTemperatureLabelvalues...)
273278
if chassisTemperatureStatusStateValue, ok := parseCommonStatusState(chassisTemperatureStatusState); ok {
274279
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_temperature_sensor_state"].desc, prometheus.GaugeValue, chassisTemperatureStatusStateValue, chassisTemperatureLabelvalues...)

0 commit comments

Comments
 (0)