Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlhansen committed Jul 16, 2024
1 parent f05789c commit 71f2da5
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ metrics:
As shown in the above example, under `hosts` you can specify login information for individual hosts via their IP address, otherwise the exporter will attempt to use the login information under `default`. The login user only needs read-only permissions. Under `metrics` you can select what kind of metrics that should be returned, as described in more detail below.

For a detailed description of the configuration, please see the [sample-config.yml](sample-config.yml) file.
**For a detailed description of the configuration, please see the [sample-config.yml](sample-config.yml) file.**

Because the metrics are collected on-demand it can take several minutes to scrape the metrics endpoint, depending on how many metrics groups are selected in the configuration file. For this reason you should carefully select the metrics of interest and make sure Prometheus is configured with a sufficiently high scrape timeout value.

Expand Down Expand Up @@ -125,7 +125,7 @@ idrac_power_control_avg_consumed_watts{id="0",name="System Power Control"} 166
idrac_power_control_interval_in_minutes{id="0",name="System Power Control"} 1
```

### Event Log
### System Event Log
This is not exactly an ordinary metric, but it is often convenient to be informed about new entries in the event log. The value of this metric is the unix timestamp for when the entry was created.

```text
Expand Down
3 changes: 1 addition & 2 deletions charts/idrac-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ idracConfig: |
address: 0.0.0.0 # Running in a container, this makes sense
port: 9348 # Listen port
timeout: 60 # HTTP timeout (in seconds) for Redfish API calls
retries: 10 # Number of retries before a target is marked as unreachable
hosts:
default:
username: IDRAC_USERNAME
Expand All @@ -95,7 +94,7 @@ idracConfig: |
system: true
sensors: true
power: true
sel: true # iDRAC only
events: true
storage: true
memory: true
network: true
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.20
require (
github.com/prometheus/client_golang v1.19.0
github.com/prometheus/common v0.48.0
github.com/xhit/go-str2duration/v2 v2.1.0
gopkg.in/yaml.v2 v2.4.0
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5E
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
Expand Down
3 changes: 1 addition & 2 deletions idrac.yml.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
address: 0.0.0.0 # Running in a container, this makes sense
port: 9348 # Listen port
timeout: 60 # HTTP timeout (in seconds) for Redfish API calls
retries: 10 # Number of retries before a target is marked as unreachable
hosts:
default:
username: "$IDRAC_USERNAME"
Expand All @@ -10,7 +9,7 @@ metrics:
system: true
sensors: true
power: true
sel: true
events: true
storage: true
memory: true
network: true
21 changes: 11 additions & 10 deletions internal/collector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ func (client *Client) findAllEndpoints() error {
client.vendor = H3C
}

// Path for event log
switch client.vendor {
case DELL:
client.eventPath = "/redfish/v1/Managers/iDRAC.Embedded.1/Logs/Sel"
case LENOVO:
client.eventPath = "/redfish/v1/Systems/1/LogServices/PlatformLog/Entries"
case HPE:
client.eventPath = "/redfish/v1/Systems/1/LogServices/IML/Entries"
}

// Fix for Inspur bug
if client.vendor == INSPUR {
client.storagePath = strings.ReplaceAll(client.storagePath, "Storages", "Storage")
Expand All @@ -134,20 +144,11 @@ func (client *Client) findAllEndpoints() error {
if strings.Contains(root.Name, "HP RESTful") {
client.memoryPath = "/redfish/v1/Systems/1/Memory/"
client.storagePath = "/redfish/v1/Systems/1/SmartStorage/ArrayControllers/"
client.eventPath = ""
client.version = 4
}
}

// Path for event log
switch client.vendor {
case DELL:
client.eventPath = "/redfish/v1/Managers/iDRAC.Embedded.1/Logs/Sel"
case LENOVO:
client.eventPath = "/redfish/v1/Systems/1/LogServices/PlatformLog/Entries"
case HPE:
client.eventPath = "/redfish/v1/Systems/1/LogServices/IML/Entries"
}

return nil
}

Expand Down
6 changes: 3 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"math"
"os"
"strings"
"time"

"github.com/mrlhansen/idrac_exporter/internal/log"
"github.com/xhit/go-str2duration/v2"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -105,10 +105,10 @@ func ReadConfig(filename string) {
}

if Config.Event.MaxAge == "" {
Config.Event.MaxAge = "168h"
Config.Event.MaxAge = "7d"
}

t, err := time.ParseDuration(Config.Event.MaxAge)
t, err := str2duration.ParseDuration(Config.Event.MaxAge)
if err != nil {
log.Fatal("Invalid configuration: unable to parse duration: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func readConfigEnv() {
getEnvString("CONFIG_METRICS_PREFIX", &Config.MetricsPrefix)
getEnvString("CONFIG_DEFAULT_USERNAME", &username)
getEnvString("CONFIG_DEFAULT_PASSWORD", &password)
getEnvString("CONFIG_EVENT_SEVERITY", &Config.Event.Severity)
getEnvString("CONFIG_EVENT_MAXAGE", &Config.Event.MaxAge)
getEnvString("CONFIG_EVENTS_SEVERITY", &Config.Event.Severity)
getEnvString("CONFIG_EVENTS_MAXAGE", &Config.Event.MaxAge)

getEnvUint("CONFIG_PORT", &Config.Port)
getEnvUint("CONFIG_TIMEOUT", &Config.Timeout)
Expand Down
7 changes: 3 additions & 4 deletions sample-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ metrics:
memory: false # CONFIG_METRICS_MEMORY=true
network: false # CONFIG_METRICS_NETWORK=true

# The events section is used for filtering events and it is only needed when
# the "events" metrics are enabled. Events can be filtered based on minimum
# severity and maximum age.
# The events section is used for filtering events when the "events" metrics group
# is enabled. Events can be filtered based on minimum severity and maximum age.
# Severity must be one of "ok", "warning", "critical"
events:
severity: warning # CONFIG_EVENTS_SEVERITY=warning
maxage: 168h # CONFIG_EVENTS_MAXAGE=168h
maxage: 7d # CONFIG_EVENTS_MAXAGE=7d

0 comments on commit 71f2da5

Please sign in to comment.