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 support for logging to a file #226

Open
atc0005 opened this issue Apr 7, 2022 · 2 comments
Open

Add support for logging to a file #226

atc0005 opened this issue Apr 7, 2022 · 2 comments
Assignees
Labels
command-line config documentation Improvements or additions to documentation enhancement New feature or request logging
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Apr 7, 2022

This could be useful for troubleshooting messages delivered by another tool such as Nagios Core that (afaik) doesn't capture output from executed notification commands.

@atc0005 atc0005 added documentation Improvements or additions to documentation enhancement New feature or request command-line logging config labels Apr 7, 2022
@atc0005 atc0005 added this to the Future milestone Apr 7, 2022
@atc0005 atc0005 self-assigned this Apr 7, 2022
@atc0005
Copy link
Owner Author

atc0005 commented Apr 7, 2022

Note: Have example use the same directory as the value for log_file from nagios.cfg.

For example:

# LOG FILE
# This is the main log file where service and host events are logged
# for historical purposes.  This should be the first option specified 
# in the config file!!!

log_file=/var/log/nagios3/nagios.log

In our case, /var/log/nagios3/send2teams.log should be the fully-qualified log file path used in the example(s). Specifying /tmp/send2teams.log may not work for Nagios' purposes unless SELinux or AppArmor policy changes are applied to permit that access.

@atc0005
Copy link
Owner Author

atc0005 commented Apr 9, 2022

Snippet used for debugging/troubleshooting work on #225:

	f, err := os.OpenFile("/var/log/nagios3/send2teams.log",
		os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
	if err != nil {
		log.Println(err)
	}

	defer f.Close()
	log.SetOutput(f)

Needs work:

  • permissions adjustment
  • handle error from f.Close()

The fixed path/filename would be replaced with a user-specified value and sanitized where possible.

@atc0005 atc0005 modified the milestones: Future, v0.10.0 Apr 11, 2022
@atc0005 atc0005 modified the milestones: v0.10.0, Future Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-line config documentation Improvements or additions to documentation enhancement New feature or request logging
Projects
None yet
Development

No branches or pull requests

1 participant