mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-16 09:55:56 +02:00
Formatting
This commit is contained in:
parent
988cea381e
commit
a6feb16ec1
1
Makefile
1
Makefile
@ -16,5 +16,6 @@ fmt:
|
|||||||
go fmt sinks/*.go
|
go fmt sinks/*.go
|
||||||
go fmt receivers/*.go
|
go fmt receivers/*.go
|
||||||
go fmt metric-collector.go
|
go fmt metric-collector.go
|
||||||
|
find . -name "*.go" -exec go fmt {} \;
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package collectors
|
package collectors
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
"sync"
|
mct "github.com/ClusterCockpit/cc-metric-collector/internal/multiChanTicker"
|
||||||
"time"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"encoding/json"
|
"sync"
|
||||||
mct "github.com/ClusterCockpit/cc-metric-collector/internal/multiChanTicker"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
var AvailableCollectors = map[string]MetricCollector{
|
var AvailableCollectors = map[string]MetricCollector{
|
||||||
"likwid": &LikwidCollector{},
|
"likwid": &LikwidCollector{},
|
||||||
"loadavg": &LoadavgCollector{},
|
"loadavg": &LoadavgCollector{},
|
||||||
@ -27,7 +26,6 @@ var AvailableCollectors = map[string]MetricCollector{
|
|||||||
"ipmistat": &IpmiCollector{},
|
"ipmistat": &IpmiCollector{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type collectorManager struct {
|
type collectorManager struct {
|
||||||
collectors []MetricCollector
|
collectors []MetricCollector
|
||||||
output chan lp.CCMetric
|
output chan lp.CCMetric
|
||||||
@ -45,7 +43,6 @@ type CollectorManager interface {
|
|||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (cm *collectorManager) Init(ticker mct.MultiChanTicker, duration time.Duration, wg *sync.WaitGroup, collectConfigFile string) error {
|
func (cm *collectorManager) Init(ticker mct.MultiChanTicker, duration time.Duration, wg *sync.WaitGroup, collectConfigFile string) error {
|
||||||
cm.collectors = make([]MetricCollector, 0)
|
cm.collectors = make([]MetricCollector, 0)
|
||||||
cm.output = nil
|
cm.output = nil
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package collectors
|
package collectors
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
influx "github.com/influxdata/line-protocol"
|
influx "github.com/influxdata/line-protocol"
|
||||||
@ -9,7 +10,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"encoding/json"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MetricCollector interface {
|
type MetricCollector interface {
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/NVIDIA/go-nvml/pkg/nvml"
|
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
|
"github.com/NVIDIA/go-nvml/pkg/nvml"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -5,12 +5,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const HWMON_PATH = `/sys/class/hwmon`
|
const HWMON_PATH = `/sys/class/hwmon`
|
||||||
|
1
go.sum
1
go.sum
@ -1,7 +1,6 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
|
||||||
github.com/NVIDIA/go-nvml v0.11.1-0 h1:XHSz3zZKC4NCP2ja1rI7++DXFhA+uDhdYa3MykCTGHY=
|
github.com/NVIDIA/go-nvml v0.11.1-0 h1:XHSz3zZKC4NCP2ja1rI7++DXFhA+uDhdYa3MykCTGHY=
|
||||||
github.com/NVIDIA/go-nvml v0.11.1-0/go.mod h1:hy7HYeQy335x6nEss0Ne3PYqleRa6Ct+VKD9RQ4nyFs=
|
github.com/NVIDIA/go-nvml v0.11.1-0/go.mod h1:hy7HYeQy335x6nEss0Ne3PYqleRa6Ct+VKD9RQ4nyFs=
|
||||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package ccmetric
|
package ccmetric
|
||||||
|
|
||||||
import (
|
import (
|
||||||
lp "github.com/influxdata/line-protocol" // MIT license
|
|
||||||
"time"
|
|
||||||
"sort"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
lp "github.com/influxdata/line-protocol" // MIT license
|
||||||
|
"sort"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Most functions are derived from github.com/influxdata/line-protocol/metric.go
|
// Most functions are derived from github.com/influxdata/line-protocol/metric.go
|
||||||
@ -187,9 +187,6 @@ func (m *ccMetric) AddField(key string, value interface{}) {
|
|||||||
m.fields = append(m.fields, &lp.Field{Key: key, Value: convertField(value)})
|
m.fields = append(m.fields, &lp.Field{Key: key, Value: convertField(value)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func New(
|
func New(
|
||||||
name string,
|
name string,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package metricRouter
|
package metricRouter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
|
||||||
"sync"
|
|
||||||
"log"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
"time"
|
|
||||||
"gopkg.in/Knetic/govaluate.v2"
|
|
||||||
mct "github.com/ClusterCockpit/cc-metric-collector/internal/multiChanTicker"
|
mct "github.com/ClusterCockpit/cc-metric-collector/internal/multiChanTicker"
|
||||||
|
"gopkg.in/Knetic/govaluate.v2"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type metricRounterTagConfig struct {
|
type metricRounterTagConfig struct {
|
||||||
@ -41,7 +41,6 @@ type MetricRouter interface {
|
|||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (r *metricRouter) Init(ticker mct.MultiChanTicker, wg *sync.WaitGroup, routerConfigFile string) error {
|
func (r *metricRouter) Init(ticker mct.MultiChanTicker, wg *sync.WaitGroup, routerConfigFile string) error {
|
||||||
r.inputs = make([]chan lp.CCMetric, 0)
|
r.inputs = make([]chan lp.CCMetric, 0)
|
||||||
r.outputs = make([]chan lp.CCMetric, 0)
|
r.outputs = make([]chan lp.CCMetric, 0)
|
||||||
|
@ -11,11 +11,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
// "strings"
|
// "strings"
|
||||||
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
|
mr "github.com/ClusterCockpit/cc-metric-collector/internal/metricRouter"
|
||||||
|
mct "github.com/ClusterCockpit/cc-metric-collector/internal/multiChanTicker"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
mr "github.com/ClusterCockpit/cc-metric-collector/internal/metricRouter"
|
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
|
||||||
mct "github.com/ClusterCockpit/cc-metric-collector/internal/multiChanTicker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// List of provided collectors. Which collector should be run can be
|
// List of provided collectors. Which collector should be run can be
|
||||||
@ -238,7 +238,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
rcfg.Duration = time.Duration(rcfg.ConfigFile.Duration) * time.Second
|
rcfg.Duration = time.Duration(rcfg.ConfigFile.Duration) * time.Second
|
||||||
|
|
||||||
|
|
||||||
rcfg.Hostname, err = os.Hostname()
|
rcfg.Hostname, err = os.Hostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err.Error())
|
log.Print(err.Error())
|
||||||
|
@ -2,9 +2,8 @@ package receivers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
// "time"
|
// "time"
|
||||||
influx "github.com/influxdata/line-protocol"
|
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
|
influx "github.com/influxdata/line-protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReceiverConfig struct {
|
type ReceiverConfig struct {
|
||||||
|
@ -2,12 +2,12 @@ package receivers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
influx "github.com/influxdata/line-protocol"
|
"fmt"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
|
influx "github.com/influxdata/line-protocol"
|
||||||
nats "github.com/nats-io/nats.go"
|
nats "github.com/nats-io/nats.go"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type NatsReceiverConfig struct {
|
type NatsReceiverConfig struct {
|
||||||
@ -89,4 +89,3 @@ func (r *NatsReceiver) Close() {
|
|||||||
r.nc.Close()
|
r.nc.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
package receivers
|
package receivers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
"sync"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"encoding/json"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
var AvailableReceivers = map[string]Receiver{
|
var AvailableReceivers = map[string]Receiver{
|
||||||
"nats": &NatsReceiver{},
|
"nats": &NatsReceiver{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type receiveManager struct {
|
type receiveManager struct {
|
||||||
inputs []Receiver
|
inputs []Receiver
|
||||||
output chan lp.CCMetric
|
output chan lp.CCMetric
|
||||||
@ -29,7 +28,6 @@ type ReceiveManager interface {
|
|||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (rm *receiveManager) Init(wg *sync.WaitGroup, receiverConfigFile string) error {
|
func (rm *receiveManager) Init(wg *sync.WaitGroup, receiverConfigFile string) error {
|
||||||
rm.inputs = make([]Receiver, 0)
|
rm.inputs = make([]Receiver, 0)
|
||||||
rm.output = nil
|
rm.output = nil
|
||||||
@ -67,7 +65,6 @@ func (rm *receiveManager) Init(wg *sync.WaitGroup, receiverConfigFile string) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (rm *receiveManager) Start() {
|
func (rm *receiveManager) Start() {
|
||||||
rm.wg.Add(1)
|
rm.wg.Add(1)
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
influx "github.com/influxdata/line-protocol"
|
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
|
influx "github.com/influxdata/line-protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HttpSink struct {
|
type HttpSink struct {
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
influx "github.com/influxdata/line-protocol"
|
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
|
influx "github.com/influxdata/line-protocol"
|
||||||
nats "github.com/nats-io/nats.go"
|
nats "github.com/nats-io/nats.go"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package sinks
|
package sinks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
"sync"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"encoding/json"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type SinkEntity struct {
|
type SinkEntity struct {
|
||||||
config json.RawMessage
|
config json.RawMessage
|
||||||
output Sink
|
output Sink
|
||||||
@ -21,7 +20,6 @@ var AvailableSinks = map[string]Sink{
|
|||||||
"http": &HttpSink{},
|
"http": &HttpSink{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type sinkManager struct {
|
type sinkManager struct {
|
||||||
input chan lp.CCMetric
|
input chan lp.CCMetric
|
||||||
outputs []Sink
|
outputs []Sink
|
||||||
@ -38,7 +36,6 @@ type SinkManager interface {
|
|||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (sm *sinkManager) Init(wg *sync.WaitGroup, sinkConfigFile string) error {
|
func (sm *sinkManager) Init(wg *sync.WaitGroup, sinkConfigFile string) error {
|
||||||
sm.input = nil
|
sm.input = nil
|
||||||
sm.outputs = make([]Sink, 0)
|
sm.outputs = make([]Sink, 0)
|
||||||
@ -69,8 +66,6 @@ func (sm *sinkManager) Init(wg *sync.WaitGroup, sinkConfigFile string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (sm *sinkManager) Start() {
|
func (sm *sinkManager) Start() {
|
||||||
sm.wg.Add(1)
|
sm.wg.Add(1)
|
||||||
batchcount := 20
|
batchcount := 20
|
||||||
@ -90,7 +85,7 @@ SinkManagerLoop:
|
|||||||
for _, s := range sm.outputs {
|
for _, s := range sm.outputs {
|
||||||
s.Write(p)
|
s.Write(p)
|
||||||
}
|
}
|
||||||
if (batchcount == 0) {
|
if batchcount == 0 {
|
||||||
log.Print("[SinkManager] FLUSH")
|
log.Print("[SinkManager] FLUSH")
|
||||||
for _, s := range sm.outputs {
|
for _, s := range sm.outputs {
|
||||||
s.Flush()
|
s.Flush()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user