@ -22,6 +22,7 @@ import (
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs"
"gopkg.in/alecthomas/kingpin.v2"
)
type statCollector struct {
@ -32,9 +33,12 @@ type statCollector struct {
btime * prometheus . Desc
procsRunning * prometheus . Desc
procsBlocked * prometheus . Desc
softIRQ * prometheus . Desc
logger log . Logger
}
var statSoftirqFlag = kingpin . Flag ( "collector.stat.softirq" , "Export softirq calls per vector" ) . Default ( "false" ) . Bool ( )
func init ( ) {
registerCollector ( "stat" , defaultEnabled , NewStatCollector )
}
@ -77,6 +81,11 @@ func NewStatCollector(logger log.Logger) (Collector, error) {
"Number of processes blocked waiting for I/O to complete." ,
nil , nil ,
) ,
softIRQ : prometheus . NewDesc (
prometheus . BuildFQName ( namespace , "" , "softirqs_total" ) ,
"Number of softirq calls." ,
[ ] string { "vector" } , nil ,
) ,
logger : logger ,
} , nil
}
@ -97,5 +106,27 @@ func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
ch <- prometheus . MustNewConstMetric ( c . procsRunning , prometheus . GaugeValue , float64 ( stats . ProcessesRunning ) )
ch <- prometheus . MustNewConstMetric ( c . procsBlocked , prometheus . GaugeValue , float64 ( stats . ProcessesBlocked ) )
if * statSoftirqFlag {
si := stats . SoftIRQ
for _ , vec := range [ ] struct {
name string
value uint64
} {
{ name : "hi" , value : si . Hi } ,
{ name : "timer" , value : si . Timer } ,
{ name : "net_tx" , value : si . NetTx } ,
{ name : "net_rx" , value : si . NetRx } ,
{ name : "block" , value : si . Block } ,
{ name : "block_iopoll" , value : si . BlockIoPoll } ,
{ name : "tasklet" , value : si . Tasklet } ,
{ name : "sched" , value : si . Sched } ,
{ name : "hrtimer" , value : si . Hrtimer } ,
{ name : "rcu" , value : si . Rcu } ,
} {
ch <- prometheus . MustNewConstMetric ( c . softIRQ , prometheus . CounterValue , float64 ( vec . value ) , vec . name )
}
}
return nil
}