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

SMART plugin: measurement broken because of unwanted CRLF added to 'serial_no' and 'wwn' tags #3957

Closed
rkohoutek opened this issue Mar 31, 2018 · 2 comments · Fixed by #3960
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@rkohoutek
Copy link

rkohoutek commented Mar 31, 2018

Bug report

When using SMART input plugin the 'serial_no' and 'wwn' measurements adds unwanted CRLF into the tag value and thus preventing correct interpretation in Grafana/Chronograf.
I am not sure whether it is Windows specific behavior or Linux version is affected too.

Relevant telegraf.conf:

[[outputs.file]]
files = ["/Appz/telegraf-test/metrics.out"]
data_format = "influx"

[[inputs.smart]]
interval = "1m"
path = "/Appz/smartmontools/bin/smartctl.exe"
attributes = true
devices = [ "/dev/sdw -d sat"]

System info:

Windows 10 Enterprise
Telegraf v1.5.3 (git: release-1.5 1e51969)
smartctl 6.6 2017-11-05 r4594 [x86_64-w64-mingw32-w10-1607] (sf-6.6-1)
smartmontools release 6.6 dated 2017-11-05 at 15:20:58 UTC
smartmontools SVN rev 4594 dated 2017-11-05 at 15:21:35
smartmontools build host: x86_64-w64-mingw32
smartmontools build with: C++98, GCC 4.9.1
smartmontools configure arguments: 'build_alias=i686-pc-linux-gnu' 'host_alias=x86_64-w64-mingw32'

Steps to reproduce:

Run telegraf with SMART plugin enabled on Windows and check metrics.out.
Values of 'wwn' and 'serial_no' includes CRLF character.

Expected behavior (metrics.out):

smart_attribute,wwn=5000c500a34719ba,id=1,name=Raw_Read_Error_Rate,flags=POSR--,fail=-,host=PRIVATEER,device=sdw,serial_no=ZA17XBW7 exit_status=4i,value=83i,worst=64i,threshold=44i,raw_value=210503312i 1522497420000000000
smart_attribute,id=3,name=Spin_Up_Time,flags=PO----,fail=-,host=PRIVATEER,device=sdw,serial_no=ZA17XBW7,wwn=5000c500a34719ba exit_status=4i,value=84i,worst=84i,threshold=0i,raw_value=0i 1522497420000000000

Actual behavior (metrics.out):

smart_attribute,wwn=5000c500a34719ba
,id=1,name=Raw_Read_Error_Rate,flags=POSR--,fail=-,host=PRIVATEER,device=sdw,serial_no=ZA17XBW7
 exit_status=4i,value=83i,worst=64i,threshold=44i,raw_value=210503312i 1522497420000000000
smart_attribute,id=3,name=Spin_Up_Time,flags=PO----,fail=-,host=PRIVATEER,device=sdw,serial_no=ZA17XBW7
,wwn=5000c500a34719ba
 exit_status=4i,value=84i,worst=84i,threshold=0i,raw_value=0i 1522497420000000000

Additional info:

I am not GO developer but it seems that the only difference while working with parsed values in https://github.com/influxdata/telegraf/blob/master/plugins/inputs/smart/smart.go is on lines 248 - 253 when there is new assignement. Maybe the problem is somewhere here:

if serial, ok := device_tags["serial_no"]; ok {
					tags["serial_no"] = serial
				}
				if wwn, ok := device_tags["wwn"]; ok {
					tags["wwn"] = wwn
				}

metrics.out.zip

Edit note (rkohoutek, 2018-04-02 20:44): removed markdown formatting from expected/actual behavior codeblocks.

@russorat
Copy link
Contributor

russorat commented Apr 2, 2018

@rkohoutek thanks for the report. Is there any way you can manually run the smartctl command and post the output?

@russorat russorat added the bug unexpected problem or unintended behavior label Apr 2, 2018
@rkohoutek
Copy link
Author

Ouput of the following command:
c:\Appz\smartmontools\bin\smartctl --info --attributes --health --format=brief /dev/sdw > sdw.txt

sdw.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants