Difference between revisions of "RRDTool"
From dbawiki
(Created page with "===Data Source=== <pre> free -m total used free shared buffers cached Mem: 499 214 284 0 2 ...") |
(→Update the database and print out the latest graph) |
||
| Line 45: | Line 45: | ||
GPRINT:memory:AVERAGE:"Avg\: %5.2lf" \ | GPRINT:memory:AVERAGE:"Avg\: %5.2lf" \ | ||
GPRINT:memory:MAX:"Max\: %5.2lf" \ | GPRINT:memory:MAX:"Max\: %5.2lf" \ | ||
| − | GPRINT:memory:MIN:"Min\: %5.2lf | + | GPRINT:memory:MIN:"Min\: %5.2lf" |
</pre> | </pre> | ||
Revision as of 22:04, 9 December 2013
Data Source
free -m
total used free shared buffers cached
Mem: 499 214 284 0 2 169
# Total
free -m | grep Mem | awk '{print $2}'
499
# Used
free -m | grep Mem | awk '{print $3}'
65
Create a database
rrdtool create /root/mem.rrd --step 60 DS:mem:GAUGE:120:0:499 RRA:MAX:0.5:1:31622400
Update the database and print out the latest graph
#!/bin/bash
# update data
mem_used=`free -m | grep Mem | awk '{print $3}'`
/usr/bin/rrdtool update /root/mem.rrd --template mem N:$mem_used
# create graph
/usr/bin/rrdtool graph /var/www/html/mem.png \
-w 500 -h 150 -a PNG \
--slope-mode \
--start -3600 --end now \
--font DEFAULT:7: \
--title "Memory used (last hour)" \
--watermark "`date`" \
--x-grid MINUTE:5:MINUTE:10:MINUTE:10:0:%R \
--alt-y-grid --rigid \
--lower-limit=0 \
--color BACK#363636 \
--color CANVAS#000000 \
--color GRID#999999 \
--color MGRID#B5B5B5 \
--color FONT#CCCCCC \
DEF:memory=/root/mem.rrd:mem:MAX \
AREA:memory#FFD700 \
LINE1:memory#FFD700:"Memory used (MB)" \
GPRINT:memory:LAST:"Last\: %5.2lf" \
GPRINT:memory:AVERAGE:"Avg\: %5.2lf" \
GPRINT:memory:MAX:"Max\: %5.2lf" \
GPRINT:memory:MIN:"Min\: %5.2lf"