Fixing format with gofmt

This commit is contained in:
Thomas Roehl 2021-03-25 17:47:08 +01:00
parent e9a74a4c9c
commit f32ff9d006
9 changed files with 310 additions and 325 deletions

View File

@ -5,8 +5,8 @@ import (
"io/ioutil"
"log"
"os/exec"
"strings"
"strconv"
"strings"
"time"
)

View File

@ -1,4 +1,5 @@
package main
/*
#cgo CFLAGS: -I.
#cgo LDFLAGS: -L. -llikwid -llikwid-hwloc -lm
@ -11,7 +12,7 @@ import "unsafe"
func main() {
var topo C.CpuTopology_t
C.topology_init();
C.topology_init()
topo = C.get_cpuTopology()
cpulist := make([]C.int, topo.numHWThreads)
for a := 0; a < int(topo.numHWThreads); a++ {
@ -27,5 +28,5 @@ func main() {
fmt.Println(v)
C.free(unsafe.Pointer(gstring))
C.perfmon_finalize()
C.topology_finalize();
C.topology_finalize()
}

View File

@ -1,4 +1,5 @@
package collectors
/*
#cgo CFLAGS: -I./likwid
#cgo LDFLAGS: -L./likwid -llikwid -llikwid-hwloc -lm
@ -12,16 +13,14 @@ import (
// "io/ioutil"
// "log"
// "strconv"
"strings"
"fmt"
"log"
"strings"
"time"
"unsafe"
"log"
//protocol "github.com/influxdata/line-protocol"
)
type LikwidCollector struct {
MetricCollector
cpulist []C.int
@ -50,7 +49,6 @@ var likwid_metrics = map[string][]LikwidMetric{
LikwidMetric{name: "flops_sp", search: "SP [MFLOP/s]", socket_scope: false}},
}
func getMetricId(group C.int, search string) (int, error) {
for i := 0; i < int(C.perfmon_getNumberOfMetrics(group)); i++ {
mname := C.perfmon_getMetricName(group, C.int(i))
@ -77,7 +75,6 @@ func getSocketCpus() map[C.int]int {
return outmap
}
func (m *LikwidCollector) Init() {
m.name = "LikwidCollector"
m.setup()
@ -143,14 +140,14 @@ func (m *LikwidCollector) Read(interval time.Duration){
}
}
}
for cpu, _ := range m.cpus {
for cpu := range m.cpus {
if flops_dp, found := m.cpus[cpu]["flops_dp"]; found {
if flops_sp, found := m.cpus[cpu]["flops_sp"]; found {
m.cpus[cpu]["flops_any"] = flops_dp.(float64) + flops_sp.(float64)
}
}
}
for sid, _ := range m.sockets {
for sid := range m.sockets {
if pwr1, found := m.sockets[int(sid)]["pwr1"]; found {
if pwr2, found := m.sockets[int(sid)]["pwr2"]; found {
sum := pwr1.(float64) + pwr2.(float64)

View File

@ -3,8 +3,8 @@ package collectors
import (
"io/ioutil"
"strconv"
"time"
"strings"
"time"
)
const LOADAVGFILE = `/proc/loadavg`
@ -13,7 +13,6 @@ type LoadavgCollector struct {
MetricCollector
}
func (m *LoadavgCollector) Init() {
m.name = "LoadavgCollector"
m.setup()

View File

@ -15,7 +15,6 @@ type LustreCollector struct {
MetricCollector
}
func (m *LustreCollector) Init() {
m.name = "LustreCollector"
m.setup()

View File

@ -7,7 +7,6 @@ import (
"strconv"
"strings"
"time"
//protocol "github.com/influxdata/line-protocol"
)
@ -17,7 +16,6 @@ type MemstatCollector struct {
MetricCollector
}
func (m *MemstatCollector) Init() {
m.name = "MemstatCollector"
m.setup()

View File

@ -1,11 +1,11 @@
package collectors
import (
"time"
"io/ioutil"
"strings"
"log"
"strconv"
"strings"
"time"
)
type MetricGetter interface {
@ -25,8 +25,6 @@ type MetricCollector struct {
cpus map[int]map[string]interface{}
}
func (c *MetricCollector) Name() string {
return c.name
}
@ -58,7 +56,6 @@ func (c *MetricCollector) setup() error {
return nil
}
func intArrayContains(array []int, str int) (int, bool) {
for i, a := range array {
if a == str {

View File

@ -1,12 +1,12 @@
package collectors
import (
"fmt"
"io/ioutil"
"log"
"strconv"
"strings"
"time"
"log"
"fmt"
)
const NETSTATFILE = `/proc/net/dev`
@ -15,7 +15,6 @@ type NetstatCollector struct {
MetricCollector
}
func (m *NetstatCollector) Init() {
m.name = "NetstatCollector"
m.setup()

View File

@ -3,13 +3,13 @@ package main
import (
"encoding/json"
"fmt"
"github.com/ClusterCockpit/cc-metric-collector/collectors"
protocol "github.com/influxdata/line-protocol"
"log"
"os"
"os/signal"
"sync"
"time"
"github.com/ClusterCockpit/cc-metric-collector/collectors"
protocol "github.com/influxdata/line-protocol"
)
var Collectors = map[string]collectors.MetricGetter{
@ -20,6 +20,7 @@ var Collectors = map[string]collectors.MetricGetter{
"ibstat": &collectors.InfinibandCollector{},
"lustrestat": &collectors.LustreCollector{},
}
type GlobalConfig struct {
Sink struct {
User string `json:"user"`
@ -32,8 +33,6 @@ type GlobalConfig struct {
Collectors []string `json:"collectors"`
}
func LoadConfiguration(file string, config *GlobalConfig) error {
configFile, err := os.Open(file)
defer configFile.Close()
@ -45,8 +44,6 @@ func LoadConfiguration(file string, config *GlobalConfig) error {
return err
}
func shutdown(wg *sync.WaitGroup, config *GlobalConfig) {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, os.Interrupt)
@ -115,7 +112,6 @@ func main() {
return
case t := <-ticker.C:
scount := 0
ccount := 0
for _, c := range config.Collectors {
@ -178,6 +174,5 @@ func main() {
}
}()
wg.Wait()
}