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

Wrong flags in Usage helper text #91

Closed
eduardohki opened this issue Jul 6, 2017 · 7 comments
Closed

Wrong flags in Usage helper text #91

eduardohki opened this issue Jul 6, 2017 · 7 comments

Comments

@eduardohki
Copy link

I was trying to manually run wmi_exproter.exe with custom options, because I wanted the port to listen at 9100 (like node_exporter).

However, the flag listed in the command-line usage wasn't working, issuing the error flag provided but not defined: -addr:

PS C:\Program Files\wmi_exporter> .\wmi_exporter.exe -addr ":9100"
flag provided but not defined: -addr
Usage of C:\Program Files\wmi_exporter\wmi_exporter.exe:
  -collector.iis.app-blacklist string
        Regexp of apps to blacklist. App name must both match whitelist and not match blacklist to be included.
  -collector.iis.app-whitelist string
        Regexp of apps to whitelist. App name must both match whitelist and not match blacklist to be included. (default
 ".+")
  -collector.iis.site-blacklist string
        Regexp of sites to blacklist. Site name must both match whitelist and not match blacklist to be included.
  -collector.iis.site-whitelist string
        Regexp of sites to whitelist. Site name must both match whitelist and not match blacklist to be included. (defau
lt ".+")
  -collector.logical_disk.volume-blacklist string
        Regexp of volumes to blacklist. Volume name must both match whitelist and not match blacklist to be included.
  -collector.logical_disk.volume-whitelist string
        Regexp of volumes to whitelist. Volume name must both match whitelist and not match blacklist to be included. (d
efault ".+")
  -collector.net.nic-blacklist string
        Regexp of NIC:s to blacklist. NIC name must both match whitelist and not match blacklist to be included.
  -collector.net.nic-whitelist string
        Regexp of NIC:s to whitelist. NIC name must both match whitelist and not match blacklist to be included. (defaul
t ".+")
  -collectors.enabled string
        Comma-separated list of collectors to use. Use '[default]' as a placeholder for all the collectors enabled by de
fault (default "cpu,cs,logical_disk,net,os,service,system")
  -collectors.print
        If true, print available collectors and exit.
  -log.format value
        Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true" (defaul
t "logger:stderr")
  -log.level value
        Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] (default "in
fo")
  -telemetry.addr string
        host:port for WMI exporter. (default ":9182")
  -telemetry.path string
        URL path for surfacing collected metrics. (default "/metrics")
  -version
        Print version information.

So I found out that it needed to use two hyphens (--addr ":9100") instead of one (-addr ":9100"), for every option.

So I think a fix is needed in the Usage text.

@carlpett
Copy link
Collaborator

carlpett commented Jul 6, 2017

Hm, no, the flag is not -addr, but -telemetry.addr. I'm surprised --addr would work, did it actually start listening on that port, or was the flag ignored?

There is a problem with using dots in flags when executing from Powershell, though, which is unfortunate. It stops parsing at the dot, so you need to do "-telemetry.addr" ":9100" if starting from Powershell.

@carlpett
Copy link
Collaborator

carlpett commented Jul 6, 2017

On testing on my system, I cannot get --addr to be accepted. What version are you using?

@eduardohki
Copy link
Author

Sorry, I inserted the wrong text here (I tested a lot of options).

here is the correct one (-telemetry.addr):

PS C:\Program Files\wmi_exporter> .\wmi_exporter.exe -telemetry.addr ":9100"
flag provided but not defined: -telemetry
Usage of C:\Program Files\wmi_exporter\wmi_exporter.exe:
  -collector.iis.app-blacklist string
        Regexp of apps to blacklist. App name must both match whitelist and not match blacklist to be included.
  -collector.iis.app-whitelist string
        Regexp of apps to whitelist. App name must both match whitelist and not match blacklist to be included. (default ".+")
  -collector.iis.site-blacklist string
        Regexp of sites to blacklist. Site name must both match whitelist and not match blacklist to be included.
  -collector.iis.site-whitelist string
        Regexp of sites to whitelist. Site name must both match whitelist and not match blacklist to be included. (default ".+")
  -collector.logical_disk.volume-blacklist string
        Regexp of volumes to blacklist. Volume name must both match whitelist and not match blacklist to be included.
  -collector.logical_disk.volume-whitelist string
        Regexp of volumes to whitelist. Volume name must both match whitelist and not match blacklist to be included. (default ".+")
  -collector.net.nic-blacklist string
        Regexp of NIC:s to blacklist. NIC name must both match whitelist and not match blacklist to be included.
  -collector.net.nic-whitelist string
        Regexp of NIC:s to whitelist. NIC name must both match whitelist and not match blacklist to be included. (default ".+")
  -collectors.enabled string
        Comma-separated list of collectors to use. Use '[default]' as a placeholder for all the collectors enabled by default (default "cpu,cs,logical_disk,net,os,service,system")
  -collectors.print
        If true, print available collectors and exit.
  -log.format value
        Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true" (default "logger:stderr")
  -log.level value
        Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] (default "info")
  -telemetry.addr string
        host:port for WMI exporter. (default ":9182")
  -telemetry.path string
        URL path for surfacing collected metrics. (default "/metrics")
  -version
        Print version information.

Using --telemetry.addr it works:

PS C:\Program Files\wmi_exporter>
PS C:\Program Files\wmi_exporter> .\wmi_exporter.exe --telemetry.addr ":9100"
time="2017-07-06T20:37:40Z" level=info msg="Enabled collectors: logical_disk, net, os, service, system, cpu, cs" source="exporter.go:191"
time="2017-07-06T20:37:41Z" level=info msg="Starting WMI exporter (version=0.2.5, branch=master, revision=175c54acf13aee43592120ad0567257f01684dc1)" source="exporter.go:202"
time="2017-07-06T20:37:41Z" level=info msg="Build context (go=go1.8, user=appvyr-win\\appveyor@APPVYR-WIN, date=20170627-07:30:21)" source="exporter.go:203"
time="2017-07-06T20:37:41Z" level=info msg="Starting server on :9100" source="exporter.go:206"

@eduardohki
Copy link
Author

eduardohki commented Jul 6, 2017

Well, I think that the problem with using dots in flags when executing from Powershell should be at least described in the Usage text, it would prevent a lot of trouble IMO.

Thanks!

@carlpett
Copy link
Collaborator

carlpett commented Jul 7, 2017

I've considered if we should actually just change the flags. The current ones were initially copied from node_exporter, but the gains from having a similar pattern are probably quite small.

It should be noted that this is only a problem in powershell, though. No other command line parser in Windows is affected.

@eduardohki
Copy link
Author

hello @carlpett

I confirmed the problem with powershell.

IMO this PowerShell "problem" could be stated in the Usage text as a warning to the user.

Thanks!

@martinlindhe
Copy link
Collaborator

I agree with @carlpett we could simply change the flags to get rid of this issue.

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

No branches or pull requests

3 participants