Skip to content

Commit

Permalink
code refactor for plugin jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Aug 2, 2022
1 parent f240e30 commit 138850d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
9 changes: 0 additions & 9 deletions conf/input.jenkins/jenkins.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
# # collect interval
# interval = 15

############################################################################
# !!! uncomment [[instances]] to enable this plugin
[[instances]]
# # interval = global.interval * interval_times
# interval_times = 1

# append some labels to metrics



# Address (host:port) of jenkins server.
# jenkins_url = "http://my-jenkins-instance:8080"

Expand Down
19 changes: 7 additions & 12 deletions inputs/jenkins/jenkins.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ func init() {
})
}

func (pt *Jenkins) Prefix() string { return inputName }
func (pt *Jenkins) Init() error { return nil }
func (pt *Jenkins) Drop() {}
func (pt *Jenkins) Gather(slist *types.SampleList) {}

func (pt *Jenkins) GetInstances() []inputs.Instance {
ret := make([]inputs.Instance, len(pt.Instances))
for i := 0; i < len(pt.Instances); i++ {
ret[i] = pt.Instances[i]
func (j *Jenkins) GetInstances() []inputs.Instance {
ret := make([]inputs.Instance, len(j.Instances))
for i := 0; i < len(j.Instances); i++ {
ret[i] = j.Instances[i]
}
return ret
}
Expand Down Expand Up @@ -85,18 +80,18 @@ func (ins *Instance) Gather(slist *types.SampleList) {
if ins.client == nil {
client, err := ins.newHTTPClient()
if err != nil {
log.Println("E! failed to new HTTPClient", err)
log.Println("E! failed to new HTTPClient:", err)
return
}

if err = ins.initialize(client); err != nil {
log.Println("E! failed to initialize", err)
log.Println("E! failed to initialize:", err)
return
}
}

ins.gatherNodesData(slist)
ins.gatherJobs(slist)

}

/////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 138850d

Please sign in to comment.