Hi there, <br><br>I'm trying to draw a graph representing the amount of seconds a Slave is behind a master in a MySQL cluster.<br>So, to get the data i just use:<br>mysql -p -e "show slave status\G;" | grep "Seconds_Behind_Master:" | tr -d " " | awk -F ":" '{print $2}'<br>
<br>Which gives me a values like:<br>0<br>1<br>3411<br>48639<br>Depending on the machine, obviously.<br><br>So far, that's fine, now, I include that in my script to create the graph, which is as follows:<br><br>HOSTNAME=`hostname`<br>
DATASOURCE=/opt/delay.sh<br>RRDTOOL=/usr/bin/rrdtool<br>RRDFILE=/opt/delay.rrd<br>GRAPH=/opt/$HOSTNAME/delay-$HOSTNAME<br>DATE=/bin/date<br><br>OUTNET_RRD_DIR=/var/lib/rrd/delay<br><br>HEIGHT=80<br>WIDTH=730<br>TITLE="Seconds behind the master"<br>
VTITLE="Delay"<br><br>if ! [ -f $RRDFILE ]; then<br> echo "Creating RRD file"<br> $RRDTOOL create $RRDFILE -s 300 DS:delay:GAUGE:600:U:U RRA:LAST:0.5:1:10000<br>fi<br><br><br># Gathering data<br>
DATA=$($DATASOURCE)<br>TIMESTAMP=$($DATE +%s)<br>$RRDTOOL update $RRDFILE $TIMESTAMP:$DATA<br><br><br>for n in day week month; do<br> $RRDTOOL graph $GRAPH-$n.png --start -1$n --end now \<br>
-h $HEIGHT -w $WIDTH -t "$TITLE $HOSTNAME ($n)" -v "$VTITLE" --slope \<br> DEF:delay=$RRDFILE:delay:LAST \<br> LINE:delay\#32CD32:"Delay (Seconds)" \<br>
GPRINT:delay:MAX:"Max\: %5.2lf %S" \<br> GPRINT:delay:AVERAGE:"Avg\: %5.2lf %S" \<br> GPRINT:delay:LAST:"Current\: %5.2lf %S Delay\n"<br>
<br>done<br><br>The problem is:<br><br>When I get the data from the MySQL, as I said, I get data such as:<br>0<br>1<br>2<br>etc<br><br>But those values are included in the rrd file as:<br> <!-- 2009-08-11 20:20:00 CEST / 1250014800 --> <row><v> 1.6333333333e-01 </v></row><br>
<!-- 2009-08-11 20:25:00 CEST / 1250015100 --> <row><v> 3.6666666667e-02 </v></row><br> <!-- 2009-08-11 20:30:00 CEST / 1250015400 --> <row><v> 0.0000000000e+00 </v></row><br>
<!-- 2009-08-11 20:35:00 CEST / 1250015700 --> <row><v> 0.0000000000e+00 </v></row><br> <!-- 2009-08-11 20:40:00 CEST / 1250016000 --> <row><v> 0.0000000000e+00 </v></row><br>
<br>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<br>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..<br>
<br>The problem disappear when the value got from the MySQL is something like: 3989<br>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.<br>
<br>I tried setting: <br>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: <br>timestamp:0<br>timestamp:1<br>
etc etc<br><br>So my guess is somewhere, somehow, 1, 2 etc is being relcaulated to a strange value included in the rrd file.<br><br>Can someone give me a clue?<br><br>Thanks very much<br>Arthur.<br>