diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d7c2d25..8a686112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * [CHANGE] * [FEATURE] * [ENHANCEMENT] Add model_name and stepping to node_cpu_info metric #1617 +* [ENHANCEMENT] Add metrics for IO errors and retires on Darwin. #1636 * [BUGFIX] ## 1.0.0-rc.0 / 2020-02-20 diff --git a/collector/diskstats_darwin.go b/collector/diskstats_darwin.go index 8b118128..89622a3c 100644 --- a/collector/diskstats_darwin.go +++ b/collector/diskstats_darwin.go @@ -125,6 +125,62 @@ func NewDiskstatsCollector(logger log.Logger) (Collector, error) { return float64(stat.BytesWritten) }, }, + { + typedDesc: typedDesc{ + desc: prometheus.NewDesc( + prometheus.BuildFQName(namespace, diskSubsystem, "read_errors_total"), + "The total number of read errors.", + diskLabelNames, + nil, + ), + valueType: prometheus.CounterValue, + }, + value: func(stat *iostat.DriveStats) float64 { + return float64(stat.ReadErrors) + }, + }, + { + typedDesc: typedDesc{ + desc: prometheus.NewDesc( + prometheus.BuildFQName(namespace, diskSubsystem, "write_errors_total"), + "The total number of write errors.", + diskLabelNames, + nil, + ), + valueType: prometheus.CounterValue, + }, + value: func(stat *iostat.DriveStats) float64 { + return float64(stat.WriteErrors) + }, + }, + { + typedDesc: typedDesc{ + desc: prometheus.NewDesc( + prometheus.BuildFQName(namespace, diskSubsystem, "read_retries_total"), + "The total number of read retries.", + diskLabelNames, + nil, + ), + valueType: prometheus.CounterValue, + }, + value: func(stat *iostat.DriveStats) float64 { + return float64(stat.ReadRetries) + }, + }, + { + typedDesc: typedDesc{ + desc: prometheus.NewDesc( + prometheus.BuildFQName(namespace, diskSubsystem, "write_retries_total"), + "The total number of write retries.", + diskLabelNames, + nil, + ), + valueType: prometheus.CounterValue, + }, + value: func(stat *iostat.DriveStats) float64 { + return float64(stat.WriteRetries) + }, + }, }, logger: logger, }, nil diff --git a/go.mod b/go.mod index f67a6b29..c84801a8 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968 github.com/golang/protobuf v1.3.3 // indirect github.com/hodgesds/perf-utils v0.0.8 - github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3 + github.com/lufia/iostat v1.1.0 github.com/mattn/go-xmlrpc v0.0.3 github.com/mdlayher/genetlink v1.0.0 // indirect github.com/mdlayher/netlink v1.1.0 // indirect diff --git a/go.sum b/go.sum index b5b43a00..1b43a8bb 100644 --- a/go.sum +++ b/go.sum @@ -174,8 +174,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3 h1:XGhvld9vIpj929Gri5ybjukYZeyZwKkFkqgATqBQiOs= -github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3/go.mod h1:lRgtFVamD7L7GaXOSwBiuXMwU3Aicfn5h66LVs4u2SA= +github.com/lufia/iostat v1.1.0 h1:Z1wa4Hhxwi8uSKfgRsFc5RLtt3SuFPIOgkiPGkUtHDY= +github.com/lufia/iostat v1.1.0/go.mod h1:rEPNA0xXgjHQjuI5Cy05sLlS2oRcSlWHRLrvh/AQ+Pg= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= diff --git a/vendor/github.com/lufia/iostat/go.mod b/vendor/github.com/lufia/iostat/go.mod new file mode 100644 index 00000000..35d0e847 --- /dev/null +++ b/vendor/github.com/lufia/iostat/go.mod @@ -0,0 +1,3 @@ +module github.com/lufia/iostat + +go 1.14 diff --git a/vendor/github.com/lufia/iostat/iostat.go b/vendor/github.com/lufia/iostat/iostat.go index ada2dadc..794b51e4 100644 --- a/vendor/github.com/lufia/iostat/iostat.go +++ b/vendor/github.com/lufia/iostat/iostat.go @@ -17,6 +17,10 @@ type DriveStats struct { TotalWriteTime time.Duration ReadLatency time.Duration WriteLatency time.Duration + ReadErrors int64 + WriteErrors int64 + ReadRetries int64 + WriteRetries int64 } // CPUStats represents CPU statistics. diff --git a/vendor/github.com/lufia/iostat/iostat_darwin.c b/vendor/github.com/lufia/iostat/iostat_darwin.c index 4f696c9c..dfe77a88 100644 --- a/vendor/github.com/lufia/iostat/iostat_darwin.c +++ b/vendor/github.com/lufia/iostat/iostat_darwin.c @@ -95,6 +95,10 @@ static struct { {kIOBlockStorageDriverStatisticsTotalWriteTimeKey, offsetof(DriveStats, writetime)}, {kIOBlockStorageDriverStatisticsLatentReadTimeKey, offsetof(DriveStats, readlat)}, {kIOBlockStorageDriverStatisticsLatentWriteTimeKey, offsetof(DriveStats, writelat)}, + {kIOBlockStorageDriverStatisticsReadErrorsKey, offsetof(DriveStats, readerrs)}, + {kIOBlockStorageDriverStatisticsWriteErrorsKey, offsetof(DriveStats, writeerrs)}, + {kIOBlockStorageDriverStatisticsReadRetriesKey, offsetof(DriveStats, readretries)}, + {kIOBlockStorageDriverStatisticsWriteRetriesKey, offsetof(DriveStats, writeretries)}, }; static int diff --git a/vendor/github.com/lufia/iostat/iostat_darwin.go b/vendor/github.com/lufia/iostat/iostat_darwin.go index 16e2cfd6..93f93348 100644 --- a/vendor/github.com/lufia/iostat/iostat_darwin.go +++ b/vendor/github.com/lufia/iostat/iostat_darwin.go @@ -32,6 +32,10 @@ func ReadDriveStats() ([]*DriveStats, error) { TotalWriteTime: time.Duration(buf[i].writetime), ReadLatency: time.Duration(buf[i].readlat), WriteLatency: time.Duration(buf[i].writelat), + ReadErrors: int64(buf[i].readerrs), + WriteErrors: int64(buf[i].writeerrs), + ReadRetries: int64(buf[i].readretries), + WriteRetries: int64(buf[i].writeretries), } } return stats, nil diff --git a/vendor/github.com/lufia/iostat/iostat_darwin.h b/vendor/github.com/lufia/iostat/iostat_darwin.h index f559db80..baece0a7 100644 --- a/vendor/github.com/lufia/iostat/iostat_darwin.h +++ b/vendor/github.com/lufia/iostat/iostat_darwin.h @@ -19,6 +19,10 @@ struct DriveStats { int64_t writetime; int64_t readlat; int64_t writelat; + int64_t readerrs; + int64_t writeerrs; + int64_t readretries; + int64_t writeretries; }; struct CPUStats { diff --git a/vendor/modules.txt b/vendor/modules.txt index 033b85a3..546605c7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -30,7 +30,7 @@ github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/timestamp # github.com/hodgesds/perf-utils v0.0.8 github.com/hodgesds/perf-utils -# github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3 +# github.com/lufia/iostat v1.1.0 github.com/lufia/iostat # github.com/mattn/go-xmlrpc v0.0.3 github.com/mattn/go-xmlrpc