Can't get rid of NaN in rrd / rra

Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can't get rid of NaN in rrd / rra

Chris Herrmann

Hi all, apologies for the cross post, I originally posted in the Cacti forums https://forums.cacti.net/about15136.html but it’s probably more appropriate 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 into 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 bunch 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/rttime.log 2>&1

(I'm using updatev right now to try and get more information about what's going 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 floating 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=`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/rttime.log 2>&1

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

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

valid data in this case is likely to range from 0 - 10, and will be floating 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 return 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  

 


_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can't get rid of NaN in rrd / rra

Chris Herrmann

OK, got it with the excellent help of the folks @ ITPA www.ipta.org.au . Basically the data value that I was putting in had a trailling \r\n. Finding this out was done with…

 

root@whisk:~# echo “$myvar” | od -a
0000000 0 . 7 8 cr nl
0000006

 

and:

printf "%f" "$myvar"

: invalid number.78

0.000000

 

This occurred because it was the last field (column) in the file, so “cut” was grabbing the carriage return as part of the last field.

 

I fixed it by adding an additional dummy field to the returned sql, so that instead of grabbing the last field in the data set I’m now grabbing the second last field.

 

So now I get:

echo “$myvar” | od -a
0000000 b nul fs 0 . 7 8 b nul gs nl
0000013

 

now which works OK and there’s aggregate data appearing in rrds now.

 

--

Regards

 

Chris Herrmann
Far Edge Technology

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

 


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