[rrd-users] Strange GAUGE values when parsing MySQL output

Arthur Meeks Meeks arthur.meeks.luppu at gmail.com
Tue Aug 11 20:48:57 CEST 2009


Hi there,

I'm trying to draw a graph representing the amount of seconds a Slave is
behind a master in a MySQL cluster.
So, to get the data i just use:
mysql -p -e "show slave status\G;" | grep "Seconds_Behind_Master:" | tr -d "
" | awk -F ":" '{print $2}'

Which gives me a values like:
0
1
3411
48639
Depending on the machine, obviously.

So far, that's fine, now, I include that in my script to create the graph,
which is as follows:

HOSTNAME=`hostname`
DATASOURCE=/opt/delay.sh
RRDTOOL=/usr/bin/rrdtool
RRDFILE=/opt/delay.rrd
GRAPH=/opt/$HOSTNAME/delay-$HOSTNAME
DATE=/bin/date

OUTNET_RRD_DIR=/var/lib/rrd/delay

HEIGHT=80
WIDTH=730
TITLE="Seconds behind the master"
VTITLE="Delay"

if ! [ -f $RRDFILE ]; then
    echo "Creating RRD file"
    $RRDTOOL create $RRDFILE  -s 300 DS:delay:GAUGE:600:U:U
RRA:LAST:0.5:1:10000
fi


# Gathering data
DATA=$($DATASOURCE)
TIMESTAMP=$($DATE +%s)
$RRDTOOL update $RRDFILE $TIMESTAMP:$DATA


for n in day week month; do
    $RRDTOOL graph $GRAPH-$n.png  --start -1$n --end now
        \
             -h $HEIGHT -w $WIDTH -t "$TITLE $HOSTNAME ($n)" -v "$VTITLE"
--slope          \
             DEF:delay=$RRDFILE:delay:LAST                              \
             LINE:delay\#32CD32:"Delay (Seconds)"
\
             GPRINT:delay:MAX:"Max\: %5.2lf %S"
    \
             GPRINT:delay:AVERAGE:"Avg\: %5.2lf %S"
    \
             GPRINT:delay:LAST:"Current\: %5.2lf %S Delay\n"

done

The problem is:

When I get the data from the MySQL, as I said, I get data such as:
0
1
2
etc

But those values are included in the rrd file as:
            <!-- 2009-08-11 20:20:00 CEST / 1250014800 --> <row><v>
1.6333333333e-01 </v></row>
            <!-- 2009-08-11 20:25:00 CEST / 1250015100 --> <row><v>
3.6666666667e-02 </v></row>
            <!-- 2009-08-11 20:30:00 CEST / 1250015400 --> <row><v>
0.0000000000e+00 </v></row>
            <!-- 2009-08-11 20:35:00 CEST / 1250015700 --> <row><v>
0.0000000000e+00 </v></row>
            <!-- 2009-08-11 20:40:00 CEST / 1250016000 --> <row><v>
0.0000000000e+00 </v></row>

So the grahp is not showing the correct values, cause it should be 1,
2...but instead it shows: 100M, 200M in the vertical axis
I've read that the common problem here is using COUNTER instead of GAUGE,
but as you can see, I'm using GAUGE to draw exactly, 0, 1, 2 etc..

The problem disappear when the value got from the MySQL is something like:
3989
Then the graph shows 3K, 3.5K, 4K etc in the vertical margin, which is
correct. But I don't understand why a value like: "1" is shown as 100M in
the graph.

I tried setting:
echo "$RRDTOOL update $RRDFILE $TIMESTAMP:$DATA" in the graph creation
script so I could see whether the $DATA was correct and, indeed, it was
correct I saw:
timestamp:0
timestamp:1
etc etc

So my guess is somewhere, somehow, 1, 2 etc is being relcaulated to a
strange value included in the rrd file.

Can someone give me a clue?

Thanks very much
Arthur.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-users/attachments/20090811/d82d5d59/attachment.html 


More information about the rrd-users mailing list