|
|
@ -1,4 +1,4 @@
|
|
|
|
// +build !nodiskstats
|
|
|
|
// +build !nodevstat
|
|
|
|
|
|
|
|
|
|
|
|
package collector
|
|
|
|
package collector
|
|
|
|
|
|
|
|
|
|
|
@ -124,66 +124,64 @@ const (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type devstatCollector struct {
|
|
|
|
type devstatCollector struct {
|
|
|
|
bytes *prometheus.GaugeVec
|
|
|
|
bytes *prometheus.CounterVec
|
|
|
|
transfers *prometheus.GaugeVec
|
|
|
|
bytes_total *prometheus.CounterVec
|
|
|
|
duration *prometheus.GaugeVec
|
|
|
|
transfers *prometheus.CounterVec
|
|
|
|
busyTime *prometheus.GaugeVec
|
|
|
|
duration *prometheus.CounterVec
|
|
|
|
blocks *prometheus.GaugeVec
|
|
|
|
busyTime *prometheus.CounterVec
|
|
|
|
|
|
|
|
blocks *prometheus.CounterVec
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
func init() {
|
|
|
|
Factories["devstat"] = NewDevstatCollector
|
|
|
|
Factories["devstat"] = NewDevstatCollector
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// device stats.
|
|
|
|
// Takes a prometheus registry and returns a new Collector exposing
|
|
|
|
|
|
|
|
// Device stats.
|
|
|
|
func NewDevstatCollector() (Collector, error) {
|
|
|
|
func NewDevstatCollector() (Collector, error) {
|
|
|
|
//var diskLabelNames = []string{"device"}
|
|
|
|
|
|
|
|
//var ioType = []string{"type"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return &devstatCollector{
|
|
|
|
return &devstatCollector{
|
|
|
|
// Docs from https://www.kernel.org/doc/Documentation/iostats.txt
|
|
|
|
bytes: prometheus.NewCounterVec(
|
|
|
|
bytes: prometheus.NewGaugeVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
|
|
|
|
Namespace: Namespace,
|
|
|
|
Namespace: Namespace,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Name: "bytes",
|
|
|
|
Name: "bytes_total",
|
|
|
|
Help: "The total number of bytes transferred",
|
|
|
|
Help: "The total number of bytes in transactions.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]string{"device", "type"},
|
|
|
|
[]string{"device", "type"},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
transfers: prometheus.NewGaugeVec(
|
|
|
|
transfers: prometheus.NewCounterVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
|
|
|
Namespace: Namespace,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Name: "transfers",
|
|
|
|
Name: "transfers_total",
|
|
|
|
Help: "The total number of transactions",
|
|
|
|
Help: "The total number of transactions.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]string{"device", "type"},
|
|
|
|
[]string{"device", "type"},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
duration: prometheus.NewGaugeVec(
|
|
|
|
duration: prometheus.NewCounterVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
|
|
|
Namespace: Namespace,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Name: "duration",
|
|
|
|
Name: "duration_seconds_total",
|
|
|
|
Help: "The total duration of transactions",
|
|
|
|
Help: "The total duration of transactions in seconds.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]string{"device", "type"},
|
|
|
|
[]string{"device", "type"},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
busyTime: prometheus.NewGaugeVec(
|
|
|
|
busyTime: prometheus.NewCounterVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
|
|
|
Namespace: Namespace,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Name: "busy_time",
|
|
|
|
Name: "busy_time_seconds_total",
|
|
|
|
Help: "Total time the device had one or more transactions outstanding",
|
|
|
|
Help: "Total time the device had one or more transactions outstanding in seconds.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]string{"device"},
|
|
|
|
[]string{"device"},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
blocks: prometheus.NewGaugeVec(
|
|
|
|
blocks: prometheus.NewCounterVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: Namespace,
|
|
|
|
Namespace: Namespace,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Subsystem: devstatSubsystem,
|
|
|
|
Name: "blocks",
|
|
|
|
Name: "blocks_transferred_total",
|
|
|
|
Help: "The total number of blocks transferred",
|
|
|
|
Help: "The total number of blocks transferred.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]string{"device"},
|
|
|
|
[]string{"device"},
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -191,18 +189,6 @@ func NewDevstatCollector() (Collector, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *devstatCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
|
|
|
func (c *devstatCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
|
|
|
/*
|
|
|
|
|
|
|
|
var busyTime [3]C.longlong
|
|
|
|
|
|
|
|
var blocks [3]C.uint64_t
|
|
|
|
|
|
|
|
var kbPerTransfer [3]C.longlong
|
|
|
|
|
|
|
|
var transfersPerSecond [3]C.longlong
|
|
|
|
|
|
|
|
var mbPerSecond [3]C.longlong
|
|
|
|
|
|
|
|
var blocksPerSecond [3]C.longlong
|
|
|
|
|
|
|
|
var msPerTransaction [3]C.longlong
|
|
|
|
|
|
|
|
var busyPCT C.longlong
|
|
|
|
|
|
|
|
var queueLength C.uint64_t
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
count := C._get_ndevs()
|
|
|
|
count := C._get_ndevs()
|
|
|
|
if count == -1 {
|
|
|
|
if count == -1 {
|
|
|
|
return errors.New("devstat_getdevs() failed!")
|
|
|
|
return errors.New("devstat_getdevs() failed!")
|
|
|
@ -214,17 +200,18 @@ func (c *devstatCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
|
|
|
for i := C.int(0); i < count; i++ {
|
|
|
|
for i := C.int(0); i < count; i++ {
|
|
|
|
stats := C._get_stats(i)
|
|
|
|
stats := C._get_stats(i)
|
|
|
|
device := fmt.Sprintf("%s%d", C.GoString(&stats.device[0]), stats.unit)
|
|
|
|
device := fmt.Sprintf("%s%d", C.GoString(&stats.device[0]), stats.unit)
|
|
|
|
|
|
|
|
// Free metrics are disabled for now, please see PR #88 for more details.
|
|
|
|
c.bytes.With(prometheus.Labels{"device": device, "type": "read"}).Set(float64(stats.bytes.read))
|
|
|
|
c.bytes.With(prometheus.Labels{"device": device, "type": "read"}).Set(float64(stats.bytes.read))
|
|
|
|
c.bytes.With(prometheus.Labels{"device": device, "type": "write"}).Set(float64(stats.bytes.write))
|
|
|
|
c.bytes.With(prometheus.Labels{"device": device, "type": "write"}).Set(float64(stats.bytes.write))
|
|
|
|
c.bytes.With(prometheus.Labels{"device": device, "type": "free"}).Set(float64(stats.bytes.free))
|
|
|
|
//c.bytes.With(prometheus.Labels{"device": device, "type": "free"}).Set(float64(stats.bytes.free))
|
|
|
|
c.transfers.With(prometheus.Labels{"device": device, "type": "other"}).Set(float64(stats.transfers.other))
|
|
|
|
c.transfers.With(prometheus.Labels{"device": device, "type": "other"}).Set(float64(stats.transfers.other))
|
|
|
|
c.transfers.With(prometheus.Labels{"device": device, "type": "read"}).Set(float64(stats.transfers.read))
|
|
|
|
c.transfers.With(prometheus.Labels{"device": device, "type": "read"}).Set(float64(stats.transfers.read))
|
|
|
|
c.transfers.With(prometheus.Labels{"device": device, "type": "write"}).Set(float64(stats.transfers.write))
|
|
|
|
c.transfers.With(prometheus.Labels{"device": device, "type": "write"}).Set(float64(stats.transfers.write))
|
|
|
|
c.transfers.With(prometheus.Labels{"device": device, "type": "free"}).Set(float64(stats.transfers.free))
|
|
|
|
//c.transfers.With(prometheus.Labels{"device": device, "type": "free"}).Set(float64(stats.transfers.free))
|
|
|
|
c.duration.With(prometheus.Labels{"device": device, "type": "other"}).Set(float64(stats.duration.other))
|
|
|
|
c.duration.With(prometheus.Labels{"device": device, "type": "other"}).Set(float64(stats.duration.other))
|
|
|
|
c.duration.With(prometheus.Labels{"device": device, "type": "read"}).Set(float64(stats.duration.read))
|
|
|
|
c.duration.With(prometheus.Labels{"device": device, "type": "read"}).Set(float64(stats.duration.read))
|
|
|
|
c.duration.With(prometheus.Labels{"device": device, "type": "write"}).Set(float64(stats.duration.write))
|
|
|
|
c.duration.With(prometheus.Labels{"device": device, "type": "write"}).Set(float64(stats.duration.write))
|
|
|
|
c.duration.With(prometheus.Labels{"device": device, "type": "free"}).Set(float64(stats.duration.free))
|
|
|
|
//c.duration.With(prometheus.Labels{"device": device, "type": "free"}).Set(float64(stats.duration.free))
|
|
|
|
c.busyTime.With(prometheus.Labels{"device": device}).Set(float64(stats.busyTime))
|
|
|
|
c.busyTime.With(prometheus.Labels{"device": device}).Set(float64(stats.busyTime))
|
|
|
|
c.blocks.With(prometheus.Labels{"device": device}).Set(float64(stats.blocks))
|
|
|
|
c.blocks.With(prometheus.Labels{"device": device}).Set(float64(stats.blocks))
|
|
|
|
}
|
|
|
|
}
|
|
|
|