SMART plugin: measurement broken because of unwanted CRLF added to 'serial_no' and 'wwn' tags #3957
Description
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
}
Edit note (rkohoutek, 2018-04-02 20:44): removed markdown formatting from expected/actual behavior codeblocks.