@ -31,7 +31,7 @@ type drbdNumericalMetric struct {
multiplier float64
multiplier float64
}
}
func newDrbd NumericalMetric ( name string , desc string , valueType prometheus . ValueType , multiplier float64 ) drbdNumericalMetric {
func newDRBD NumericalMetric ( name string , desc string , valueType prometheus . ValueType , multiplier float64 ) drbdNumericalMetric {
return drbdNumericalMetric {
return drbdNumericalMetric {
desc : prometheus . NewDesc (
desc : prometheus . NewDesc (
prometheus . BuildFQName ( Namespace , "drbd" , name ) ,
prometheus . BuildFQName ( Namespace , "drbd" , name ) ,
@ -55,7 +55,7 @@ func (metric *drbdStringPairMetric) isOkay(value string) float64 {
return 0
return 0
}
}
func newDrbd StringPairMetric ( name string , desc string , valueOkay string ) drbdStringPairMetric {
func newDRBD StringPairMetric ( name string , desc string , valueOkay string ) drbdStringPairMetric {
return drbdStringPairMetric {
return drbdStringPairMetric {
desc : prometheus . NewDesc (
desc : prometheus . NewDesc (
prometheus . BuildFQName ( Namespace , "drbd" , name ) ,
prometheus . BuildFQName ( Namespace , "drbd" , name ) ,
@ -67,73 +67,73 @@ func newDrbdStringPairMetric(name string, desc string, valueOkay string) drbdStr
var (
var (
drbdNumericalMetrics = map [ string ] drbdNumericalMetric {
drbdNumericalMetrics = map [ string ] drbdNumericalMetric {
"ns" : newDrbd NumericalMetric (
"ns" : newDRBD NumericalMetric (
"network_sent_bytes" ,
"network_sent_bytes_total " ,
"Volume of net data sent to the partner via the network connection." ,
"Volume of net data sent to the partner via the network connection; in bytes ." ,
prometheus . CounterValue ,
prometheus . CounterValue ,
1024 ) ,
1024 ) ,
"nr" : newDrbd NumericalMetric (
"nr" : newDRBD NumericalMetric (
"network_received_bytes" ,
"network_received_bytes_total " ,
"Volume of net data received by the partner via the network connection." ,
"Volume of net data received by the partner via the network connection; in bytes ." ,
prometheus . CounterValue ,
prometheus . CounterValue ,
1 ) ,
1 ) ,
"dw" : newDrbd NumericalMetric (
"dw" : newDRBD NumericalMetric (
"disk_written_bytes" ,
"disk_written_bytes_total " ,
"Net data written on local hard disk." ,
"Net data written on local hard disk; in bytes ." ,
prometheus . CounterValue ,
prometheus . CounterValue ,
1024 ) ,
1024 ) ,
"dr" : newDrbd NumericalMetric (
"dr" : newDRBD NumericalMetric (
"disk_read_bytes" ,
"disk_read_bytes_total " ,
"Net data read from local hard disk." ,
"Net data read from local hard disk; in bytes ." ,
prometheus . CounterValue ,
prometheus . CounterValue ,
1024 ) ,
1024 ) ,
"al" : newDrbd NumericalMetric (
"al" : newDRBD NumericalMetric (
"activitylog_writes" ,
"activitylog_writes_total " ,
"Number of updates of the activity log area of the meta data." ,
"Number of updates of the activity log area of the meta data." ,
prometheus . CounterValue ,
prometheus . CounterValue ,
1 ) ,
1 ) ,
"bm" : newDrbd NumericalMetric (
"bm" : newDRBD NumericalMetric (
"bitmap_writes" ,
"bitmap_writes_total " ,
"Number of updates of the bitmap area of the meta data." ,
"Number of updates of the bitmap area of the meta data." ,
prometheus . CounterValue ,
prometheus . CounterValue ,
1 ) ,
1 ) ,
"lo" : newDrbd NumericalMetric (
"lo" : newDRBD NumericalMetric (
"local_pending" ,
"local_pending" ,
"Number of open requests to the local I/O sub-system." ,
"Number of open requests to the local I/O sub-system." ,
prometheus . GaugeValue ,
prometheus . GaugeValue ,
1 ) ,
1 ) ,
"pe" : newDrbd NumericalMetric (
"pe" : newDRBD NumericalMetric (
"remote_pending" ,
"remote_pending" ,
"Number of requests sent to the partner, but that have not yet been answered by the latter." ,
"Number of requests sent to the partner, but that have not yet been answered by the latter." ,
prometheus . GaugeValue ,
prometheus . GaugeValue ,
1 ) ,
1 ) ,
"ua" : newDrbd NumericalMetric (
"ua" : newDRBD NumericalMetric (
"remote_unacknowledged" ,
"remote_unacknowledged" ,
"Number of requests received by the partner via the network connection, but that have not yet been answered." ,
"Number of requests received by the partner via the network connection, but that have not yet been answered." ,
prometheus . GaugeValue ,
prometheus . GaugeValue ,
1 ) ,
1 ) ,
"ap" : newDrbd NumericalMetric (
"ap" : newDRBD NumericalMetric (
"application_pending" ,
"application_pending" ,
"Number of block I/O requests forwarded to DRBD, but not yet answered by DRBD." ,
"Number of block I/O requests forwarded to DRBD, but not yet answered by DRBD." ,
prometheus . GaugeValue ,
prometheus . GaugeValue ,
1 ) ,
1 ) ,
"ep" : newDrbd NumericalMetric (
"ep" : newDRBD NumericalMetric (
"epochs" ,
"epochs" ,
"Number of Epochs currently on the fly." ,
"Number of Epochs currently on the fly." ,
prometheus . GaugeValue ,
prometheus . GaugeValue ,
1 ) ,
1 ) ,
"oos" : newDrbd NumericalMetric (
"oos" : newDRBD NumericalMetric (
"out_of_sync_bytes" ,
"out_of_sync_bytes" ,
"Amount of data known to be out of sync." ,
"Amount of data known to be out of sync; in bytes ." ,
prometheus . GaugeValue ,
prometheus . GaugeValue ,
1024 ) ,
1024 ) ,
}
}
drbdStringPairMetrics = map [ string ] drbdStringPairMetric {
drbdStringPairMetrics = map [ string ] drbdStringPairMetric {
"ro" : newDrbd StringPairMetric (
"ro" : newDRBD StringPairMetric (
"node_role_is_primary" ,
"node_role_is_primary" ,
"Whether the role of the node is in the primary state." ,
"Whether the role of the node is in the primary state." ,
"Primary" ) ,
"Primary" ) ,
"ds" : newDrbd StringPairMetric (
"ds" : newDRBD StringPairMetric (
"disk_state_is_up_to_date" ,
"disk_state_is_up_to_date" ,
"Whether the disk of the node is up to date." ,
"Whether the disk of the node is up to date." ,
"UpToDate" ) ,
"UpToDate" ) ,
@ -148,10 +148,10 @@ var (
type drbdCollector struct { }
type drbdCollector struct { }
func init ( ) {
func init ( ) {
Factories [ "drbd" ] = NewDrbd Collector
Factories [ "drbd" ] = newDRBD Collector
}
}
func NewDrbd Collector( ) ( Collector , error ) {
func newDRBD Collector( ) ( Collector , error ) {
return & drbdCollector { } , nil
return & drbdCollector { } , nil
}
}
@ -160,7 +160,7 @@ func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) {
file , err := os . Open ( statsFile )
file , err := os . Open ( statsFile )
if err != nil {
if err != nil {
if os . IsNotExist ( err ) {
if os . IsNotExist ( err ) {
log . Debugf ( "Not collecting DRBD statistics, as %s does not exist: %s" , statsFile )
log . Debugf ( "Not collecting DRBD statistics, as %s does not exist: %s" , statsFile , err )
return nil
return nil
}
}
return err
return err
@ -195,7 +195,7 @@ func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) {
metric . isOkay ( values [ 1 ] ) , device , "remote" )
metric . isOkay ( values [ 1 ] ) , device , "remote" )
} else if kv [ 0 ] == "cs" {
} else if kv [ 0 ] == "cs" {
// Connection state.
// Connection state.
var connected float64 = 0
var connected float64
if kv [ 1 ] == "Connected" {
if kv [ 1 ] == "Connected" {
connected = 1
connected = 1
}
}
@ -203,10 +203,10 @@ func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) {
drbdConnected , prometheus . GaugeValue ,
drbdConnected , prometheus . GaugeValue ,
connected , device )
connected , device )
} else {
} else {
log . Infof ( "Don't know how to process key-value pair [%s: %s ]" , kv [ 0 ] , kv [ 1 ] )
log . Infof ( "Don't know how to process key-value pair [%s: %q ]" , kv [ 0 ] , kv [ 1 ] )
}
}
} else {
} else {
log . Infof ( "Don't know how to process string %s " , field )
log . Infof ( "Don't know how to process string %q " , field )
}
}
}
}
return scanner . Err ( )
return scanner . Err ( )