mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-12 21:17:25 +01:00
Reformat, remove x bit on memavg Collector
This commit is contained in:
parent
9597798ebc
commit
4519632ef2
@ -4,14 +4,17 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
//"bytes"
|
//"bytes"
|
||||||
// "context"
|
// "context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
//"sort"
|
//"sort"
|
||||||
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"errors"
|
|
||||||
protocol "github.com/influxdata/line-protocol"
|
protocol "github.com/influxdata/line-protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -81,7 +84,6 @@ func LoadCollectorConfiguration(file string, config *CollectorConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// Load collector configurations
|
// Load collector configurations
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -109,7 +111,6 @@ func GetCollectorFolders(root string, folders *[]string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// Setup all collectors
|
// Setup all collectors
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -132,7 +133,6 @@ func SetupCollectors(config GlobalConfig) ([]InternalCollectorConfig, error) {
|
|||||||
return outconfig, nil
|
return outconfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// Run collector
|
// Run collector
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -171,7 +171,9 @@ func RunCollector(config InternalCollectorConfig) ([]string, error) {
|
|||||||
lines := strings.Split(string(stdout), "\n")
|
lines := strings.Split(string(stdout), "\n")
|
||||||
|
|
||||||
for _, l := range lines {
|
for _, l := range lines {
|
||||||
if strings.HasPrefix(l, "#") { continue }
|
if strings.HasPrefix(l, "#") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
results = append(results, l)
|
results = append(results, l)
|
||||||
}
|
}
|
||||||
return results, err
|
return results, err
|
||||||
@ -189,11 +191,11 @@ func SetupSink(config GlobalConfig) chan string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RunSink(config GlobalConfig, queue *chan string) (*time.Ticker, chan bool) {
|
func RunSink(config GlobalConfig, queue *chan string) (*time.Ticker, chan bool) {
|
||||||
var interval time.Duration
|
|
||||||
|
|
||||||
interval = time.Duration(config.Report.Interval) * time.Second
|
interval := time.Duration(config.Report.Interval) * time.Second
|
||||||
ticker := time.NewTicker(interval)
|
ticker := time.NewTicker(interval)
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -229,19 +231,17 @@ func CloseSink(config GlobalConfig, queue *chan string, ticker *time.Ticker, don
|
|||||||
close(*queue)
|
close(*queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func MainLoop(config GlobalConfig, sink *chan string) (*time.Ticker, chan bool) {
|
func MainLoop(config GlobalConfig, sink *chan string) (*time.Ticker, chan bool) {
|
||||||
var intConfig []InternalCollectorConfig
|
var intConfig []InternalCollectorConfig
|
||||||
intConfig, err := SetupCollectors(config)
|
intConfig, err := SetupCollectors(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
var interval time.Duration
|
|
||||||
|
|
||||||
interval = time.Duration(config.Schedule.Node.Frequency) * time.Second
|
|
||||||
|
|
||||||
|
interval := time.Duration(config.Schedule.Node.Frequency) * time.Second
|
||||||
ticker := time.NewTicker(time.Second)
|
ticker := time.NewTicker(time.Second)
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
0
collectors/memavg/read_memavg.go
Executable file → Normal file
0
collectors/memavg/read_memavg.go
Executable file → Normal file
Loading…
Reference in New Issue
Block a user