Skip to content

Commit

Permalink
Add RPC stats for the client
Browse files Browse the repository at this point in the history
Signed-Off-By: Robert Clark <robert.d.clark@hpe.com>
  • Loading branch information
Robert Clark committed Jun 6, 2017
1 parent 6863c97 commit 9c8dd0a
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions sources/procfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ const (
statsHelp string = "Number of operations the filesystem has performed."

// Help text dedicated to the 'brw_stats' file
pagesPerBlockRWHelp string = "Total number of pages per RPC."
pagesPerBlockRWHelp string = "Total number of pages per block RPC."
discontiguousPagesHelp string = "Total number of logical discontinuities per RPC."
ioTimeHelp string = "Total time in milliseconds the filesystem has spent processing various object sizes."
diskIOSizeHelp string = "Total number of operations the filesystem has performed for the given size."
diskIOsInFlightHelp string = "Current number of I/O operations that are processing during the snapshot."

// Help text dedicated to the 'rpc_stats' file
pagesPerRPCHelp string = "Total number of pages per RPC."
rpcsInFlightHelp string = "Current number of RPCs that are processing during the snapshot."
offsetHelp string = "Current RPC offset by size."

// string mappings for 'health_check' values
healthCheckHealthy string = "1"
healthCheckUnhealthy string = "0"
Expand Down Expand Up @@ -236,6 +241,14 @@ func (s *lustreProcfsSource) generateClientMetricTemplates() error {
{"stats", "stats_total", statsHelp, s.counterMetric, true},
{"xattr_cache", "xattr_cache_enabled", "Returns '1' if extended attribute cache is enabled", s.gaugeMetric, false},
},
"mdc/*": {
{"rpc_stats", "mdc_rpcs_in_flight", rpcsInFlightHelp, s.gaugeMetric},
},
"osc/*": {
{"rpc_stats", "pages_per_rpc", pagesPerRPCHelp, s.counterMetric},
{"rpc_stats", "osc_rpcs_in_flight", rpcsInFlightHelp, s.gaugeMetric},
{"rpc_stats", "rpcs_offset", offsetHelp, s.counterMetric},
},
}
for path := range metricMap {
for _, item := range metricMap[path] {
Expand Down Expand Up @@ -293,8 +306,8 @@ func (s *lustreProcfsSource) Update(ch chan<- prometheus.Metric) (err error) {
if err != nil {
return err
}
case "brw_stats":
err = s.parseBRWStats(metric.source, "brw_stats", path, directoryDepth, metric.helpText, metric.promName, func(nodeType string, brwOperation string, brwSize string, nodeName string, name string, helpText string, value uint64) {
case "brw_stats", "rpc_stats":
err = s.parseBRWStats(metric.source, "stats", path, directoryDepth, metric.helpText, metric.promName, func(nodeType string, brwOperation string, brwSize string, nodeName string, name string, helpText string, value uint64) {
ch <- metric.metricFunc([]string{nodeType, "operation", "size"}, []string{nodeName, brwOperation, brwSize}, name, helpText, value)
})
if err != nil {
Expand Down Expand Up @@ -433,10 +446,18 @@ func splitBRWStats(statBlock string) (metricList []lustreBRWMetric, err error) {
// Lines are in the following format:
// [size] [# read RPCs] [relative read size (%)] [cumulative read size (%)] | [# write RPCs] [relative write size (%)] [cumulative write size (%)]
// [0] [1] [2] [3] [4] [5] [6] [7]
size, readRPCs, writeRPCs := fields[0], fields[1], fields[5]
size = strings.Replace(size, ":", "", -1)
metricList = append(metricList, lustreBRWMetric{size: size, operation: "read", value: readRPCs})
metricList = append(metricList, lustreBRWMetric{size: size, operation: "write", value: writeRPCs})
if len(fields) >= 6 {
size, readRPCs, writeRPCs := fields[0], fields[1], fields[5]
size = strings.Replace(size, ":", "", -1)
metricList = append(metricList, lustreBRWMetric{size: size, operation: "read", value: readRPCs})
metricList = append(metricList, lustreBRWMetric{size: size, operation: "write", value: writeRPCs})
} else if len(fields) >= 1 {
size, rpcs := fields[0], fields[1]
size = strings.Replace(size, ":", "", -1)
metricList = append(metricList, lustreBRWMetric{size: size, operation: "read", value: rpcs})
} else {
continue
}
}
}
return metricList, nil
Expand Down Expand Up @@ -617,6 +638,9 @@ func (s *lustreProcfsSource) parseBRWStats(nodeType string, metricType string, p
diskIOsInFlightHelp: "disk I/Os in flight",
ioTimeHelp: "I/O time",
diskIOSizeHelp: "disk I/O size",
pagesPerRPCHelp: "pages per rpc",
rpcsInFlightHelp: "rpcs in flight",
offsetHelp: "offset",
}
statsFileBytes, err := ioutil.ReadFile(path)
if err != nil {
Expand Down

0 comments on commit 9c8dd0a

Please sign in to comment.