From fae3d95b59f770762c8d5aef9b9990dba134b9a8 Mon Sep 17 00:00:00 2001 From: Robert Clark Date: Mon, 5 Jun 2017 14:20:34 -0500 Subject: [PATCH] Add RPC stats for the client Signed-Off-By: Robert Clark --- sources/procfs.go | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/sources/procfs.go b/sources/procfs.go index 56b800bb..846ddb2f 100644 --- a/sources/procfs.go +++ b/sources/procfs.go @@ -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" @@ -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, false}, + }, + "osc/*": { + {"rpc_stats", "pages_per_rpc", pagesPerRPCHelp, s.counterMetric, false}, + {"rpc_stats", "osc_rpcs_in_flight", rpcsInFlightHelp, s.gaugeMetric, false}, + {"rpc_stats", "rpcs_offset", offsetHelp, s.counterMetric, false}, + }, } for path := range metricMap { for _, item := range metricMap[path] { @@ -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 { @@ -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 @@ -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 {