-
Notifications
You must be signed in to change notification settings - Fork 0
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
workaround for Windows path and update README about plugin path #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a note and one comment, but I think there were no issues.
@@ -85,7 +87,17 @@ func (opts *mackerelMetricOpts) run() *checkers.Checker { | |||
|
|||
conf, err := config.LoadConfig(config.DefaultConfig.Conffile) | |||
if err != nil { | |||
return checkers.Unknown(fmt.Sprintf("%v", err)) | |||
if runtime.GOOS == "windows" { | |||
newpath := filepath.Join(config.DefaultConfig.Conffile, "../../../mackerel-agent.conf") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note]
It will probably be something like this:
C:\Program Files\Mackerel\mackerel-agent\plugins\bin\mackerel-agent.conf\..\..\..\mackerel-agent.conf
↓
C:\Program Files\Mackerel\mackerel-agent\mackerel-agent.conf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! it looks ugly workaround, but it is hard to change mackerel-agent config logic.
newpath := filepath.Join(config.DefaultConfig.Conffile, "../../../mackerel-agent.conf") | ||
conf, err = config.LoadConfig(newpath) | ||
if err != nil { | ||
return checkers.Unknown(fmt.Sprintf("%v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following kind of code would also be good.
return checkers.Unknown(fmt.Sprintf("%v", err)) | |
return checkers.Unknown(err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll apply it to other projects... 😻
This PR fixes 2 issues.
Update README:
Windows plugin will be installed to C:\Program Files\Mackerel\mackerel-agent\plugins\bin by mkr plugin install.
Linux plugin will be installed to /opt/mackerel-agent/bin.
Users must specify these paths explicitly.
Update handling DefaultConfig.Conffile:
config(from mackerel-agent library).DefaultConfig.Conffile's behaves dfferently in Linux and Windows.
On Linux, it refers to /etc/mackerel-agent.conf, regardless of the location of the plugin.
But on Windows, it mysteriously points to mackerel-agent.conf in the plugin path C:\Program Files\Mackerel\mackerel-agent\plugins\bin\mackerel-agent.conf (yes, this is an invalid location).
The code I put in run() is awkward, but it acts as a workaround.