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

win_perf_counters "SMB Server Shares" and "SMB Client Shares". #5599

Closed
Erikov-K opened this issue Mar 18, 2019 · 4 comments
Closed

win_perf_counters "SMB Server Shares" and "SMB Client Shares". #5599

Erikov-K opened this issue Mar 18, 2019 · 4 comments
Labels
area/windows Related to windows plugins (win_eventlog, win_perf_counters, win_services) bug unexpected problem or unintended behavior

Comments

@Erikov-K
Copy link

Hello!

I have some troubles with "win_perf_counters" input plugin.
I want to collect data from "SMB Server Shares" and "SMB Client Shares".
Instance objects of this counters contain \ (backslash) in their names.

Example:
Show all available counters from measurement "SMB Client Shares":

typeperf -q "SMB Client Shares"
\SMB Client Shares(*)\Credit Stalls/sec
\SMB Client Shares(*)\Metadata Requests/sec
\SMB Client Shares(*)\Avg. Data Queue Length
\SMB Client Shares(*)\Avg. Write Queue Length
\SMB Client Shares(*)\Avg. Read Queue Length
\SMB Client Shares(*)\Current Data Queue Length
\SMB Client Shares(*)\Avg. sec/Data Request
\SMB Client Shares(*)\Avg. Data Bytes/Request
\SMB Client Shares(*)\Data Requests/sec
\SMB Client Shares(*)\Data Bytes/sec
\SMB Client Shares(*)\Avg. sec/Write
\SMB Client Shares(*)\Avg. sec/Read
\SMB Client Shares(*)\Avg. Bytes/Write
\SMB Client Shares(*)\Avg. Bytes/Read
\SMB Client Shares(*)\Write Requests/sec
\SMB Client Shares(*)\Read Requests/sec
\SMB Client Shares(*)\Write Bytes/sec
\SMB Client Shares(*)\Read Bytes/sec
Exiting, please wait...
The command completed successfully.

Show all available counters from measurement "SMB Client Shares" with all instances objects:

typeperf -qx "SMB Client Shares"

So, command for measure specific share with specific counter instance object looks like:

typeperf "\SMB Client Shares(\ServerName.DomainName\ShareName)\Avg. Data Bytes/Request"

And here are my problem!
Input plugin "win_perf_counters.go" has this code:

var sanitizedChars = strings.NewReplacer("/sec", "_persec", "/Sec", "persec", " ", "", "%", "Percent", \, "")

… which removes backslash from instance name!

So I finally have instance looks like "ServerName.DomainNameShareName" instead of "\ServerName.DomainName\ShareName"

May be it will be more correct don't remove characters such as \ (backslash) ?
For example: replace them by - (dash) or _ (bottom dash) ?
Also, "/sec" replaced with "_persec" automatically.
But what about "/Request", "/Write" or "/Read" ?

For each of this counters I need to use "processors.rename.replace"
Also there are counters which ends with dot (Example: "Avg. *").
What about them?

Thank you!

@Erikov-K
Copy link
Author

Erikov-K commented Mar 19, 2019

I solved my problem by adding processors.strings.replace to config file.
After processing the instance objects looks like "ShareName".

[[processors.strings]]
namepass = ["smb_client_shares"]

[[processors.strings.replace]]
  tag = "instance"
  old = "ServerName.DomainName"
  new = ""

[[processors.strings.replace]]
  tag = "instance"
  old = "ServerName"
  new = ""

I think, it will be a good idea to correctly processing \ (backslash) in future telegraf builds! :-)

@danielnelson
Copy link
Contributor

I agree it would be better to convert \ -> _ and we should this for 1.11.0.

Bigger picture, maybe we should just stop processing the instance altogether other than perhaps trimming surrounding whitespace. I don't see a reason to modify it since it is just being used as a tag value and not as a tag key. For the measurement and field keys I'd like to be even more aggressive moving to [a-z_]. I have an issue open in #5196 and I'd love to get your input.

@danielnelson danielnelson added bug unexpected problem or unintended behavior area/windows Related to windows plugins (win_eventlog, win_perf_counters, win_services) labels Mar 21, 2019
@danielnelson danielnelson added this to the 1.11.0 milestone Mar 21, 2019
@russorat russorat removed this from the 1.11.0 milestone Apr 24, 2019
@abedfarvardin
Copy link

I configured samba in this way and it worked well for me

SMB / File Server

[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
ObjectName = "SMB Client Shares"
Counters = ["Write Bytes/sec","Read Bytes/sec","Current Data Queue Length","Metadata Requests/sec"]
Instances = ["*"]
Measurement = "win_smb"

@sjwang90
Copy link
Contributor

sjwang90 commented Aug 4, 2021

Closing issue - please comment any breaking changes in regards to win_per_counters configs at #5196

@sjwang90 sjwang90 closed this as completed Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/windows Related to windows plugins (win_eventlog, win_perf_counters, win_services) bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants