Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Icinga2 input plugin #2668

Closed
wants to merge 0 commits into from
Closed

Conversation

mlabouardy
Copy link
Contributor

@mlabouardy mlabouardy commented Apr 13, 2017

Required for all PRs:

  • CHANGELOG.md updated (we recommend not updating this until the PR has been approved by a maintainer)
  • Sign CLA (if not already signed)
  • README.md updated (if adding a new plugin)

@mlabouardy mlabouardy changed the title Add support to icinga2 (input) Add support to icinga2 & Traefik (input) Apr 14, 2017
@mlabouardy mlabouardy changed the title Add support to icinga2 & Traefik (input) Add support to icinga2 (input) Apr 14, 2017
@mlabouardy mlabouardy changed the title Add support to icinga2 (input) Add Icinga2 input plugin Apr 19, 2017
@danielnelson danielnelson added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Aug 24, 2017
@mlabouardy
Copy link
Contributor Author

@danielnelson any news ?

type ObjectType string

var sampleConfig = `
## Required Icinga2 server address (default: "https://localhost:5665")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two space indent.


tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a single transport that is scoped to the Icinga2 struct, instead of created each Gather. This will prevent connections being closed


tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we disabling ssl verification? Should we make this configurable:

  ## Optional SSL Config
  # ssl_ca = "/etc/telegraf/ca.pem"
  # ssl_cert = "/etc/telegraf/cert.pem"
  # ssl_key = "/etc/telegraf/key.pem"
  ## Use SSL but skip chain & host verification
  # insecure_skip_verify = false

Check the apache input for an example.


client := &http.Client{Transport: tr}

url := fmt.Sprintf("%s/v1/objects/%s?attrs=name&attrs=display_name&attrs=state&attrs=check_command", s.Server, s.Filter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to use the url package to construct the url, It looks like you could do a lot of this only once.

url := fmt.Sprintf("%s/v1/objects/%s?attrs=name&attrs=display_name&attrs=state&attrs=check_command", s.Server, s.Filter)

req, err := http.NewRequest("GET", url, nil)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add whitespace between the call and checking the error throughout the pr.

tags := make(map[string]string)

record["name"] = check.Attrs.Name
record["status"] = check.Attrs.State
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call this field state since that is the name in Icinga?

record := make(map[string]interface{})
tags := make(map[string]string)

record["name"] = check.Attrs.Name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the name should be a tag? I see in the tests one of the values has a uuid: eq-par.dc2.fr!ef017af8-c684-4f3f-bb20-0dfe9fcd3dbe, how unique must this be and how often would this value change? Is it always a uuid or this is this just an artifact of your setup?


func (s *Icinga2) GatherStatus(acc telegraf.Accumulator, checks []Object) {
for _, check := range checks {
record := make(map[string]interface{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call this variable fields

CheckCommand string `json:"check_command"`
DisplayName string `json:"display_name"`
Name string `json:"name"`
State float32 `json:"state"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an int?

## Icing2 Endpoint
server = "https://127.0.0.1:5665"
## Required Icinga2 object type ("services" or "hosts, default "services")
filter = "services"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work for any object type, or just services and hosts?

@danielnelson danielnelson mentioned this pull request Apr 11, 2018
3 tasks
@russorat russorat added this to the 1.8.0 milestone Jun 21, 2018
@glinton
Copy link
Contributor

glinton commented Aug 14, 2018

@mlabouardy Do you have time to address the feedback provided by daniel?

@mlabouardy
Copy link
Contributor Author

@glinton yes, I will work on it today

@mlabouardy
Copy link
Contributor Author

I just closed by mistake, can we open it again

@mlabouardy
Copy link
Contributor Author

@danielnelson @glinton I just opened a new one with the required fixes, sorry guys: #4559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin new plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants