Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions collector/fixtures/e2e-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ node_md_blocks{device="md4"} 4.883648e+06
node_md_blocks{device="md6"} 1.95310144e+08
node_md_blocks{device="md7"} 7.813735424e+09
node_md_blocks{device="md8"} 1.95310144e+08
node_md_blocks{device="md9"} 523968
# HELP node_md_blocks_synced Number of blocks synced on device.
# TYPE node_md_blocks_synced gauge
node_md_blocks_synced{device="md0"} 248896
Expand All @@ -435,6 +436,7 @@ node_md_blocks_synced{device="md4"} 4.883648e+06
node_md_blocks_synced{device="md6"} 1.6775552e+07
node_md_blocks_synced{device="md7"} 7.813735424e+09
node_md_blocks_synced{device="md8"} 1.6775552e+07
node_md_blocks_synced{device="md9"} 523968
# HELP node_md_disks Total number of disks of device.
# TYPE node_md_disks gauge
node_md_disks{device="md0"} 2
Expand All @@ -444,6 +446,7 @@ node_md_disks{device="md4"} 2
node_md_disks{device="md6"} 2
node_md_disks{device="md7"} 4
node_md_disks{device="md8"} 2
node_md_disks{device="md9"} 4
# HELP node_md_disks_active Number of active disks of device.
# TYPE node_md_disks_active gauge
node_md_disks_active{device="md0"} 2
Expand All @@ -453,6 +456,7 @@ node_md_disks_active{device="md4"} 2
node_md_disks_active{device="md6"} 1
node_md_disks_active{device="md7"} 3
node_md_disks_active{device="md8"} 2
node_md_disks_active{device="md9"} 4
# HELP node_md_is_active Indicator whether the md-device is active or not.
# TYPE node_md_is_active gauge
node_md_is_active{device="md0"} 1
Expand All @@ -462,6 +466,7 @@ node_md_is_active{device="md4"} 0
node_md_is_active{device="md6"} 1
node_md_is_active{device="md7"} 1
node_md_is_active{device="md8"} 1
node_md_is_active{device="md9"} 1
# HELP node_megacli_drive_count megacli: drive error and event counters
# TYPE node_megacli_drive_count counter
node_megacli_drive_count{enclosure="32",slot="0",type="Media Error Count"} 0
Expand Down
5 changes: 5 additions & 0 deletions collector/fixtures/proc/mdstat
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ md7 : active raid6 sdb1[0] sde1[3] sdd1[2] sdc1[1]
7813735424 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/3] [U_UU]
bitmap: 0/30 pages [0KB], 65536KB chunk

md9 : active raid1 sdc2[2] sdd2[3] sdb2[1] sda2[0]
523968 blocks super 1.2 [4/4] [UUUU]
resync=DELAYED


unused devices: <none>
2 changes: 1 addition & 1 deletion collector/mdadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func parseMdstat(mdStatusFilePath string) ([]mdStatus, error) {

// If device is syncing at the moment, get the number of currently synced bytes,
// otherwise that number equals the size of the device.
if strings.Contains(lines[j], "recovery") || strings.Contains(lines[j], "resync") {
if strings.Contains(lines[j], "recovery") || strings.Contains(lines[j], "resync") && ! strings.Contains(lines[j], "resync=DELAYED") {
syncedBlocks, err = evalBuildline(lines[j])
if err != nil {
return mdStates, fmt.Errorf("error parsing mdstat: %s", err)
Expand Down
1 change: 1 addition & 0 deletions collector/mdadm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestMdadm(t *testing.T) {
"md6": mdStatus{"md6", true, 1, 2, 195310144, 16775552},
"md8": mdStatus{"md8", true, 2, 2, 195310144, 16775552},
"md7": mdStatus{"md7", true, 3, 4, 7813735424, 7813735424},
"md9": mdStatus{"md9", true, 4, 4, 523968, 523968},
}

for _, md := range mdStates {
Expand Down
2 changes: 1 addition & 1 deletion collector/ntp.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewNtpCollector() (Collector, error) {
return nil, fmt.Errorf("no NTP server specifies, see --ntpServer")
}
if *ntpProtocolVersion < 2 || *ntpProtocolVersion > 4 {
return nil, fmt.Errorf("invalid NTP protocol version %d; must be 2, 3, or 4")
return nil, fmt.Errorf("invalid NTP protocol version %d; must be 2, 3, or 4", *ntpProtocolVersion)
}

return &ntpCollector{
Expand Down
17 changes: 15 additions & 2 deletions node_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ var (
memProfile = flag.String("debug.memprofile-file", "", "Write memory profile to this file upon receipt of SIGUSR1.")
listenAddress = flag.String("web.listen-address", ":9100", "Address on which to expose metrics and web interface.")
metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
enabledCollectors = flag.String("collectors.enabled", "diskstats,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,sockstat,stat,textfile,time,uname", "Comma-separated list of collectors to use.")
printCollectors = flag.Bool("collectors.print", false, "If true, print available collectors and exit.")
enabledCollectors = flag.String("collectors.enabled",
filterAvailableCollectors("diskstats,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,sockstat,stat,textfile,time,uname"),
"Comma-separated list of collectors to use.")
printCollectors = flag.Bool("collectors.print", false, "If true, print available collectors and exit.")

collectorLabelNames = []string{"collector", "result"}

Expand Down Expand Up @@ -81,6 +83,17 @@ func (n NodeCollector) Collect(ch chan<- prometheus.Metric) {
scrapeDurations.Collect(ch)
}

func filterAvailableCollectors(collectors string) string {
availableCollectors := make([]string, 0)
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)
Expand Down