Can't get rid of NaN in rrd / rra

Chris Herrmann <[email protected]> Fri, 11 Aug 2017 02:12:23 +0000
Newsgroups gmane.comp.db.rrdtool.user
Message-ID <ME1PR01MB1715B95C23AD046B487B15CEB5890@ME1PR01MB1715.ausprd01.prod.outlook.com>
--===============5931990042697758158==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_ME1PR01MB1715B95C23AD046B487B15CEB5890ME1PR01MB1715ausp_"

--_000_ME1PR01MB1715B95C23AD046B487B15CEB5890ME1PR01MB1715ausp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi all, apologies for the cross post, I originally posted in the Cacti foru=
ms https://forums.cacti.net/about15136.html but it's probably more appropri=
ate here.

-------------------

Hi, I've been bashing my head against this issue for a while now... time to=
 get some help.

I'm reading data from a database into variables, and then dropping that int=
o the rrd. Graphs aren't working in cacti, which is failing because the rra=
 aggregations are all returning nan. I've worked my way through a whole bun=
ch of stuff to no avail. So... here's where I'm currently at:

cron runs a script every 5 minutes. This script basically does:
rrdtool updatev /var/www/mrtg/applications/test.rrd N:$rttime >> /var/log/r=
ttime.log 2>&1

(I'm using updatev right now to try and get more information about what's g=
oing on).

the RRD is defined:
/usr/bin/rrdtool create \
/var/www/mrtg/applications/test.rrd \
--step 300 \
DS:rttime:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:500 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:AVERAGE:0.5:1440:820 \
RRA:MAX:0.5:1:500 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797 \
RRA:MAX:0.5:1440:820 \


$rttime is populated by querying a sql server database and returning the fl=
oating value to the variable.
I'm using mssql 0.6.2 from https://www.npmjs.com/package/sql-cli to talk to=
 the sql server.

So the command string ends up looking like

$SQLBIN -s "$DBHOST" -d "$DBNAME" -u "$DBUSER" -p "$DBPASSWD" -q "$QUERY1" =
-f csv | sed 's/"//g' | cut -d , -f 1,3 > /tmp/output.txt

which gets me useful fields. Populating the variable happens with:

rttime=3D`sed -n "$i p" /tmp/output.txt | cut -d , -f 2`

which will give something like:
2.0166666666666666

If I then update the rrd:
rrdtool updatev /var/www/mrtg/applications/test.rrd N:$rttime >> /var/log/r=
ttime.log 2>&1

rrdtool updatev /var/www/mrtg/applications/test.rrd N:0
return_value =3D 0
[1502287200]RRA[AVERAGE][1]DS[rttime] =3D NaN
...

It puts the data into the rrd, but the rras don't get populated:
filename =3D "/var/www/mrtg/applications/test.time.rrd"
rrd_version =3D "0003"
step =3D 300
last_update =3D 1502250603
header_size =3D 4120
ds[rttime].index =3D 0
ds[rttime]=3D "GAUGE"
ds[rttime].minimal_heartbeat =3D 600
ds[rttime].min =3D 0.0000000000e+00
ds[rttime].max =3D 1.0000000000e+03
ds[rttime].last_ds =3D "1.4166666666666667
ds[rttime].value =3D NaN
ds[rttime].unknown_sec =3D 3
rra[0].cf =3D "AVERAGE"
rra[0].rows =3D 500
rra[0].cur_row =3D 301
rra[0].pdp_per_row =3D 1
rra[0].xff =3D 5.0000000000e-01
rra[0].cdp_prep[0].value =3D NaN
rra[0].cdp_prep[0].unknown_datapoints =3D 0
...

valid data in this case is likely to range from 0 - 10, and will be floatin=
g point. But the doco says GAUGE should be OK with float?

Now... I have some rrds & accompanying graphs using almost exactly the same=
 process, but where the data returned is always an integer - and they work =
fine. Maybe this is the problem? I've just modified the script to only retu=
rn 2dp (in case it was a problem with too many decimal places...)

Nope... still getting NaN for all the averages.

Where do I look next?

Thanks!

--
Regards

Chris Herrmann
Far Edge Technology

p. 02 84251400
m. 0403 393309
http://www.faredge.com.au


--_000_ME1PR01MB1715B95C23AD046B487B15CEB5890ME1PR01MB1715ausp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-AU" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi all, apologies for the cross post, I originally p=
osted in the Cacti forums
<a href=3D"https://forums.cacti.net/about15136.html">https://forums.cacti.n=
et/about15136.html</a> but it&#8217;s probably more appropriate here.<o:p><=
/o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">-------------------<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Hi, I've been bashing my head against this issue for=
 a while now... time to get some help.<br>
<br>
I'm reading data from a database into variables, and then dropping that int=
o the rrd. Graphs aren't working in cacti, which is failing because the rra=
 aggregations are all returning nan. I've worked my way through a whole bun=
ch of stuff to no avail. So... here's
 where I'm currently at:<br>
<br>
cron runs a script every 5 minutes. This script basically does:<br>
rrdtool updatev /var/www/mrtg/applications/test.rrd N:$rttime &gt;&gt; /var=
/log/rttime.log 2&gt;&amp;1<br>
<br>
(I'm using updatev right now to try and get more information about what's g=
oing on).<br>
<br>
the RRD is defined:<br>
/usr/bin/rrdtool create \<br>
/var/www/mrtg/applications/test.rrd \<br>
--step 300 \<br>
DS:rttime:GAUGE:600:0:U \<br>
RRA:AVERAGE:0.5:1:500 \<br>
RRA:AVERAGE:0.5:1:600 \<br>
RRA:AVERAGE:0.5:6:700 \<br>
RRA:AVERAGE:0.5:24:775 \<br>
RRA:AVERAGE:0.5:288:797 \<br>
RRA:AVERAGE:0.5:1440:820 \<br>
RRA:MAX:0.5:1:500 \<br>
RRA:MAX:0.5:1:600 \<br>
RRA:MAX:0.5:6:700 \<br>
RRA:MAX:0.5:24:775 \<br>
RRA:MAX:0.5:288:797 \<br>
RRA:MAX:0.5:1440:820 \<br>
<br>
<br>
$rttime is populated by querying a sql server database and returning the fl=
oating value to the variable.<br>
I'm using mssql 0.6.2 from https://www.npmjs.com/package/sql-cli to talk to=
 the sql server.<br>
<br>
So the command string ends up looking like<br>
<br>
$SQLBIN -s &quot;$DBHOST&quot; -d &quot;$DBNAME&quot; -u &quot;$DBUSER&quot=
; -p &quot;$DBPASSWD&quot; -q &quot;$QUERY1&quot; -f csv | sed 's/&quot;//g=
' | cut -d , -f 1,3 &gt; /tmp/output.txt<br>
<br>
which gets me useful fields. Populating the variable happens with:<br>
<br>
rttime=3D`sed -n &quot;$i p&quot; /tmp/output.txt | cut -d , -f 2`<br>
<br>
which will give something like:<br>
2.0166666666666666<br>
<br>
If I then update the rrd:<br>
rrdtool updatev /var/www/mrtg/applications/test.rrd N:$rttime &gt;&gt; /var=
/log/rttime.log 2&gt;&amp;1<br>
<br>
rrdtool updatev /var/www/mrtg/applications/test.rrd N:0<br>
return_value =3D 0<br>
[1502287200]RRA[AVERAGE][1]DS[rttime] =3D NaN<br>
...<br>
<br>
It puts the data into the rrd, but the rras don't get populated:<br>
filename =3D &quot;/var/www/mrtg/applications/test.time.rrd&quot;<br>
rrd_version =3D &quot;0003&quot;<br>
step =3D 300<br>
last_update =3D 1502250603<br>
header_size =3D 4120<br>
ds[rttime].index =3D 0<br>
ds[rttime]=3D &quot;GAUGE&quot;<br>
ds[rttime].minimal_heartbeat =3D 600<br>
ds[rttime].min =3D 0.0000000000e&#43;00<br>
ds[rttime].max =3D 1.0000000000e&#43;03<br>
ds[rttime].last_ds =3D &quot;1.4166666666666667<br>
ds[rttime].value =3D NaN<br>
ds[rttime].unknown_sec =3D 3<br>
rra[0].cf =3D &quot;AVERAGE&quot;<br>
rra[0].rows =3D 500<br>
rra[0].cur_row =3D 301<br>
rra[0].pdp_per_row =3D 1<br>
rra[0].xff =3D 5.0000000000e-01<br>
rra[0].cdp_prep[0].value =3D NaN<br>
rra[0].cdp_prep[0].unknown_datapoints =3D 0<br>
...<br>
<br>
valid data in this case is likely to range from 0 - 10, and will be floatin=
g point. But the doco says GAUGE should be OK with float?<br>
<br>
Now... I have some rrds &amp; accompanying graphs using almost exactly the =
same process, but where the data returned is always an integer - and they w=
ork fine. Maybe this is the problem? I've just modified the script to only =
return 2dp (in case it was a problem
 with too many decimal places&#8230;)<br>
<br>
Nope... still getting NaN for all the averages.<br>
<br>
Where do I look next?<br>
<br>
Thanks!<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"mso-fareast-language:E=
N-AU">--<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"mso-fareast-language:E=
N-AU">Regards<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"mso-fareast-language:E=
N-AU"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"mso-fareast-language:E=
N-AU">Chris Herrmann<br>
Far Edge Technology<br>
<br>
p. 02 84251400<br>
m. 0403 393309<br>
<a href=3D"http://www.faredge.com.au"><span style=3D"color:#0563C1">http://=
www.faredge.com.au</span></a>&nbsp;&nbsp;
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_ME1PR01MB1715B95C23AD046B487B15CEB5890ME1PR01MB1715ausp_--


--===============5931990042697758158==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
rrd-users mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

--===============5931990042697758158==--