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

Option to specify Nagios fields from environment variables #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

divtxt
Copy link

@divtxt divtxt commented Mar 18, 2015

@mdcollins05 - please try this out.

  • fields sent by -f FOO="$FOO" via command_line can also be sent by -e FOO
  • requires enable env vars to be set

I just picked -e/--env-field - other suggestions welcome

cc @chamblin

@mdcollins05
Copy link
Contributor

I tested it out and it works as advertised! It handles quotes with no problems now.

Thanks!

@divtxt
Copy link
Author

divtxt commented Mar 23, 2015

Added ICINGA support

v = os.environ.get("NAGIOS_%s" % f)
if v is None:
v = os.environ.get("ICINGA_%s" % f)
if v is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

should we just do something like this instead?

if v is not None:
  details[f] = v

Otherwise, I imagine we'll be creating events with some "" => "" details fields.

Copy link
Author

Choose a reason for hiding this comment

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

Could do. Though I'm not sure you'd get a blank key? I was leaning towards always sending the field even if the value is blank so that the user knows there's no bug in the pd parts of the stack.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. Yeah, this seems good.

Copy link
Author

Choose a reason for hiding this comment

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

I'll add a comment explaning!

return
from os import environ
for f in env_fields:
details[f] = environ.get("NAGIOS_%s" % f) or environ.get("ICINGA_%s" % f) or ""
Copy link
Author

Choose a reason for hiding this comment

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

@chamblin
Copy link
Contributor

Nice! :shipit:

@divtxt
Copy link
Author

divtxt commented Mar 24, 2015

@mdcollins05 - would appreciate it if you can test the latest version on aws. (icinga testing too if that's easy) No rush.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants