mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 23:19:06 +01:00
Avoid vet warning struct field commands has json tag but is not exported
This commit is contained in:
parent
9f8d3ddbd3
commit
d903fc6daa
@ -15,8 +15,8 @@ import (
|
|||||||
const CUSTOMCMDPATH = `/home/unrz139/Work/cc-metric-collector/collectors/custom`
|
const CUSTOMCMDPATH = `/home/unrz139/Work/cc-metric-collector/collectors/custom`
|
||||||
|
|
||||||
type CustomCmdCollectorConfig struct {
|
type CustomCmdCollectorConfig struct {
|
||||||
commands []string `json:"commands"`
|
Commands []string `json:"commands"`
|
||||||
files []string `json:"files"`
|
Files []string `json:"files"`
|
||||||
ExcludeMetrics []string `json:"exclude_metrics"`
|
ExcludeMetrics []string `json:"exclude_metrics"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ func (m *CustomCmdCollector) Init(config []byte) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.setup()
|
m.setup()
|
||||||
for _, c := range m.config.commands {
|
for _, c := range m.config.Commands {
|
||||||
cmdfields := strings.Fields(c)
|
cmdfields := strings.Fields(c)
|
||||||
command := exec.Command(cmdfields[0], strings.Join(cmdfields[1:], " "))
|
command := exec.Command(cmdfields[0], strings.Join(cmdfields[1:], " "))
|
||||||
command.Wait()
|
command.Wait()
|
||||||
@ -49,7 +49,7 @@ func (m *CustomCmdCollector) Init(config []byte) error {
|
|||||||
m.commands = append(m.commands, c)
|
m.commands = append(m.commands, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, f := range m.config.files {
|
for _, f := range m.config.Files {
|
||||||
_, err = ioutil.ReadFile(f)
|
_, err = ioutil.ReadFile(f)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
m.files = append(m.files, f)
|
m.files = append(m.files, f)
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
const LUSTREFILE = `/proc/fs/lustre/llite/lnec-XXXXXX/stats`
|
const LUSTREFILE = `/proc/fs/lustre/llite/lnec-XXXXXX/stats`
|
||||||
|
|
||||||
type LustreCollectorConfig struct {
|
type LustreCollectorConfig struct {
|
||||||
procfiles []string `json:"procfiles"`
|
Procfiles []string `json:"procfiles"`
|
||||||
ExcludeMetrics []string `json:"exclude_metrics"`
|
ExcludeMetrics []string `json:"exclude_metrics"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func (m *LustreCollector) Init(config []byte) error {
|
|||||||
"statfs": {"statfs": 1},
|
"statfs": {"statfs": 1},
|
||||||
"inode_permission": {"inode_permission": 1}}
|
"inode_permission": {"inode_permission": 1}}
|
||||||
m.devices = make([]string, 0)
|
m.devices = make([]string, 0)
|
||||||
for _, p := range m.config.procfiles {
|
for _, p := range m.config.Procfiles {
|
||||||
_, err := ioutil.ReadFile(p)
|
_, err := ioutil.ReadFile(p)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
m.devices = append(m.devices, p)
|
m.devices = append(m.devices, p)
|
||||||
|
@ -16,7 +16,7 @@ const MAX_NUM_PROCS = 10
|
|||||||
const DEFAULT_NUM_PROCS = 2
|
const DEFAULT_NUM_PROCS = 2
|
||||||
|
|
||||||
type TopProcsCollectorConfig struct {
|
type TopProcsCollectorConfig struct {
|
||||||
num_procs int `json:"num_procs"`
|
Num_procs int `json:"num_procs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TopProcsCollector struct {
|
type TopProcsCollector struct {
|
||||||
@ -35,9 +35,9 @@ func (m *TopProcsCollector) Init(config []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m.config.num_procs = int(DEFAULT_NUM_PROCS)
|
m.config.Num_procs = int(DEFAULT_NUM_PROCS)
|
||||||
}
|
}
|
||||||
if m.config.num_procs <= 0 || m.config.num_procs > MAX_NUM_PROCS {
|
if m.config.Num_procs <= 0 || m.config.Num_procs > MAX_NUM_PROCS {
|
||||||
return errors.New(fmt.Sprintf("num_procs option must be set in 'topprocs' config (range: 1-%d)", MAX_NUM_PROCS))
|
return errors.New(fmt.Sprintf("num_procs option must be set in 'topprocs' config (range: 1-%d)", MAX_NUM_PROCS))
|
||||||
}
|
}
|
||||||
m.setup()
|
m.setup()
|
||||||
@ -64,7 +64,7 @@ func (m *TopProcsCollector) Read(interval time.Duration, out *[]lp.MutableMetric
|
|||||||
}
|
}
|
||||||
|
|
||||||
lines := strings.Split(string(stdout), "\n")
|
lines := strings.Split(string(stdout), "\n")
|
||||||
for i := 1; i < m.config.num_procs+1; i++ {
|
for i := 1; i < m.config.Num_procs+1; i++ {
|
||||||
name := fmt.Sprintf("topproc%d", i)
|
name := fmt.Sprintf("topproc%d", i)
|
||||||
y, err := lp.New(name, m.tags, map[string]interface{}{"value": string(lines[i])}, time.Now())
|
y, err := lp.New(name, m.tags, map[string]interface{}{"value": string(lines[i])}, time.Now())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user