mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-09 23:24:09 -08:00
Replace --collectors.enabled with per-collector flags (#640)
* Move NodeCollector into package collector * Refactor collector enabling * Update README with new collector enabled flags * Fix out-of-date inline flag reference syntax * Use new flags in end-to-end tests * Add flag to disable all default collectors * Track if a flag has been set explicitly * Add --collectors.disable-defaults to README * Revert disable-defaults flag * Shorten flags * Fixup timex collector registration * Fix end-to-end tests * Change procfs and sysfs path flags * Fix review comments
This commit is contained in:
parent
3762191e66
commit
859a825bb8
|
@ -16,7 +16,8 @@ The [WMI exporter](https://github.com/martinlindhe/wmi_exporter) is recommended
|
|||
There is varying support for collectors on each operating system. The tables
|
||||
below list all existing collectors and the supported systems.
|
||||
|
||||
Which collectors are used is controlled by the `--collectors.enabled` flag.
|
||||
Collectors are enabled by providing a `--collector.<name>` flag.
|
||||
Collectors that are enabled by default can be disabled by providing a `--no-collector.<name>` flag.
|
||||
|
||||
### Enabled by default
|
||||
|
||||
|
@ -137,8 +138,8 @@ docker run -d -p 9100:9100 \
|
|||
-v "/:/rootfs:ro" \
|
||||
--net="host" \
|
||||
quay.io/prometheus/node-exporter \
|
||||
--collector.procfs /host/proc \
|
||||
--collector.sysfs /host/sys \
|
||||
--path.procfs /host/proc \
|
||||
--path.sysfs /host/sys \
|
||||
--collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
|
||||
```
|
||||
|
||||
|
|
|
@ -30,14 +30,14 @@ type arpCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["arp"] = NewARPCollector
|
||||
registerCollector("arp", defaultEnabled, NewARPCollector)
|
||||
}
|
||||
|
||||
// NewARPCollector returns a new Collector exposing ARP stats.
|
||||
func NewARPCollector() (Collector, error) {
|
||||
return &arpCollector{
|
||||
entries: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "arp", "entries"),
|
||||
prometheus.BuildFQName(namespace, "arp", "entries"),
|
||||
"ARP entries by device",
|
||||
[]string{"device"}, nil,
|
||||
),
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
Factories["bcache"] = NewBcacheCollector
|
||||
registerCollector("bcache", defaultEnabled, NewBcacheCollector)
|
||||
}
|
||||
|
||||
// A bcacheCollector is a Collector which gathers metrics from Linux bcache.
|
||||
|
@ -283,7 +283,7 @@ func (c *bcacheCollector) updateBcacheStats(ch chan<- prometheus.Metric, s *bcac
|
|||
labels := append(devLabel, m.extraLabel...)
|
||||
|
||||
desc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, m.name),
|
||||
prometheus.BuildFQName(namespace, subsystem, m.name),
|
||||
m.desc,
|
||||
labels,
|
||||
nil,
|
||||
|
|
|
@ -31,7 +31,7 @@ type bondingCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["bonding"] = NewBondingCollector
|
||||
registerCollector("bonding", defaultDisabled, NewBondingCollector)
|
||||
}
|
||||
|
||||
// NewBondingCollector returns a newly allocated bondingCollector.
|
||||
|
@ -39,12 +39,12 @@ func init() {
|
|||
func NewBondingCollector() (Collector, error) {
|
||||
return &bondingCollector{
|
||||
slaves: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "bonding", "slaves"),
|
||||
prometheus.BuildFQName(namespace, "bonding", "slaves"),
|
||||
"Number of configured slaves per bonding interface.",
|
||||
[]string{"master"}, nil,
|
||||
), prometheus.GaugeValue},
|
||||
active: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "bonding", "active"),
|
||||
prometheus.BuildFQName(namespace, "bonding", "active"),
|
||||
"Number of active slaves per bonding interface.",
|
||||
[]string{"master"}, nil,
|
||||
), prometheus.GaugeValue},
|
||||
|
|
|
@ -34,13 +34,13 @@ type buddyinfoCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["buddyinfo"] = NewBuddyinfoCollector
|
||||
registerCollector("buddyinfo", defaultDisabled, NewBuddyinfoCollector)
|
||||
}
|
||||
|
||||
// NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats.
|
||||
func NewBuddyinfoCollector() (Collector, error) {
|
||||
desc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, buddyInfoSubsystem, "count"),
|
||||
prometheus.BuildFQName(namespace, buddyInfoSubsystem, "count"),
|
||||
"Count of free blocks according to size.",
|
||||
[]string{"node", "zone", "size"}, nil,
|
||||
)
|
||||
|
|
|
@ -15,20 +15,121 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/common/log"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
// Namespace defines the common namespace to be used by all metrics.
|
||||
const Namespace = "node"
|
||||
const namespace = "node"
|
||||
|
||||
// Factories contains the list of all available collectors.
|
||||
var Factories = make(map[string]func() (Collector, error))
|
||||
var (
|
||||
scrapeDurationDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "scrape", "collector_duration_seconds"),
|
||||
"node_exporter: Duration of a collector scrape.",
|
||||
[]string{"collector"},
|
||||
nil,
|
||||
)
|
||||
scrapeSuccessDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "scrape", "collector_success"),
|
||||
"node_exporter: Whether a collector succeeded.",
|
||||
[]string{"collector"},
|
||||
nil,
|
||||
)
|
||||
)
|
||||
|
||||
func warnDeprecated(collector string) {
|
||||
log.Warnf("The %s collector is deprecated and will be removed in the future!", collector)
|
||||
}
|
||||
|
||||
const (
|
||||
defaultEnabled = true
|
||||
defaultDisabled = false
|
||||
)
|
||||
|
||||
var (
|
||||
factories = make(map[string]func() (Collector, error))
|
||||
collectorState = make(map[string]*bool)
|
||||
)
|
||||
|
||||
func registerCollector(collector string, isDefaultEnabled bool, factory func() (Collector, error)) {
|
||||
var helpDefaultState string
|
||||
if isDefaultEnabled {
|
||||
helpDefaultState = "enabled"
|
||||
} else {
|
||||
helpDefaultState = "disabled"
|
||||
}
|
||||
|
||||
flagName := fmt.Sprintf("collector.%s", collector)
|
||||
flagHelp := fmt.Sprintf("Enable the %s collector (default: %s).", collector, helpDefaultState)
|
||||
defaultValue := fmt.Sprintf("%v", isDefaultEnabled)
|
||||
|
||||
flag := kingpin.Flag(flagName, flagHelp).Default(defaultValue).Bool()
|
||||
collectorState[collector] = flag
|
||||
|
||||
factories[collector] = factory
|
||||
}
|
||||
|
||||
// NodeCollector implements the prometheus.Collector interface.
|
||||
type nodeCollector struct {
|
||||
Collectors map[string]Collector
|
||||
}
|
||||
|
||||
// NewNodeCollector creates a new NodeCollector
|
||||
func NewNodeCollector() (*nodeCollector, error) {
|
||||
collectors := make(map[string]Collector)
|
||||
for key, enabled := range collectorState {
|
||||
if *enabled {
|
||||
collector, err := factories[key]()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
collectors[key] = collector
|
||||
}
|
||||
}
|
||||
return &nodeCollector{Collectors: collectors}, nil
|
||||
}
|
||||
|
||||
// Describe implements the prometheus.Collector interface.
|
||||
func (n nodeCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||
ch <- scrapeDurationDesc
|
||||
ch <- scrapeSuccessDesc
|
||||
}
|
||||
|
||||
// Collect implements the prometheus.Collector interface.
|
||||
func (n nodeCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(n.Collectors))
|
||||
for name, c := range n.Collectors {
|
||||
go func(name string, c Collector) {
|
||||
execute(name, c, ch)
|
||||
wg.Done()
|
||||
}(name, c)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func execute(name string, c Collector, ch chan<- prometheus.Metric) {
|
||||
begin := time.Now()
|
||||
err := c.Update(ch)
|
||||
duration := time.Since(begin)
|
||||
var success float64
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("ERROR: %s collector failed after %fs: %s", name, duration.Seconds(), err)
|
||||
success = 0
|
||||
} else {
|
||||
log.Debugf("OK: %s collector succeeded after %fs.", name, duration.Seconds())
|
||||
success = 1
|
||||
}
|
||||
ch <- prometheus.MustNewConstMetric(scrapeDurationDesc, prometheus.GaugeValue, duration.Seconds(), name)
|
||||
ch <- prometheus.MustNewConstMetric(scrapeSuccessDesc, prometheus.GaugeValue, success, name)
|
||||
}
|
||||
|
||||
// Collector is the interface a collector has to implement.
|
||||
type Collector interface {
|
||||
// Get new metrics and expose them via prometheus registry.
|
||||
|
|
|
@ -25,19 +25,19 @@ type conntrackCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["conntrack"] = NewConntrackCollector
|
||||
registerCollector("conntrack", defaultEnabled, NewConntrackCollector)
|
||||
}
|
||||
|
||||
// NewConntrackCollector returns a new Collector exposing conntrack stats.
|
||||
func NewConntrackCollector() (Collector, error) {
|
||||
return &conntrackCollector{
|
||||
current: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "nf_conntrack_entries"),
|
||||
prometheus.BuildFQName(namespace, "", "nf_conntrack_entries"),
|
||||
"Number of currently allocated flow entries for connection tracking.",
|
||||
nil, nil,
|
||||
),
|
||||
limit: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "nf_conntrack_entries_limit"),
|
||||
prometheus.BuildFQName(namespace, "", "nf_conntrack_entries_limit"),
|
||||
"Maximum size of connection tracking table.",
|
||||
nil, nil,
|
||||
),
|
||||
|
|
|
@ -52,14 +52,14 @@ type statCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["cpu"] = NewCPUCollector
|
||||
registerCollector("cpu", defaultEnabled, NewCPUCollector)
|
||||
}
|
||||
|
||||
// NewCPUCollector returns a new Collector exposing CPU stats.
|
||||
func NewCPUCollector() (Collector, error) {
|
||||
return &statCollector{
|
||||
cpu: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "cpu"),
|
||||
prometheus.BuildFQName(namespace, "", "cpu"),
|
||||
"Seconds the cpus spent in each mode.",
|
||||
[]string{"cpu", "mode"}, nil,
|
||||
),
|
||||
|
|
|
@ -88,14 +88,14 @@ type statCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["cpu"] = NewStatCollector
|
||||
registerCollector("cpu", defaultEnabled, NewStatCollector)
|
||||
}
|
||||
|
||||
// NewStatCollector returns a new Collector exposing CPU stats.
|
||||
func NewStatCollector() (Collector, error) {
|
||||
return &statCollector{
|
||||
cpu: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "cpu"),
|
||||
prometheus.BuildFQName(namespace, "", "cpu"),
|
||||
"Seconds the cpus spent in each mode.",
|
||||
[]string{"cpu", "mode"}, nil,
|
||||
),
|
||||
|
|
|
@ -86,19 +86,19 @@ type statCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["cpu"] = NewStatCollector
|
||||
registerCollector("cpu", defaultEnabled, NewStatCollector)
|
||||
}
|
||||
|
||||
// NewStatCollector returns a new Collector exposing CPU stats.
|
||||
func NewStatCollector() (Collector, error) {
|
||||
return &statCollector{
|
||||
cpu: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "cpu", "seconds_total"),
|
||||
prometheus.BuildFQName(namespace, "cpu", "seconds_total"),
|
||||
"Seconds the CPU spent in each mode.",
|
||||
[]string{"cpu", "mode"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
temp: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "cpu", "temperature_celsius"),
|
||||
prometheus.BuildFQName(namespace, "cpu", "temperature_celsius"),
|
||||
"CPU temperature",
|
||||
[]string{"cpu"}, nil,
|
||||
), prometheus.GaugeValue},
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
cpuCollectorNamespace = "cpu"
|
||||
cpuCollectorSubsystem = "cpu"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -46,40 +46,40 @@ type cpuCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["cpu"] = NewCPUCollector
|
||||
registerCollector("cpu", defaultEnabled, NewCPUCollector)
|
||||
}
|
||||
|
||||
// NewCPUCollector returns a new Collector exposing kernel/system statistics.
|
||||
func NewCPUCollector() (Collector, error) {
|
||||
return &cpuCollector{
|
||||
cpu: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", cpuCollectorNamespace),
|
||||
prometheus.BuildFQName(namespace, "", cpuCollectorSubsystem),
|
||||
"Seconds the cpus spent in each mode.",
|
||||
[]string{"cpu", "mode"}, nil,
|
||||
),
|
||||
cpuFreq: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "frequency_hertz"),
|
||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_hertz"),
|
||||
"Current cpu thread frequency in hertz.",
|
||||
[]string{"cpu"}, nil,
|
||||
),
|
||||
cpuFreqMin: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "frequency_min_hertz"),
|
||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_min_hertz"),
|
||||
"Minimum cpu thread frequency in hertz.",
|
||||
[]string{"cpu"}, nil,
|
||||
),
|
||||
cpuFreqMax: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "frequency_max_hertz"),
|
||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_max_hertz"),
|
||||
"Maximum cpu thread frequency in hertz.",
|
||||
[]string{"cpu"}, nil,
|
||||
),
|
||||
// FIXME: This should be a per core metric, not per cpu!
|
||||
cpuCoreThrottle: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "core_throttles_total"),
|
||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "core_throttles_total"),
|
||||
"Number of times this cpu core has been throttled.",
|
||||
[]string{"cpu"}, nil,
|
||||
),
|
||||
cpuPackageThrottle: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "package_throttles_total"),
|
||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "package_throttles_total"),
|
||||
"Number of times this cpu package has been throttled.",
|
||||
[]string{"node"}, nil,
|
||||
),
|
||||
|
|
|
@ -99,24 +99,24 @@ type devstatCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["devstat"] = NewDevstatCollector
|
||||
registerCollector("devstat", defaultDisabled, NewDevstatCollector)
|
||||
}
|
||||
|
||||
// NewDevstatCollector returns a new Collector exposing Device stats.
|
||||
func NewDevstatCollector() (Collector, error) {
|
||||
return &devstatCollector{
|
||||
bytesDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, devstatSubsystem, "bytes_total"),
|
||||
prometheus.BuildFQName(namespace, devstatSubsystem, "bytes_total"),
|
||||
"The total number of bytes transferred for reads and writes on the device.",
|
||||
[]string{"device"}, nil,
|
||||
),
|
||||
transfersDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, devstatSubsystem, "transfers_total"),
|
||||
prometheus.BuildFQName(namespace, devstatSubsystem, "transfers_total"),
|
||||
"The total number of transactions completed.",
|
||||
[]string{"device"}, nil,
|
||||
),
|
||||
blocksDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, devstatSubsystem, "blocks_total"),
|
||||
prometheus.BuildFQName(namespace, devstatSubsystem, "blocks_total"),
|
||||
"The total number of bytes given in terms of the devices blocksize.",
|
||||
[]string{"device"}, nil,
|
||||
),
|
||||
|
|
|
@ -44,7 +44,7 @@ type devstatCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["devstat"] = NewDevstatCollector
|
||||
registerCollector("devstat", defaultDisabled, NewDevstatCollector)
|
||||
}
|
||||
|
||||
// NewDevstatCollector returns a new Collector exposing Device stats.
|
||||
|
@ -52,27 +52,27 @@ func NewDevstatCollector() (Collector, error) {
|
|||
return &devstatCollector{
|
||||
devinfo: &C.struct_devinfo{},
|
||||
bytes: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, devstatSubsystem, "bytes_total"),
|
||||
prometheus.BuildFQName(namespace, devstatSubsystem, "bytes_total"),
|
||||
"The total number of bytes in transactions.",
|
||||
[]string{"device", "type"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
transfers: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, devstatSubsystem, "transfers_total"),
|
||||
prometheus.BuildFQName(namespace, devstatSubsystem, "transfers_total"),
|
||||
"The total number of transactions.",
|
||||
[]string{"device", "type"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
duration: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, devstatSubsystem, "duration_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, devstatSubsystem, "duration_seconds_total"),
|
||||
"The total duration of transactions in seconds.",
|
||||
[]string{"device", "type"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
busyTime: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, devstatSubsystem, "busy_time_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, devstatSubsystem, "busy_time_seconds_total"),
|
||||
"Total time the device had one or more transactions outstanding in seconds.",
|
||||
[]string{"device"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
blocks: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, devstatSubsystem, "blocks_transferred_total"),
|
||||
prometheus.BuildFQName(namespace, devstatSubsystem, "blocks_transferred_total"),
|
||||
"The total number of blocks transferred.",
|
||||
[]string{"device"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
|
|
|
@ -36,7 +36,7 @@ type diskstatsCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["diskstats"] = NewDiskstatsCollector
|
||||
registerCollector("diskstats", defaultEnabled, NewDiskstatsCollector)
|
||||
}
|
||||
|
||||
// NewDiskstatsCollector returns a new Collector exposing disk device stats.
|
||||
|
@ -48,7 +48,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
{
|
||||
typedDesc: typedDesc{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "reads_completed_total"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "reads_completed_total"),
|
||||
"The total number of reads completed successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -62,7 +62,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
{
|
||||
typedDesc: typedDesc{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "read_sectors_total"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "read_sectors_total"),
|
||||
"The total number of sectors read successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -76,7 +76,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
{
|
||||
typedDesc: typedDesc{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "read_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "read_seconds_total"),
|
||||
"The total number of seconds spent by all reads.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -90,7 +90,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
{
|
||||
typedDesc: typedDesc{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "writes_completed_total"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "writes_completed_total"),
|
||||
"The total number of writes completed successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -104,7 +104,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
{
|
||||
typedDesc: typedDesc{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "written_sectors_total"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "written_sectors_total"),
|
||||
"The total number of sectors written successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -118,7 +118,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
{
|
||||
typedDesc: typedDesc{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "write_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "write_seconds_total"),
|
||||
"This is the total number of seconds spent by all writes.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -132,7 +132,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
{
|
||||
typedDesc: typedDesc{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "read_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "read_bytes_total"),
|
||||
"The total number of bytes read successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -146,7 +146,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
{
|
||||
typedDesc: typedDesc{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "written_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "written_bytes_total"),
|
||||
"The total number of bytes written successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
|
|
@ -44,7 +44,7 @@ type diskstatsCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["diskstats"] = NewDiskstatsCollector
|
||||
registerCollector("diskstats", defaultEnabled, NewDiskstatsCollector)
|
||||
}
|
||||
|
||||
// NewDiskstatsCollector returns a new Collector exposing disk device stats.
|
||||
|
@ -57,7 +57,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
descs: []typedDesc{
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "reads_completed"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "reads_completed"),
|
||||
"The total number of reads completed successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -65,7 +65,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "reads_merged"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "reads_merged"),
|
||||
"The total number of reads merged. See https://www.kernel.org/doc/Documentation/iostats.txt.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -73,7 +73,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "sectors_read"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "sectors_read"),
|
||||
"The total number of sectors read successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -81,7 +81,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "read_time_ms"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "read_time_ms"),
|
||||
"The total number of milliseconds spent by all reads.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -89,7 +89,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "writes_completed"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "writes_completed"),
|
||||
"The total number of writes completed successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -97,7 +97,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "writes_merged"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "writes_merged"),
|
||||
"The number of writes merged. See https://www.kernel.org/doc/Documentation/iostats.txt.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -105,7 +105,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "sectors_written"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "sectors_written"),
|
||||
"The total number of sectors written successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -113,7 +113,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "write_time_ms"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "write_time_ms"),
|
||||
"This is the total number of milliseconds spent by all writes.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -121,7 +121,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "io_now"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "io_now"),
|
||||
"The number of I/Os currently in progress.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -129,7 +129,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "io_time_ms"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "io_time_ms"),
|
||||
"Total Milliseconds spent doing I/Os.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -137,7 +137,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "io_time_weighted"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "io_time_weighted"),
|
||||
"The weighted # of milliseconds spent doing I/Os. See https://www.kernel.org/doc/Documentation/iostats.txt.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -145,7 +145,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "bytes_read"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "bytes_read"),
|
||||
"The total number of bytes read successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
@ -153,7 +153,7 @@ func NewDiskstatsCollector() (Collector, error) {
|
|||
},
|
||||
{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, diskSubsystem, "bytes_written"),
|
||||
prometheus.BuildFQName(namespace, diskSubsystem, "bytes_written"),
|
||||
"The total number of bytes written successfully.",
|
||||
diskLabelNames,
|
||||
nil,
|
||||
|
|
|
@ -34,7 +34,7 @@ type drbdNumericalMetric struct {
|
|||
func newDRBDNumericalMetric(name string, desc string, valueType prometheus.ValueType, multiplier float64) drbdNumericalMetric {
|
||||
return drbdNumericalMetric{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "drbd", name),
|
||||
prometheus.BuildFQName(namespace, "drbd", name),
|
||||
desc,
|
||||
[]string{"device"}, nil),
|
||||
valueType: valueType,
|
||||
|
@ -58,7 +58,7 @@ func (metric *drbdStringPairMetric) isOkay(value string) float64 {
|
|||
func newDRBDStringPairMetric(name string, desc string, valueOkay string) drbdStringPairMetric {
|
||||
return drbdStringPairMetric{
|
||||
desc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "drbd", name),
|
||||
prometheus.BuildFQName(namespace, "drbd", name),
|
||||
desc,
|
||||
[]string{"device", "node"}, nil),
|
||||
valueOkay: valueOkay,
|
||||
|
@ -140,7 +140,7 @@ var (
|
|||
}
|
||||
|
||||
drbdConnected = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "drbd", "connected"),
|
||||
prometheus.BuildFQName(namespace, "drbd", "connected"),
|
||||
"Whether DRBD is connected to the peer.",
|
||||
[]string{"device"}, nil)
|
||||
)
|
||||
|
@ -148,7 +148,7 @@ var (
|
|||
type drbdCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories["drbd"] = newDRBDCollector
|
||||
registerCollector("drbd", defaultDisabled, newDRBDCollector)
|
||||
}
|
||||
|
||||
func newDRBDCollector() (Collector, error) {
|
||||
|
|
|
@ -41,29 +41,29 @@ type edacCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["edac"] = NewEdacCollector
|
||||
registerCollector("edac", defaultEnabled, NewEdacCollector)
|
||||
}
|
||||
|
||||
// NewEdacCollector returns a new Collector exposing edac stats.
|
||||
func NewEdacCollector() (Collector, error) {
|
||||
return &edacCollector{
|
||||
ceCount: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, edacSubsystem, "correctable_errors_total"),
|
||||
prometheus.BuildFQName(namespace, edacSubsystem, "correctable_errors_total"),
|
||||
"Total correctable memory errors.",
|
||||
[]string{"controller"}, nil,
|
||||
),
|
||||
ueCount: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, edacSubsystem, "uncorrectable_errors_total"),
|
||||
prometheus.BuildFQName(namespace, edacSubsystem, "uncorrectable_errors_total"),
|
||||
"Total uncorrectable memory errors.",
|
||||
[]string{"controller"}, nil,
|
||||
),
|
||||
csRowCECount: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, edacSubsystem, "csrow_correctable_errors_total"),
|
||||
prometheus.BuildFQName(namespace, edacSubsystem, "csrow_correctable_errors_total"),
|
||||
"Total correctable memory errors for this csrow.",
|
||||
[]string{"controller", "csrow"}, nil,
|
||||
),
|
||||
csRowUECount: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, edacSubsystem, "csrow_uncorrectable_errors_total"),
|
||||
prometheus.BuildFQName(namespace, edacSubsystem, "csrow_uncorrectable_errors_total"),
|
||||
"Total uncorrectable memory errors for this csrow.",
|
||||
[]string{"controller", "csrow"}, nil,
|
||||
),
|
||||
|
|
|
@ -26,14 +26,14 @@ type entropyCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["entropy"] = NewEntropyCollector
|
||||
registerCollector("entropy", defaultEnabled, NewEntropyCollector)
|
||||
}
|
||||
|
||||
// NewEntropyCollector returns a new Collector exposing entropy stats.
|
||||
func NewEntropyCollector() (Collector, error) {
|
||||
return &entropyCollector{
|
||||
entropyAvail: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "entropy_available_bits"),
|
||||
prometheus.BuildFQName(namespace, "", "entropy_available_bits"),
|
||||
"Bits of available entropy.",
|
||||
nil, nil,
|
||||
),
|
||||
|
|
|
@ -25,7 +25,7 @@ type execCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["exec"] = NewExecCollector
|
||||
registerCollector("exec", defaultEnabled, NewExecCollector)
|
||||
}
|
||||
|
||||
// NewExecCollector returns a new Collector exposing system execution statistics.
|
||||
|
@ -95,7 +95,7 @@ func (c *execCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "exec", m.name),
|
||||
prometheus.BuildFQName(namespace, "exec", m.name),
|
||||
m.description,
|
||||
nil, nil,
|
||||
), prometheus.CounterValue, v)
|
||||
|
|
|
@ -32,7 +32,7 @@ const (
|
|||
type fileFDStatCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories[fileFDStatSubsystem] = NewFileFDStatCollector
|
||||
registerCollector(fileFDStatSubsystem, defaultEnabled, NewFileFDStatCollector)
|
||||
}
|
||||
|
||||
// NewFileFDStatCollector returns a new Collector exposing file-nr stats.
|
||||
|
@ -52,7 +52,7 @@ func (c *fileFDStatCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
}
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, fileFDStatSubsystem, name),
|
||||
prometheus.BuildFQName(namespace, fileFDStatSubsystem, name),
|
||||
fmt.Sprintf("File descriptor statistics: %s.", name),
|
||||
nil, nil,
|
||||
),
|
||||
|
|
|
@ -62,7 +62,7 @@ type filesystemStats struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["filesystem"] = NewFilesystemCollector
|
||||
registerCollector("filesystem", defaultEnabled, NewFilesystemCollector)
|
||||
}
|
||||
|
||||
// NewFilesystemCollector returns a new Collector exposing filesystems stats.
|
||||
|
@ -72,43 +72,43 @@ func NewFilesystemCollector() (Collector, error) {
|
|||
filesystemsTypesPattern := regexp.MustCompile(*ignoredFSTypes)
|
||||
|
||||
sizeDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "size"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "size"),
|
||||
"Filesystem size in bytes.",
|
||||
filesystemLabelNames, nil,
|
||||
)
|
||||
|
||||
freeDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "free"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "free"),
|
||||
"Filesystem free space in bytes.",
|
||||
filesystemLabelNames, nil,
|
||||
)
|
||||
|
||||
availDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "avail"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "avail"),
|
||||
"Filesystem space available to non-root users in bytes.",
|
||||
filesystemLabelNames, nil,
|
||||
)
|
||||
|
||||
filesDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "files"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "files"),
|
||||
"Filesystem total file nodes.",
|
||||
filesystemLabelNames, nil,
|
||||
)
|
||||
|
||||
filesFreeDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "files_free"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "files_free"),
|
||||
"Filesystem total free file nodes.",
|
||||
filesystemLabelNames, nil,
|
||||
)
|
||||
|
||||
roDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "readonly"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "readonly"),
|
||||
"Filesystem read-only status.",
|
||||
filesystemLabelNames, nil,
|
||||
)
|
||||
|
||||
deviceErrorDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "device_error"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "device_error"),
|
||||
"Whether an error occurred while getting statistics for the given device.",
|
||||
filesystemLabelNames, nil,
|
||||
)
|
||||
|
|
|
@ -41,7 +41,7 @@ type gmondCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["gmond"] = NewGmondCollector
|
||||
registerCollector("gmond", defaultDisabled, NewGmondCollector)
|
||||
}
|
||||
|
||||
var illegalCharsRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
|
||||
|
|
|
@ -42,7 +42,7 @@ var (
|
|||
)
|
||||
|
||||
func init() {
|
||||
Factories["hwmon"] = NewHwMonCollector
|
||||
registerCollector("hwmon", defaultEnabled, NewHwMonCollector)
|
||||
}
|
||||
|
||||
type hwMonCollector struct{}
|
||||
|
|
|
@ -44,7 +44,7 @@ type infinibandMetric struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["infiniband"] = NewInfiniBandCollector
|
||||
registerCollector("infiniband", defaultEnabled, NewInfiniBandCollector)
|
||||
}
|
||||
|
||||
// NewInfiniBandCollector returns a new Collector exposing InfiniBand stats.
|
||||
|
@ -80,7 +80,7 @@ func NewInfiniBandCollector() (Collector, error) {
|
|||
|
||||
for metricName, infinibandMetric := range i.counters {
|
||||
i.metricDescs[metricName] = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, metricName),
|
||||
prometheus.BuildFQName(namespace, subsystem, metricName),
|
||||
infinibandMetric.Help,
|
||||
[]string{"device", "port"},
|
||||
nil,
|
||||
|
@ -89,7 +89,7 @@ func NewInfiniBandCollector() (Collector, error) {
|
|||
|
||||
for metricName, infinibandMetric := range i.legacyCounters {
|
||||
i.metricDescs[metricName] = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, metricName),
|
||||
prometheus.BuildFQName(namespace, subsystem, metricName),
|
||||
infinibandMetric.Help,
|
||||
[]string{"device", "port"},
|
||||
nil,
|
||||
|
|
|
@ -23,14 +23,14 @@ type interruptsCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["interrupts"] = NewInterruptsCollector
|
||||
registerCollector("interrupts", defaultDisabled, NewInterruptsCollector)
|
||||
}
|
||||
|
||||
// NewInterruptsCollector returns a new Collector exposing interrupts stats.
|
||||
func NewInterruptsCollector() (Collector, error) {
|
||||
return &interruptsCollector{
|
||||
desc: typedDesc{prometheus.NewDesc(
|
||||
Namespace+"_interrupts",
|
||||
namespace+"_interrupts",
|
||||
"Interrupt details.",
|
||||
interruptLabelNames, nil,
|
||||
), prometheus.CounterValue},
|
||||
|
|
|
@ -33,7 +33,7 @@ type ipvsCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["ipvs"] = NewIPVSCollector
|
||||
registerCollector("ipvs", defaultEnabled, NewIPVSCollector)
|
||||
}
|
||||
|
||||
// NewIPVSCollector sets up a new collector for IPVS metrics. It accepts the
|
||||
|
@ -62,42 +62,42 @@ func newIPVSCollector() (*ipvsCollector, error) {
|
|||
}
|
||||
|
||||
c.connections = typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "connections_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "connections_total"),
|
||||
"The total number of connections made.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue}
|
||||
c.incomingPackets = typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "incoming_packets_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "incoming_packets_total"),
|
||||
"The total number of incoming packets.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue}
|
||||
c.outgoingPackets = typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "outgoing_packets_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "outgoing_packets_total"),
|
||||
"The total number of outgoing packets.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue}
|
||||
c.incomingBytes = typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "incoming_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "incoming_bytes_total"),
|
||||
"The total amount of incoming data.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue}
|
||||
c.outgoingBytes = typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "outgoing_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "outgoing_bytes_total"),
|
||||
"The total amount of outgoing data.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue}
|
||||
c.backendConnectionsActive = typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "backend_connections_active"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "backend_connections_active"),
|
||||
"The current active connections by local and remote address.",
|
||||
ipvsBackendLabelNames, nil,
|
||||
), prometheus.GaugeValue}
|
||||
c.backendConnectionsInact = typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "backend_connections_inactive"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "backend_connections_inactive"),
|
||||
"The current inactive connections by local and remote address.",
|
||||
ipvsBackendLabelNames, nil,
|
||||
), prometheus.GaugeValue}
|
||||
c.backendWeight = typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "backend_weight"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "backend_weight"),
|
||||
"The current backend weight by local and remote address.",
|
||||
ipvsBackendLabelNames, nil,
|
||||
), prometheus.GaugeValue}
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
)
|
||||
|
||||
func TestIPVSCollector(t *testing.T) {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--collector.procfs", "fixtures/proc"}); err != nil {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--path.procfs", "fixtures/proc"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
collector, err := newIPVSCollector()
|
||||
|
@ -76,7 +76,7 @@ func (c miniCollector) Describe(ch chan<- *prometheus.Desc) {
|
|||
}
|
||||
|
||||
func TestIPVSCollectorResponse(t *testing.T) {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--collector.procfs", "fixtures/proc"}); err != nil {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--path.procfs", "fixtures/proc"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
collector, err := NewIPVSCollector()
|
||||
|
|
|
@ -32,7 +32,7 @@ type ksmdCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["ksmd"] = NewKsmdCollector
|
||||
registerCollector("ksmd", defaultDisabled, NewKsmdCollector)
|
||||
}
|
||||
|
||||
func getCanonicalMetricName(filename string) string {
|
||||
|
@ -53,7 +53,7 @@ func NewKsmdCollector() (Collector, error) {
|
|||
|
||||
for _, n := range ksmdFiles {
|
||||
descs[n] = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, getCanonicalMetricName(n)),
|
||||
prometheus.BuildFQName(namespace, subsystem, getCanonicalMetricName(n)),
|
||||
fmt.Sprintf("ksmd '%s' file.", n), nil, nil)
|
||||
}
|
||||
return &ksmdCollector{descs}, nil
|
||||
|
|
|
@ -28,16 +28,16 @@ type loadavgCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["loadavg"] = NewLoadavgCollector
|
||||
registerCollector("loadavg", defaultEnabled, NewLoadavgCollector)
|
||||
}
|
||||
|
||||
// NewLoadavgCollector returns a new Collector exposing load average stats.
|
||||
func NewLoadavgCollector() (Collector, error) {
|
||||
return &loadavgCollector{
|
||||
metric: []typedDesc{
|
||||
{prometheus.NewDesc(Namespace+"_load1", "1m load average.", nil, nil), prometheus.GaugeValue},
|
||||
{prometheus.NewDesc(Namespace+"_load5", "5m load average.", nil, nil), prometheus.GaugeValue},
|
||||
{prometheus.NewDesc(Namespace+"_load15", "15m load average.", nil, nil), prometheus.GaugeValue},
|
||||
{prometheus.NewDesc(namespace+"_load1", "1m load average.", nil, nil), prometheus.GaugeValue},
|
||||
{prometheus.NewDesc(namespace+"_load5", "5m load average.", nil, nil), prometheus.GaugeValue},
|
||||
{prometheus.NewDesc(namespace+"_load15", "15m load average.", nil, nil), prometheus.GaugeValue},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ var (
|
|||
attrClassValues = []string{"other", "user", "greeter", "lock-screen", "background"}
|
||||
|
||||
sessionsDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, logindSubsystem, "sessions"),
|
||||
prometheus.BuildFQName(namespace, logindSubsystem, "sessions"),
|
||||
"Number of sessions registered in logind.", []string{"seat", "remote", "type", "class"}, nil,
|
||||
)
|
||||
)
|
||||
|
@ -78,7 +78,7 @@ type logindSeatEntry struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["logind"] = NewLogindCollector
|
||||
registerCollector("logind", defaultDisabled, NewLogindCollector)
|
||||
}
|
||||
|
||||
// NewLogindCollector returns a new Collector exposing logind statistics.
|
||||
|
|
|
@ -47,7 +47,7 @@ type mdStatus struct {
|
|||
type mdadmCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories["mdadm"] = NewMdadmCollector
|
||||
registerCollector("mdadm", defaultEnabled, NewMdadmCollector)
|
||||
}
|
||||
|
||||
func evalStatusline(statusline string) (active, total, size int64, err error) {
|
||||
|
@ -220,35 +220,35 @@ func NewMdadmCollector() (Collector, error) {
|
|||
|
||||
var (
|
||||
isActiveDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "md", "is_active"),
|
||||
prometheus.BuildFQName(namespace, "md", "is_active"),
|
||||
"Indicator whether the md-device is active or not.",
|
||||
[]string{"device"},
|
||||
nil,
|
||||
)
|
||||
|
||||
disksActiveDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "md", "disks_active"),
|
||||
prometheus.BuildFQName(namespace, "md", "disks_active"),
|
||||
"Number of active disks of device.",
|
||||
[]string{"device"},
|
||||
nil,
|
||||
)
|
||||
|
||||
disksTotalDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "md", "disks"),
|
||||
prometheus.BuildFQName(namespace, "md", "disks"),
|
||||
"Total number of disks of device.",
|
||||
[]string{"device"},
|
||||
nil,
|
||||
)
|
||||
|
||||
blocksTotalDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "md", "blocks"),
|
||||
prometheus.BuildFQName(namespace, "md", "blocks"),
|
||||
"Total number of blocks on device.",
|
||||
[]string{"device"},
|
||||
nil,
|
||||
)
|
||||
|
||||
blocksSyncedDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "md", "blocks_synced"),
|
||||
prometheus.BuildFQName(namespace, "md", "blocks_synced"),
|
||||
"Number of blocks synced on device.",
|
||||
[]string{"device"},
|
||||
nil,
|
||||
|
|
|
@ -44,7 +44,7 @@ type megaCliCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["megacli"] = NewMegaCliCollector
|
||||
registerCollector("megacli", defaultDisabled, NewMegaCliCollector)
|
||||
}
|
||||
|
||||
// NewMegaCliCollector returns a new Collector exposing RAID status through
|
||||
|
@ -54,17 +54,17 @@ func NewMegaCliCollector() (Collector, error) {
|
|||
return &megaCliCollector{
|
||||
cli: *megacliCommand,
|
||||
driveTemperature: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: Namespace,
|
||||
Namespace: namespace,
|
||||
Name: "megacli_drive_temperature_celsius",
|
||||
Help: "megacli: drive temperature",
|
||||
}, []string{"enclosure", "slot"}),
|
||||
driveCounters: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: Namespace,
|
||||
Namespace: namespace,
|
||||
Name: "megacli_drive_count",
|
||||
Help: "megacli: drive error and event counters",
|
||||
}, []string{"enclosure", "slot", "type"}),
|
||||
drivePresence: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: Namespace,
|
||||
Namespace: namespace,
|
||||
Name: "megacli_adapter_disk_presence",
|
||||
Help: "megacli: disk presence per adapter",
|
||||
}, []string{"type"}),
|
||||
|
|
|
@ -30,7 +30,7 @@ const (
|
|||
type meminfoCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories["meminfo"] = NewMeminfoCollector
|
||||
registerCollector("meminfo", defaultEnabled, NewMeminfoCollector)
|
||||
}
|
||||
|
||||
// NewMeminfoCollector returns a new Collector exposing memory stats.
|
||||
|
@ -49,7 +49,7 @@ func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
for k, v := range memInfo {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, memInfoSubsystem, k),
|
||||
prometheus.BuildFQName(namespace, memInfoSubsystem, k),
|
||||
fmt.Sprintf("Memory information field %s.", k),
|
||||
nil, nil,
|
||||
),
|
||||
|
|
|
@ -47,7 +47,7 @@ type meminfoNumaCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["meminfo_numa"] = NewMeminfoNumaCollector
|
||||
registerCollector("meminfo_numa", defaultDisabled, NewMeminfoNumaCollector)
|
||||
}
|
||||
|
||||
// NewMeminfoNumaCollector returns a new Collector exposing memory stats.
|
||||
|
@ -66,7 +66,7 @@ func (c *meminfoNumaCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
desc, ok := c.metricDescs[v.metricName]
|
||||
if !ok {
|
||||
desc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, memInfoNumaSubsystem, v.metricName),
|
||||
prometheus.BuildFQName(namespace, memInfoNumaSubsystem, v.metricName),
|
||||
fmt.Sprintf("Memory information field %s.", v.metricName),
|
||||
[]string{"node"}, nil)
|
||||
c.metricDescs[v.metricName] = desc
|
||||
|
|
|
@ -90,7 +90,7 @@ type mountStatsCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["mountstats"] = NewMountStatsCollector
|
||||
registerCollector("mountstats", defaultDisabled, NewMountStatsCollector)
|
||||
}
|
||||
|
||||
// NewMountStatsCollector returns a new Collector exposing NFS statistics.
|
||||
|
@ -117,371 +117,371 @@ func NewMountStatsCollector() (Collector, error) {
|
|||
|
||||
return &mountStatsCollector{
|
||||
NFSAgeSecondsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "age_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "age_seconds_total"),
|
||||
"The age of the NFS mount in seconds.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSReadBytesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "read_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "read_bytes_total"),
|
||||
"Number of bytes read using the read() syscall.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSWriteBytesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "write_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "write_bytes_total"),
|
||||
"Number of bytes written using the write() syscall.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSDirectReadBytesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "direct_read_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "direct_read_bytes_total"),
|
||||
"Number of bytes read using the read() syscall in O_DIRECT mode.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSDirectWriteBytesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "direct_write_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "direct_write_bytes_total"),
|
||||
"Number of bytes written using the write() syscall in O_DIRECT mode.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTotalReadBytesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "total_read_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "total_read_bytes_total"),
|
||||
"Number of bytes read from the NFS server, in total.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTotalWriteBytesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "total_write_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "total_write_bytes_total"),
|
||||
"Number of bytes written to the NFS server, in total.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSReadPagesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "read_pages_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "read_pages_total"),
|
||||
"Number of pages read directly via mmap()'d files.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSWritePagesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "write_pages_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "write_pages_total"),
|
||||
"Number of pages written directly via mmap()'d files.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportBindTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_bind_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_bind_total"),
|
||||
"Number of times the client has had to establish a connection from scratch to the NFS server.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportConnectTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_connect_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_connect_total"),
|
||||
"Number of times the client has made a TCP connection to the NFS server.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportIdleTimeSeconds: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_idle_time_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_idle_time_seconds"),
|
||||
"Duration since the NFS mount last saw any RPC traffic, in seconds.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportSendsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_sends_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_sends_total"),
|
||||
"Number of RPC requests for this mount sent to the NFS server.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportReceivesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_receives_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_receives_total"),
|
||||
"Number of RPC responses for this mount received from the NFS server.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportBadTransactionIDsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_bad_transaction_ids_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_bad_transaction_ids_total"),
|
||||
"Number of times the NFS server sent a response with a transaction ID unknown to this client.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportBacklogQueueTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_backlog_queue_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_backlog_queue_total"),
|
||||
"Total number of items added to the RPC backlog queue.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportMaximumRPCSlots: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_maximum_rpc_slots"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_maximum_rpc_slots"),
|
||||
"Maximum number of simultaneously active RPC requests ever used.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportSendingQueueTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_sending_queue_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_sending_queue_total"),
|
||||
"Total number of items added to the RPC transmission sending queue.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSTransportPendingQueueTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "transport_pending_queue_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "transport_pending_queue_total"),
|
||||
"Total number of items added to the RPC transmission pending queue.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSOperationsRequestsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "operations_requests_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "operations_requests_total"),
|
||||
"Number of requests performed for a given operation.",
|
||||
opLabels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSOperationsTransmissionsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "operations_transmissions_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "operations_transmissions_total"),
|
||||
"Number of times an actual RPC request has been transmitted for a given operation.",
|
||||
opLabels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSOperationsMajorTimeoutsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "operations_major_timeouts_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "operations_major_timeouts_total"),
|
||||
"Number of times a request has had a major timeout for a given operation.",
|
||||
opLabels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSOperationsSentBytesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "operations_sent_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "operations_sent_bytes_total"),
|
||||
"Number of bytes sent for a given operation, including RPC headers and payload.",
|
||||
opLabels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSOperationsReceivedBytesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "operations_received_bytes_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "operations_received_bytes_total"),
|
||||
"Number of bytes received for a given operation, including RPC headers and payload.",
|
||||
opLabels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSOperationsQueueTimeSecondsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "operations_queue_time_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "operations_queue_time_seconds_total"),
|
||||
"Duration all requests spent queued for transmission for a given operation before they were sent, in seconds.",
|
||||
opLabels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSOperationsResponseTimeSecondsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "operations_response_time_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "operations_response_time_seconds_total"),
|
||||
"Duration all requests took to get a reply back after a request for a given operation was transmitted, in seconds.",
|
||||
opLabels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSOperationsRequestTimeSecondsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "operations_request_time_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "operations_request_time_seconds_total"),
|
||||
"Duration all requests took from when a request was enqueued to when it was completely handled for a given operation, in seconds.",
|
||||
opLabels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventInodeRevalidateTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_inode_revalidate_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_inode_revalidate_total"),
|
||||
"Number of times cached inode attributes are re-validated from the server.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventDnodeRevalidateTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_dnode_revalidate_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_dnode_revalidate_total"),
|
||||
"Number of times cached dentry nodes are re-validated from the server.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventDataInvalidateTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_data_invalidate_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_data_invalidate_total"),
|
||||
"Number of times an inode cache is cleared.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventAttributeInvalidateTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_attribute_invalidate_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_attribute_invalidate_total"),
|
||||
"Number of times cached inode attributes are invalidated.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSOpenTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_open_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_open_total"),
|
||||
"Number of times cached inode attributes are invalidated.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSLookupTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_lookup_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_lookup_total"),
|
||||
"Number of times a directory lookup has occurred.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSAccessTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_access_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_access_total"),
|
||||
"Number of times permissions have been checked.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSUpdatePageTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_update_page_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_update_page_total"),
|
||||
"Number of updates (and potential writes) to pages.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSReadPageTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_read_page_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_read_page_total"),
|
||||
"Number of pages read directly via mmap()'d files.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSReadPagesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_read_pages_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_read_pages_total"),
|
||||
"Number of times a group of pages have been read.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSWritePageTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_write_page_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_write_page_total"),
|
||||
"Number of pages written directly via mmap()'d files.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSWritePagesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_write_pages_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_write_pages_total"),
|
||||
"Number of times a group of pages have been written.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSGetdentsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_getdents_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_getdents_total"),
|
||||
"Number of times directory entries have been read with getdents().",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSSetattrTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_setattr_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_setattr_total"),
|
||||
"Number of times directory entries have been read with getdents().",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSFlushTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_flush_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_flush_total"),
|
||||
"Number of pending writes that have been forcefully flushed to the server.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSFsyncTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_fsync_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_fsync_total"),
|
||||
"Number of times fsync() has been called on directories and files.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSLockTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_lock_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_lock_total"),
|
||||
"Number of times locking has been attempted on a file.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventVFSFileReleaseTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_vfs_file_release_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_vfs_file_release_total"),
|
||||
"Number of times files have been closed and released.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventTruncationTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_truncation_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_truncation_total"),
|
||||
"Number of times files have been truncated.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventWriteExtensionTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_write_extension_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_write_extension_total"),
|
||||
"Number of times a file has been grown due to writes beyond its existing end.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventSillyRenameTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_silly_rename_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_silly_rename_total"),
|
||||
"Number of times a file was removed while still open by another process.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventShortReadTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_short_read_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_short_read_total"),
|
||||
"Number of times the NFS server gave less data than expected while reading.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventShortWriteTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_short_write_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_short_write_total"),
|
||||
"Number of times the NFS server wrote less data than expected while writing.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventJukeboxDelayTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_jukebox_delay_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_jukebox_delay_total"),
|
||||
"Number of times the NFS server indicated EJUKEBOX; retrieving data from offline storage.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventPNFSReadTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_pnfs_read_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_pnfs_read_total"),
|
||||
"Number of NFS v4.1+ pNFS reads.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
NFSEventPNFSWriteTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "event_pnfs_write_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "event_pnfs_write_total"),
|
||||
"Number of NFS v4.1+ pNFS writes.",
|
||||
labels,
|
||||
nil,
|
||||
|
|
|
@ -36,7 +36,7 @@ type netDevCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["netdev"] = NewNetDevCollector
|
||||
registerCollector("netdev", defaultEnabled, NewNetDevCollector)
|
||||
}
|
||||
|
||||
// NewNetDevCollector returns a new Collector exposing network device stats.
|
||||
|
@ -59,7 +59,7 @@ func (c *netDevCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
desc, ok := c.metricDescs[key]
|
||||
if !ok {
|
||||
desc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, c.subsystem, key),
|
||||
prometheus.BuildFQName(namespace, c.subsystem, key),
|
||||
fmt.Sprintf("Network device statistic %s.", key),
|
||||
[]string{"device"},
|
||||
nil,
|
||||
|
|
|
@ -33,7 +33,7 @@ const (
|
|||
type netStatCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories["netstat"] = NewNetStatCollector
|
||||
registerCollector("netstat", defaultEnabled, NewNetStatCollector)
|
||||
}
|
||||
|
||||
// NewNetStatCollector takes and returns
|
||||
|
@ -72,7 +72,7 @@ func (c *netStatCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
}
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, netStatsSubsystem, key),
|
||||
prometheus.BuildFQName(namespace, netStatsSubsystem, key),
|
||||
fmt.Sprintf("Statistic %s.", protocol+name),
|
||||
nil, nil,
|
||||
),
|
||||
|
|
|
@ -66,39 +66,39 @@ var (
|
|||
}
|
||||
|
||||
nfsNetReadsDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "nfs", "net_reads"),
|
||||
prometheus.BuildFQName(namespace, "nfs", "net_reads"),
|
||||
"Number of reads at the network layer.",
|
||||
[]string{"protocol"},
|
||||
nil,
|
||||
)
|
||||
nfsNetConnectionsDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "nfs", "net_connections"),
|
||||
prometheus.BuildFQName(namespace, "nfs", "net_connections"),
|
||||
"Number of connections at the network layer.",
|
||||
[]string{"protocol"},
|
||||
nil,
|
||||
)
|
||||
|
||||
nfsRPCOperationsDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "nfs", "rpc_operations"),
|
||||
prometheus.BuildFQName(namespace, "nfs", "rpc_operations"),
|
||||
"Number of RPCs performed.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
nfsRPCRetransmissionsDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "nfs", "rpc_retransmissions"),
|
||||
prometheus.BuildFQName(namespace, "nfs", "rpc_retransmissions"),
|
||||
"Number of RPC transmissions performed.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
nfsRPCAuthenticationRefreshesDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "nfs", "rpc_authentication_refreshes"),
|
||||
prometheus.BuildFQName(namespace, "nfs", "rpc_authentication_refreshes"),
|
||||
"Number of RPC authentication refreshes performed.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
nfsProceduresDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "nfs", "procedures"),
|
||||
prometheus.BuildFQName(namespace, "nfs", "procedures"),
|
||||
"Number of NFS procedures invoked.",
|
||||
[]string{"version", "procedure"},
|
||||
nil,
|
||||
|
@ -108,7 +108,7 @@ var (
|
|||
type nfsCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories["nfs"] = NewNfsCollector
|
||||
registerCollector("nfs", defaultDisabled, NewNfsCollector)
|
||||
}
|
||||
|
||||
// NewNfsCollector returns a new Collector exposing NFS statistics.
|
||||
|
|
|
@ -48,7 +48,7 @@ type ntpCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["ntp"] = NewNtpCollector
|
||||
registerCollector("ntp", defaultDisabled, NewNtpCollector)
|
||||
}
|
||||
|
||||
// NewNtpCollector returns a new Collector exposing sanity of local NTP server.
|
||||
|
@ -58,7 +58,7 @@ func init() {
|
|||
func NewNtpCollector() (Collector, error) {
|
||||
ipaddr := net.ParseIP(*ntpServer)
|
||||
if !*ntpServerIsLocal && (ipaddr == nil || !ipaddr.IsLoopback()) {
|
||||
return nil, fmt.Errorf("only IP address of local NTP server is valid for -collector.ntp.server")
|
||||
return nil, fmt.Errorf("only IP address of local NTP server is valid for --collector.ntp.server")
|
||||
}
|
||||
|
||||
if *ntpProtocolVersion < 2 || *ntpProtocolVersion > 4 {
|
||||
|
@ -71,42 +71,42 @@ func NewNtpCollector() (Collector, error) {
|
|||
|
||||
return &ntpCollector{
|
||||
stratum: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, ntpSubsystem, "stratum"),
|
||||
prometheus.BuildFQName(namespace, ntpSubsystem, "stratum"),
|
||||
"NTPD stratum.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
leap: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, ntpSubsystem, "leap"),
|
||||
prometheus.BuildFQName(namespace, ntpSubsystem, "leap"),
|
||||
"NTPD leap second indicator, 2 bits.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
rtt: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, ntpSubsystem, "rtt_seconds"),
|
||||
prometheus.BuildFQName(namespace, ntpSubsystem, "rtt_seconds"),
|
||||
"RTT to NTPD.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
offset: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, ntpSubsystem, "offset_seconds"),
|
||||
prometheus.BuildFQName(namespace, ntpSubsystem, "offset_seconds"),
|
||||
"ClockOffset between NTP and local clock.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
reftime: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, ntpSubsystem, "reference_timestamp_seconds"),
|
||||
prometheus.BuildFQName(namespace, ntpSubsystem, "reference_timestamp_seconds"),
|
||||
"NTPD ReferenceTime, UNIX timestamp.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
rootDelay: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, ntpSubsystem, "root_delay_seconds"),
|
||||
prometheus.BuildFQName(namespace, ntpSubsystem, "root_delay_seconds"),
|
||||
"NTPD RootDelay.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
rootDispersion: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, ntpSubsystem, "root_dispersion_seconds"),
|
||||
prometheus.BuildFQName(namespace, ntpSubsystem, "root_dispersion_seconds"),
|
||||
"NTPD RootDispersion.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
sanity: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, ntpSubsystem, "sanity"),
|
||||
prometheus.BuildFQName(namespace, ntpSubsystem, "sanity"),
|
||||
"NTPD sanity according to RFC5905 heuristics and configured limits.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
|
|
|
@ -22,8 +22,8 @@ import (
|
|||
|
||||
var (
|
||||
// The path of the proc filesystem.
|
||||
procPath = kingpin.Flag("collector.procfs", "procfs mountpoint.").Default(procfs.DefaultMountPoint).String()
|
||||
sysPath = kingpin.Flag("collector.sysfs", "sysfs mountpoint.").Default("/sys").String()
|
||||
procPath = kingpin.Flag("path.procfs", "procfs mountpoint.").Default(procfs.DefaultMountPoint).String()
|
||||
sysPath = kingpin.Flag("path.sysfs", "sysfs mountpoint.").Default("/sys").String()
|
||||
)
|
||||
|
||||
func procFilePath(name string) string {
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
)
|
||||
|
||||
func TestDefaultProcPath(t *testing.T) {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--collector.procfs", procfs.DefaultMountPoint}); err != nil {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--path.procfs", procfs.DefaultMountPoint}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ func TestDefaultProcPath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCustomProcPath(t *testing.T) {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--collector.procfs", "./../some/./place/"}); err != nil {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--path.procfs", "./../some/./place/"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ func TestCustomProcPath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDefaultSysPath(t *testing.T) {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--collector.sysfs", "/sys"}); err != nil {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--path.sysfs", "/sys"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ func TestDefaultSysPath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCustomSysPath(t *testing.T) {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--collector.sysfs", "./../some/./place/"}); err != nil {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--path.sysfs", "./../some/./place/"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,37 +34,37 @@ type qdiscStatCollector struct {
|
|||
}
|
||||
|
||||
var (
|
||||
collectorQdisc = kingpin.Flag("collector.qdisc", "test fixtures to use for qdisc collector end-to-end testing").Default("").String()
|
||||
collectorQdisc = kingpin.Flag("collector.qdisc.fixtures", "test fixtures to use for qdisc collector end-to-end testing").Default("").String()
|
||||
)
|
||||
|
||||
func init() {
|
||||
Factories["qdisc"] = NewQdiscStatCollector
|
||||
registerCollector("qdisc", defaultDisabled, NewQdiscStatCollector)
|
||||
}
|
||||
|
||||
func NewQdiscStatCollector() (Collector, error) {
|
||||
return &qdiscStatCollector{
|
||||
bytes: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "qdisc", "bytes_total"),
|
||||
prometheus.BuildFQName(namespace, "qdisc", "bytes_total"),
|
||||
"Number of bytes sent.",
|
||||
[]string{"device", "kind"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
packets: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "qdisc", "packets_total"),
|
||||
prometheus.BuildFQName(namespace, "qdisc", "packets_total"),
|
||||
"Number of packets sent.",
|
||||
[]string{"device", "kind"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
drops: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "qdisc", "drops_total"),
|
||||
prometheus.BuildFQName(namespace, "qdisc", "drops_total"),
|
||||
"Number of packets dropped.",
|
||||
[]string{"device", "kind"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
requeues: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "qdisc", "requeues_total"),
|
||||
prometheus.BuildFQName(namespace, "qdisc", "requeues_total"),
|
||||
"Number of packets dequeued, not transmitted, and requeued.",
|
||||
[]string{"device", "kind"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
overlimits: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "qdisc", "overlimits_total"),
|
||||
prometheus.BuildFQName(namespace, "qdisc", "overlimits_total"),
|
||||
"Number of overlimit packets.",
|
||||
[]string{"device", "kind"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
|
|
|
@ -29,7 +29,7 @@ type runitCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["runit"] = NewRunitCollector
|
||||
registerCollector("runit", defaultDisabled, NewRunitCollector)
|
||||
}
|
||||
|
||||
// NewRunitCollector returns a new Collector exposing runit statistics.
|
||||
|
@ -42,22 +42,22 @@ func NewRunitCollector() (Collector, error) {
|
|||
|
||||
return &runitCollector{
|
||||
state: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "state"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "state"),
|
||||
"State of runit service.",
|
||||
labelNames, constLabels,
|
||||
), prometheus.GaugeValue},
|
||||
stateDesired: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "desired_state"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "desired_state"),
|
||||
"Desired state of runit service.",
|
||||
labelNames, constLabels,
|
||||
), prometheus.GaugeValue},
|
||||
stateNormal: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "normal_state"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "normal_state"),
|
||||
"Normal state of runit service.",
|
||||
labelNames, constLabels,
|
||||
), prometheus.GaugeValue},
|
||||
stateTimestamp: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "state_last_change_timestamp_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "state_last_change_timestamp_seconds"),
|
||||
"Unix timestamp of the last runit service state change.",
|
||||
labelNames, constLabels,
|
||||
), prometheus.GaugeValue},
|
||||
|
|
|
@ -36,7 +36,7 @@ var pageSize = os.Getpagesize()
|
|||
type sockStatCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories[sockStatSubsystem] = NewSockStatCollector
|
||||
registerCollector(sockStatSubsystem, defaultEnabled, NewSockStatCollector)
|
||||
}
|
||||
|
||||
// NewSockStatCollector returns a new Collector exposing socket stats.
|
||||
|
@ -57,7 +57,7 @@ func (c *sockStatCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
}
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, sockStatSubsystem, protocol+"_"+name),
|
||||
prometheus.BuildFQName(namespace, sockStatSubsystem, protocol+"_"+name),
|
||||
fmt.Sprintf("Number of %s sockets in state %s.", protocol, name),
|
||||
nil, nil,
|
||||
),
|
||||
|
|
|
@ -34,44 +34,44 @@ type statCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["stat"] = NewStatCollector
|
||||
registerCollector("stat", defaultEnabled, NewStatCollector)
|
||||
}
|
||||
|
||||
// NewStatCollector returns a new Collector exposing kernel/system statistics.
|
||||
func NewStatCollector() (Collector, error) {
|
||||
return &statCollector{
|
||||
cpu: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "cpu"),
|
||||
prometheus.BuildFQName(namespace, "", "cpu"),
|
||||
"Seconds the cpus spent in each mode.",
|
||||
[]string{"cpu", "mode"}, nil,
|
||||
),
|
||||
intr: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "intr"),
|
||||
prometheus.BuildFQName(namespace, "", "intr"),
|
||||
"Total number of interrupts serviced.",
|
||||
nil, nil,
|
||||
),
|
||||
ctxt: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "context_switches"),
|
||||
prometheus.BuildFQName(namespace, "", "context_switches"),
|
||||
"Total number of context switches.",
|
||||
nil, nil,
|
||||
),
|
||||
forks: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "forks"),
|
||||
prometheus.BuildFQName(namespace, "", "forks"),
|
||||
"Total number of forks.",
|
||||
nil, nil,
|
||||
),
|
||||
btime: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "boot_time"),
|
||||
prometheus.BuildFQName(namespace, "", "boot_time"),
|
||||
"Node boot time, in unixtime.",
|
||||
nil, nil,
|
||||
),
|
||||
procsRunning: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "procs_running"),
|
||||
prometheus.BuildFQName(namespace, "", "procs_running"),
|
||||
"Number of processes in runnable state.",
|
||||
nil, nil,
|
||||
),
|
||||
procsBlocked: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "", "procs_blocked"),
|
||||
prometheus.BuildFQName(namespace, "", "procs_blocked"),
|
||||
"Number of processes blocked waiting for I/O to complete.",
|
||||
nil, nil,
|
||||
),
|
||||
|
|
|
@ -35,7 +35,7 @@ type supervisordCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["supervisord"] = NewSupervisordCollector
|
||||
registerCollector("supervisord", defaultDisabled, NewSupervisordCollector)
|
||||
}
|
||||
|
||||
// NewSupervisordCollector returns a new Collector exposing supervisord statistics.
|
||||
|
@ -52,25 +52,25 @@ func NewSupervisordCollector() (Collector, error) {
|
|||
return &supervisordCollector{
|
||||
client: client,
|
||||
upDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "up"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "up"),
|
||||
"Process Up",
|
||||
labelNames,
|
||||
nil,
|
||||
),
|
||||
stateDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "state"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "state"),
|
||||
"Process State",
|
||||
labelNames,
|
||||
nil,
|
||||
),
|
||||
exitStatusDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "exit_status"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "exit_status"),
|
||||
"Process Exit Status",
|
||||
labelNames,
|
||||
nil,
|
||||
),
|
||||
uptimeDesc: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "uptime"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "uptime"),
|
||||
"Process Uptime",
|
||||
labelNames,
|
||||
nil,
|
||||
|
|
|
@ -41,7 +41,7 @@ type systemdCollector struct {
|
|||
var unitStatesName = []string{"active", "activating", "deactivating", "inactive", "failed"}
|
||||
|
||||
func init() {
|
||||
Factories["systemd"] = NewSystemdCollector
|
||||
registerCollector("systemd", defaultDisabled, NewSystemdCollector)
|
||||
}
|
||||
|
||||
// NewSystemdCollector returns a new Collector exposing systemd statistics.
|
||||
|
@ -49,11 +49,11 @@ func NewSystemdCollector() (Collector, error) {
|
|||
const subsystem = "systemd"
|
||||
|
||||
unitDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "unit_state"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "unit_state"),
|
||||
"Systemd unit", []string{"name", "state"}, nil,
|
||||
)
|
||||
systemRunningDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "system_running"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "system_running"),
|
||||
"Whether the system is operational (see 'systemctl is-system-running')",
|
||||
nil, nil,
|
||||
)
|
||||
|
|
|
@ -58,14 +58,14 @@ type tcpStatCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["tcpstat"] = NewTCPStatCollector
|
||||
registerCollector("tcpstat", defaultDisabled, NewTCPStatCollector)
|
||||
}
|
||||
|
||||
// NewTCPStatCollector returns a new Collector exposing network stats.
|
||||
func NewTCPStatCollector() (Collector, error) {
|
||||
return &tcpStatCollector{
|
||||
desc: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "tcp", "connection_states"),
|
||||
prometheus.BuildFQName(namespace, "tcp", "connection_states"),
|
||||
"Number of connection states.",
|
||||
[]string{"state"}, nil,
|
||||
), prometheus.GaugeValue},
|
||||
|
|
|
@ -41,7 +41,7 @@ type textFileCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["textfile"] = NewTextFileCollector
|
||||
registerCollector("textfile", defaultEnabled, NewTextFileCollector)
|
||||
}
|
||||
|
||||
// NewTextFileCollector returns a new Collector exposing metrics read from files
|
||||
|
|
|
@ -27,7 +27,7 @@ type timeCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["time"] = NewTimeCollector
|
||||
registerCollector("time", defaultEnabled, NewTimeCollector)
|
||||
}
|
||||
|
||||
// NewTimeCollector returns a new Collector exposing the current system time in
|
||||
|
@ -35,7 +35,7 @@ func init() {
|
|||
func NewTimeCollector() (Collector, error) {
|
||||
return &timeCollector{
|
||||
desc: prometheus.NewDesc(
|
||||
Namespace+"_time",
|
||||
namespace+"_time",
|
||||
"System time in seconds since epoch (1970).",
|
||||
nil, nil,
|
||||
),
|
||||
|
|
|
@ -57,7 +57,7 @@ type timexCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["timex"] = NewTimexCollector
|
||||
registerCollector("timex", defaultEnabled, NewTimexCollector)
|
||||
}
|
||||
|
||||
// NewTimexCollector returns a new Collector exposing adjtime(3) stats.
|
||||
|
@ -66,87 +66,87 @@ func NewTimexCollector() (Collector, error) {
|
|||
|
||||
return &timexCollector{
|
||||
offset: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "offset_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "offset_seconds"),
|
||||
"Time offset in between local system and reference clock.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
freq: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "frequency_adjustment"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "frequency_adjustment"),
|
||||
"Local clock frequency adjustment.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
maxerror: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "maxerror_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "maxerror_seconds"),
|
||||
"Maximum error in seconds.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
esterror: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "estimated_error_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "estimated_error_seconds"),
|
||||
"Estimated error in seconds.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
status: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "status"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "status"),
|
||||
"Value of the status array bits.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
constant: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "loop_time_constant"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "loop_time_constant"),
|
||||
"Phase-locked loop time constant.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
tick: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "tick_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "tick_seconds"),
|
||||
"Seconds between clock ticks.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
ppsfreq: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "pps_frequency"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "pps_frequency"),
|
||||
"Pulse per second frequency.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
jitter: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "pps_jitter_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "pps_jitter_seconds"),
|
||||
"Pulse per second jitter.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
shift: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "pps_shift_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "pps_shift_seconds"),
|
||||
"Pulse per second interval duration.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
stabil: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "pps_stability"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "pps_stability"),
|
||||
"Pulse per second stability.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue},
|
||||
jitcnt: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "pps_jitter_count"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "pps_jitter_count"),
|
||||
"Pulse per second count of jitter limit exceeded events.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue},
|
||||
calcnt: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "pps_calibration_count"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "pps_calibration_count"),
|
||||
"Pulse per second count of calibration intervals.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue},
|
||||
errcnt: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "pps_error_count"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "pps_error_count"),
|
||||
"Pulse per second count of calibration errors.",
|
||||
nil, nil,
|
||||
), prometheus.CounterValue},
|
||||
stbcnt: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "pps_stability_exceeded_count"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "pps_stability_exceeded_count"),
|
||||
"Pulse per second count of stability limit exceeded events.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
tai: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "tai_offset"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "tai_offset"),
|
||||
"International Atomic Time (TAI) offset.",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
syncStatus: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "sync_status"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "sync_status"),
|
||||
"Is clock synchronized to a reliable server (1 = yes, 0 = no).",
|
||||
nil, nil,
|
||||
), prometheus.GaugeValue},
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
)
|
||||
|
||||
var unameDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "uname", "info"),
|
||||
prometheus.BuildFQName(namespace, "uname", "info"),
|
||||
"Labeled system information as provided by the uname system call.",
|
||||
[]string{
|
||||
"sysname",
|
||||
|
@ -38,7 +38,7 @@ var unameDesc = prometheus.NewDesc(
|
|||
type unameCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories["uname"] = newUnameCollector
|
||||
registerCollector("uname", defaultEnabled, newUnameCollector)
|
||||
}
|
||||
|
||||
// NewUnameCollector returns new unameCollector.
|
||||
|
|
|
@ -32,7 +32,7 @@ const (
|
|||
type vmStatCollector struct{}
|
||||
|
||||
func init() {
|
||||
Factories["vmstat"] = NewvmStatCollector
|
||||
registerCollector("vmstat", defaultEnabled, NewvmStatCollector)
|
||||
}
|
||||
|
||||
// NewvmStatCollector returns a new Collector exposing vmstat stats.
|
||||
|
@ -57,7 +57,7 @@ func (c *vmStatCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, vmStatSubsystem, parts[0]),
|
||||
prometheus.BuildFQName(namespace, vmStatSubsystem, parts[0]),
|
||||
fmt.Sprintf("/proc/vmstat information field %s.", parts[0]),
|
||||
nil, nil),
|
||||
prometheus.UntypedValue,
|
||||
|
|
|
@ -41,11 +41,11 @@ type wifiCollector struct {
|
|||
}
|
||||
|
||||
var (
|
||||
collectorWifi = kingpin.Flag("collector.wifi", "test fixtures to use for wifi collector metrics").Default("").String()
|
||||
collectorWifi = kingpin.Flag("collector.wifi.fixtures", "test fixtures to use for wifi collector metrics").Default("").String()
|
||||
)
|
||||
|
||||
func init() {
|
||||
Factories["wifi"] = NewWifiCollector
|
||||
registerCollector("wifi", defaultEnabled, NewWifiCollector)
|
||||
}
|
||||
|
||||
var _ wifiStater = &wifi.Client{}
|
||||
|
@ -70,70 +70,70 @@ func NewWifiCollector() (Collector, error) {
|
|||
|
||||
return &wifiCollector{
|
||||
interfaceFrequencyHertz: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "interface_frequency_hertz"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "interface_frequency_hertz"),
|
||||
"The current frequency a WiFi interface is operating at, in hertz.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
stationInfo: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_info"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_info"),
|
||||
"Labeled WiFi interface station information as provided by the operating system.",
|
||||
[]string{"device", "bssid", "ssid", "mode"},
|
||||
nil,
|
||||
),
|
||||
|
||||
stationConnectedSecondsTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_connected_seconds_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_connected_seconds_total"),
|
||||
"The total number of seconds a station has been connected to an access point.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
stationInactiveSeconds: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_inactive_seconds"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_inactive_seconds"),
|
||||
"The number of seconds since any wireless activity has occurred on a station.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
stationReceiveBitsPerSecond: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_receive_bits_per_second"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_receive_bits_per_second"),
|
||||
"The current WiFi receive bitrate of a station, in bits per second.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
stationTransmitBitsPerSecond: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_transmit_bits_per_second"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_transmit_bits_per_second"),
|
||||
"The current WiFi transmit bitrate of a station, in bits per second.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
stationSignalDBM: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_signal_dbm"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_signal_dbm"),
|
||||
"The current WiFi signal strength, in decibel-milliwatts (dBm).",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
stationTransmitRetriesTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_transmit_retries_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_transmit_retries_total"),
|
||||
"The total number of times a station has had to retry while sending a packet.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
stationTransmitFailedTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_transmit_failed_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_transmit_failed_total"),
|
||||
"The total number of times a station has failed to send a packet.",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
stationBeaconLossTotal: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "station_beacon_loss_total"),
|
||||
prometheus.BuildFQName(namespace, subsystem, "station_beacon_loss_total"),
|
||||
"The total number of times a station has detected a beacon loss.",
|
||||
labels,
|
||||
nil,
|
||||
|
|
|
@ -27,7 +27,7 @@ type xfsCollector struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
Factories["xfs"] = NewXFSCollector
|
||||
registerCollector("xfs", defaultEnabled, NewXFSCollector)
|
||||
}
|
||||
|
||||
// NewXFSCollector returns a new Collector exposing XFS statistics.
|
||||
|
@ -179,7 +179,7 @@ func (c *xfsCollector) updateXFSStats(ch chan<- prometheus.Metric, s *xfs.Stats)
|
|||
|
||||
for _, m := range metrics {
|
||||
desc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, m.name),
|
||||
prometheus.BuildFQName(namespace, subsystem, m.name),
|
||||
m.desc,
|
||||
labels,
|
||||
nil,
|
||||
|
|
|
@ -29,7 +29,7 @@ var errZFSNotAvailable = errors.New("ZFS / ZFS statistics are not available")
|
|||
type zfsSysctl string
|
||||
|
||||
func init() {
|
||||
Factories["zfs"] = NewZFSCollector
|
||||
registerCollector("zfs", defaultEnabled, NewZFSCollector)
|
||||
}
|
||||
|
||||
type zfsCollector struct {
|
||||
|
@ -80,7 +80,7 @@ func (c *zfsCollector) constSysctlMetric(subsystem string, sysctl zfsSysctl, val
|
|||
|
||||
return prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, metricName),
|
||||
prometheus.BuildFQName(namespace, subsystem, metricName),
|
||||
string(sysctl),
|
||||
nil,
|
||||
nil,
|
||||
|
@ -95,7 +95,7 @@ func (c *zfsCollector) constPoolMetric(poolName string, sysctl zfsSysctl, value
|
|||
|
||||
return prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, "zfs_zpool", metricName),
|
||||
prometheus.BuildFQName(namespace, "zfs_zpool", metricName),
|
||||
string(sysctl),
|
||||
[]string{"zpool"},
|
||||
nil,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
set -euf -o pipefail
|
||||
|
||||
collectors=$(cat << COLLECTORS
|
||||
enabled_collectors=$(cat << COLLECTORS
|
||||
arp
|
||||
bcache
|
||||
buddyinfo
|
||||
|
@ -36,6 +36,14 @@ collectors=$(cat << COLLECTORS
|
|||
zfs
|
||||
COLLECTORS
|
||||
)
|
||||
disabled_collectors=$(cat << COLLECTORS
|
||||
filesystem
|
||||
time
|
||||
timex
|
||||
uname
|
||||
vmstat
|
||||
COLLECTORS
|
||||
)
|
||||
cd "$(dirname $0)"
|
||||
|
||||
port="$((10000 + (RANDOM % 10000)))"
|
||||
|
@ -74,13 +82,14 @@ then
|
|||
fi
|
||||
|
||||
./node_exporter \
|
||||
--collector.procfs="collector/fixtures/proc" \
|
||||
--collector.sysfs="collector/fixtures/sys" \
|
||||
--collectors.enabled="$(echo ${collectors} | tr ' ' ',')" \
|
||||
--path.procfs="collector/fixtures/proc" \
|
||||
--path.sysfs="collector/fixtures/sys" \
|
||||
$(for c in ${enabled_collectors}; do echo --collector.${c} ; done) \
|
||||
$(for c in ${disabled_collectors}; do echo --no-collector.${c} ; done) \
|
||||
--collector.textfile.directory="collector/fixtures/textfile/two_metric_files/" \
|
||||
--collector.megacli.command="collector/fixtures/megacli" \
|
||||
--collector.wifi="collector/fixtures/wifi" \
|
||||
--collector.qdisc="collector/fixtures/qdisc/" \
|
||||
--collector.wifi.fixtures="collector/fixtures/wifi" \
|
||||
--collector.qdisc.fixtures="collector/fixtures/qdisc/" \
|
||||
--web.listen-address "127.0.0.1:${port}" \
|
||||
--log.level="debug" > "${tmpdir}/node_exporter.log" 2>&1 &
|
||||
|
||||
|
|
115
node_exporter.go
115
node_exporter.go
|
@ -14,13 +14,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
@ -30,93 +25,6 @@ import (
|
|||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultCollectors = "arp,bcache,conntrack,cpu,diskstats,entropy,edac,exec,filefd,filesystem,hwmon,infiniband,ipvs,loadavg,mdadm,meminfo,netdev,netstat,sockstat,stat,textfile,time,timex,uname,vmstat,wifi,xfs,zfs"
|
||||
)
|
||||
|
||||
var (
|
||||
scrapeDurationDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(collector.Namespace, "scrape", "collector_duration_seconds"),
|
||||
"node_exporter: Duration of a collector scrape.",
|
||||
[]string{"collector"},
|
||||
nil,
|
||||
)
|
||||
scrapeSuccessDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(collector.Namespace, "scrape", "collector_success"),
|
||||
"node_exporter: Whether a collector succeeded.",
|
||||
[]string{"collector"},
|
||||
nil,
|
||||
)
|
||||
)
|
||||
|
||||
// NodeCollector implements the prometheus.Collector interface.
|
||||
type NodeCollector struct {
|
||||
collectors map[string]collector.Collector
|
||||
}
|
||||
|
||||
// Describe implements the prometheus.Collector interface.
|
||||
func (n NodeCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||
ch <- scrapeDurationDesc
|
||||
ch <- scrapeSuccessDesc
|
||||
}
|
||||
|
||||
// Collect implements the prometheus.Collector interface.
|
||||
func (n NodeCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(n.collectors))
|
||||
for name, c := range n.collectors {
|
||||
go func(name string, c collector.Collector) {
|
||||
execute(name, c, ch)
|
||||
wg.Done()
|
||||
}(name, c)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func filterAvailableCollectors(collectors string) string {
|
||||
var availableCollectors []string
|
||||
for _, c := range strings.Split(collectors, ",") {
|
||||
_, ok := collector.Factories[c]
|
||||
if ok {
|
||||
availableCollectors = append(availableCollectors, c)
|
||||
}
|
||||
}
|
||||
return strings.Join(availableCollectors, ",")
|
||||
}
|
||||
|
||||
func execute(name string, c collector.Collector, ch chan<- prometheus.Metric) {
|
||||
begin := time.Now()
|
||||
err := c.Update(ch)
|
||||
duration := time.Since(begin)
|
||||
var success float64
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("ERROR: %s collector failed after %fs: %s", name, duration.Seconds(), err)
|
||||
success = 0
|
||||
} else {
|
||||
log.Debugf("OK: %s collector succeeded after %fs.", name, duration.Seconds())
|
||||
success = 1
|
||||
}
|
||||
ch <- prometheus.MustNewConstMetric(scrapeDurationDesc, prometheus.GaugeValue, duration.Seconds(), name)
|
||||
ch <- prometheus.MustNewConstMetric(scrapeSuccessDesc, prometheus.GaugeValue, success, name)
|
||||
}
|
||||
|
||||
func loadCollectors(list string) (map[string]collector.Collector, error) {
|
||||
collectors := map[string]collector.Collector{}
|
||||
for _, name := range strings.Split(list, ",") {
|
||||
fn, ok := collector.Factories[name]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("collector '%s' not available", name)
|
||||
}
|
||||
c, err := fn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
collectors[name] = c
|
||||
}
|
||||
return collectors, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(version.NewCollector("node_exporter"))
|
||||
}
|
||||
|
@ -125,8 +33,6 @@ func main() {
|
|||
var (
|
||||
listenAddress = kingpin.Flag("web.listen-address", "Address on which to expose metrics and web interface.").Default(":9100").String()
|
||||
metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String()
|
||||
enabledCollectors = kingpin.Flag("collectors.enabled", "Comma-separated list of collectors to use.").Default(filterAvailableCollectors(defaultCollectors)).String()
|
||||
printCollectors = kingpin.Flag("collectors.print", "If true, print available collectors and exit.").Bool()
|
||||
)
|
||||
|
||||
log.AddFlags(kingpin.CommandLine)
|
||||
|
@ -137,29 +43,16 @@ func main() {
|
|||
log.Infoln("Starting node_exporter", version.Info())
|
||||
log.Infoln("Build context", version.BuildContext())
|
||||
|
||||
if *printCollectors {
|
||||
collectorNames := make(sort.StringSlice, 0, len(collector.Factories))
|
||||
for n := range collector.Factories {
|
||||
collectorNames = append(collectorNames, n)
|
||||
}
|
||||
collectorNames.Sort()
|
||||
fmt.Printf("Available collectors:\n")
|
||||
for _, n := range collectorNames {
|
||||
fmt.Printf(" - %s\n", n)
|
||||
}
|
||||
return
|
||||
}
|
||||
collectors, err := loadCollectors(*enabledCollectors)
|
||||
nc, err := collector.NewNodeCollector()
|
||||
if err != nil {
|
||||
log.Fatalf("Couldn't load collectors: %s", err)
|
||||
log.Fatalf("Couldn't create collector: %s", err)
|
||||
}
|
||||
|
||||
log.Infof("Enabled collectors:")
|
||||
for n := range collectors {
|
||||
for n := range nc.Collectors {
|
||||
log.Infof(" - %s", n)
|
||||
}
|
||||
|
||||
if err := prometheus.Register(NodeCollector{collectors: collectors}); err != nil {
|
||||
if err := prometheus.Register(nc); err != nil {
|
||||
log.Fatalf("Couldn't register collector: %s", err)
|
||||
}
|
||||
handler := promhttp.HandlerFor(prometheus.DefaultGatherer,
|
||||
|
|
Loading…
Reference in a new issue