Skip to content

Commit

Permalink
Avoid vet warning struct field commands has json tag but is not exported
Browse files Browse the repository at this point in the history
  • Loading branch information
ho-ob committed Jan 25, 2022
1 parent df77c3f commit 222862a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions collectors/customCmdMetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
const CUSTOMCMDPATH = `/home/unrz139/Work/cc-metric-collector/collectors/custom`

type CustomCmdCollectorConfig struct {
commands []string `json:"commands"`
files []string `json:"files"`
Commands []string `json:"commands"`
Files []string `json:"files"`
ExcludeMetrics []string `json:"exclude_metrics"`
}

Expand All @@ -40,7 +40,7 @@ func (m *CustomCmdCollector) Init(config []byte) error {
}
}
m.setup()
for _, c := range m.config.commands {
for _, c := range m.config.Commands {
cmdfields := strings.Fields(c)
command := exec.Command(cmdfields[0], strings.Join(cmdfields[1:], " "))
command.Wait()
Expand All @@ -49,7 +49,7 @@ func (m *CustomCmdCollector) Init(config []byte) error {
m.commands = append(m.commands, c)
}
}
for _, f := range m.config.files {
for _, f := range m.config.Files {
_, err = ioutil.ReadFile(f)
if err == nil {
m.files = append(m.files, f)
Expand Down
4 changes: 2 additions & 2 deletions collectors/lustreMetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
const LUSTREFILE = `/proc/fs/lustre/llite/lnec-XXXXXX/stats`

type LustreCollectorConfig struct {
procfiles []string `json:"procfiles"`
Procfiles []string `json:"procfiles"`
ExcludeMetrics []string `json:"exclude_metrics"`
}

Expand Down Expand Up @@ -47,7 +47,7 @@ func (m *LustreCollector) Init(config []byte) error {
"statfs": {"statfs": 1},
"inode_permission": {"inode_permission": 1}}
m.devices = make([]string, 0)
for _, p := range m.config.procfiles {
for _, p := range m.config.Procfiles {
_, err := ioutil.ReadFile(p)
if err == nil {
m.devices = append(m.devices, p)
Expand Down
8 changes: 4 additions & 4 deletions collectors/topprocsMetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MAX_NUM_PROCS = 10
const DEFAULT_NUM_PROCS = 2

type TopProcsCollectorConfig struct {
num_procs int `json:"num_procs"`
Num_procs int `json:"num_procs"`
}

type TopProcsCollector struct {
Expand All @@ -35,9 +35,9 @@ func (m *TopProcsCollector) Init(config []byte) error {
return err
}
} 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))
}
m.setup()
Expand All @@ -64,7 +64,7 @@ func (m *TopProcsCollector) Read(interval time.Duration, out *[]lp.MutableMetric
}

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)
y, err := lp.New(name, m.tags, map[string]interface{}{"value": string(lines[i])}, time.Now())
if err == nil {
Expand Down

0 comments on commit 222862a

Please sign in to comment.