Hello,
The information sent by collectl to graphite_exporter trigger a bug during the
formatting of environnement data :
Aug 18 01:45:33 <HOSTNAME> graphite_expo Invalid value rter[15097]:
time="2019-08-18T01:45:33+02:00" level=info msg="Invalid value in line:
<HOSTNAME>.env.BTemp1 sf 1566085530" source="main.go:112"
The value of environnement data was set to « sf » that return a "Invalid value"
notification.
A unitary execution of the ‘Environment subsystem’ (E parameter of the -s
option) between a host and the grafite daemon show this behaviour :
<host># collectl -sE -i::1 -c1 --export graphite,<graphite_host>
<graphite_host># tcpdump
[...]
0x0000: 4500 0057 9ca7 4000 4006 4545 0a82 21b3 E..W..@[email protected]..!.
0x0010: 0a82 21fe dafe 07d3 57d9 6ddd fbf7 1fb5 ..!.....W.m.....
0x0020: 8018 00de cdde 0000 0101 080a a2e9 f028 ...............(
0x0030: a2f4 333b 0000 0000 0000 0000 002e 656e ..3;<HOSTNAME>.en
0x0040: 762e 4254 656d 7032 2073 6620 3135 3636 v.BTemp2.sf.1566
0x0050: 3339 3231 3835 0a 392185.
<host># tcpdump
[...]
0x0000: 4500 0057 b54f 4000 4006 2c9d 0a82 21b3 E..W.O@.@.,...!.
0x0010: 0a82 21fe dafe 07d3 57de dd56 fbf7 1fb5 ..!.....W..V....
0x0020: 8018 00de 2e44 0000 0101 080a a2f1 09af .....D..........
0x0030: a2fb 4cc2 0000 0000 0000 0000 002e 656e ..L.<HOSTNAME>.en
0x0040: 762e 4254 656d 7032 2073 6620 3135 3636 v.BTemp2.sf.1566
0x0050: 3339 3236 3530 0a 392650.
This two network dumps show the issues at data sending time by the host
involving the corrupt data received by the graphite host.
The execution without exporting data to graphite host shows good values :
<host># collectl -sE -i::1 -c1 -f /var/log/collectl/
<host># ls -l /var/log/collectl/<host>2-20190821-145917.raw.gz
-rw-r--r--. 1 root root 975 Aug 21 14:59
/var/log/collectl/<host>-20190821-145917.raw.gz
<host># zgrep "Blade Temp" /var/log/collectl/<host>-20190821-145917.raw.gz
ipmi: Blade Temp1,28,degrees C,ok
ipmi: Blade Temp2,31,degrees C,ok
ipmi: Blade Temp1,28,degrees C,ok
ipmi: Blade Temp2,31,degrees C,ok
The collected data is sent to graphite deamon using the sendData function
defined at line 445 of /usr/share/collect/graphite.ph file. This function take
4 arguments. The 4th arguments is the float precision used during data
formating :
445 sendData("env.$name$inst", $name, $ipmiData->{$key}->[$i]->{value}, '%s');
[...]
460 sub sendData
461{
462 my $name= shift;
463 my $units=shift;
664 my $value=shift;
465 my $numpl=shift; # number of decimal places
[...]
516 my $valString=(!defined($numpl)) ? sprintf('%d', $value) :
sprintf("%.${numpl}f", $value);
517 my $message=sprintf("$graphiteBefore$graphiteMyHost$graphitePost.$name
$valString %d\n", $graphiteIntTimeLast);
518 print $message if $graphiteDebug & 1;
519 if (!($graphiteDebug & 8))
520 {
521 my $bytes=syswrite($graphiteSocket, $message, length($message), 0);
522 }
The float precision is set to ‘%s’ string which can’t be used as part of the
float string format used at line 516. The string "%s" gives the string format
"%.%sf". The values sent are therefore set to "sf" instead of a floating point
number.
The fix is to set the precision parameter to a integer constant instead of the
string '%s'. A patch was add in attachment (The second correction is just to
make the string format generation more human readable).
Thank you
Florian
--- /usr/share/collectl/graphite.ph.bug 2019-09-05 15:54:44.087745990 +0200
+++ /usr/share/collectl/graphite.ph 2019-09-05 15:58:56.567804337 +0200
@@ -442,7 +442,7 @@
my $name=$ipmiData->{$key}->[$i]->{name};
my $inst=($key!~/power/ && $ipmiData->{$key}->[$i]->{inst} ne '-1') ? $ipmiData->{$key}->[$i]->{inst} : '';
- sendData("env.$name$inst", $name, $ipmiData->{$key}->[$i]->{value}, '%s');
+ sendData("env.$name$inst", $name, $ipmiData->{$key}->[$i]->{value}, '2');
}
}
}
@@ -513,7 +513,7 @@
if (!$graphiteCOFlag || $value!=$graphiteDataLast{$name} || $graphiteTTL{$name}==1)
{
$valSentFlag=1;
- my $valString=(!defined($numpl)) ? sprintf('%d', $value) : sprintf("%.${numpl}f", $value);
+ my $valString=(!defined($numpl)) ? sprintf('%d', $value) : sprintf("%.".${numpl}."f", $value);
my $message=sprintf("$graphiteBefore$graphiteMyHost$graphitePost.$name $valString %d\n", $graphiteIntTimeLast);
print $message if $graphiteDebug & 1;
if (!($graphiteDebug & 8))
_______________________________________________
Collectl-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/collectl-interest