Performance Tuning Workshop
TECH
RRDTool has comprehensive storage and graphing capabilities utilized by many
NOTE
popular monitoring tools. SysAdmins practice loading and graphing in this round
robin database to acquire a best practice data gathering technique.
RRDtool example database creation, data update, graph display
1. Introduction
RRDtool is used as the storage and graphing component of many popular data gathering tools, including
Cacti, MRTG, Nagios, Nmon, ntop, OpenNMS and numerous others. Learning RRDtool commands and
structures contributes to understanding the core behaviors of these other tools.
This Practice creates a sample round robin database to fill with data during multiple periods. The 10
minute RRA (round robin archive) data set fills quickly enough to allow creating of a complete graph by
the end of this practice. If configured to continue gathering data, the additional RRAs can provide
sufficient data to return later to generate both a 1 hour and a 24 hour graph.
Begin by installing the rrdtool package, if necessary, and an image viewer to be used later.
[root@server ~]# yum install -y rrdtool eog
2. Create the empty round robin database file.
Build the rrdtool command in a shell script so as to allow quick correction and re-creation of the
database for practice. Re-running the script will lose any existing gathered data.
The source data is expected every 1 second (step=1). This data stream is to be consolidated
simultaneously into three different resolution RRAs. The first averages each 5 source data points into 1
stored data point, keeping a circular 120 stored points. The second averages each 30 source into 1
stored and the third consolidates at 720 to 1, both also keeping 120 points total.
The first RRA holds the data stream's last 10 minutes (120 points at 5 averaged seconds each).
The second RRA holds the data stream's last hour (120 points at 30 averaged seconds each).
The third RRA holds the data stream's last day (120 points at 720 averaged seconds each).
[root@server ~]# vi /root/netping_create.sh
#!/bin/bash
[[ -f /root/netping.rrd ]] && rm -f /root/netping.rrd
rrdtool create /root/netping.rrd \
--start=$(date +%s) --step=1 \
DS:netping:GAUGE:2:0:U \
RRA:AVERAGE:0.5:5:120 \
RRA:AVERAGE:0.5:30:120 \
RRA:AVERAGE:0.5:720:120
[root@server ~]# chmod +x /root/netping_create.sh
[root@server ~]# /root/netping_create.sh
RRDtool create/update/graph September 24, 2012 Page 1
RRDtool example database creation, data update, graph display
3. Create the data source script.
The data gathered is the round trip ping time from one system to the instructor (or any other) system.
Because each 'for loop' takes a little longer than 1 second, only 59 can be accomplished in this 1 minute
script. The database heartbeat is 2 seconds, so one incoming data point will be used twice sometime
during each minute to compensate. Without this logic, the last source data point from running this script
one minute and the first source data point from the script run the following minute would collide, causing
the database to complain that data for that overlapping second had already been received.
[root@server ~]# vi /root/netping_update.sh
#!/bin/bash
for second in $(seq 1 59); do
rrdtool update /root/netping.rrd \
$(date +%s):\
$(ping -c1 192.168.0.254 | awk /time=/'{print substr($7,6)}')
sleep 1
done
[root@server ~]# chmod +x /root/netping_update.sh
4. Configure cron to run the data source script.
Later, this file will be configured to also include the graphing scripts.
[root@server ~]# vi /etc/cron.d/netping
* * * * * root /root/netping_update.sh
5. Browse the empty RRD database.
Use RRDtool commands to browse the database in a readable text format. If the script just previously
configured in cron is working properly and the database is structured correctly, then repetitively re-
displaying the RRD database will begin to show consolidated, stored data. Find each RRA section and
notice that each contains 120 storage slots, already time configured. In a circular buffer technique
(round-robin), each new consolidated data point overwrites the next slot.
See the man pages named rrdinfo, rrddump, and rrdfetch to learn correct syntax.
Determine the type of information that can be obtained with each command. Especially, use these
comands to determine the structure of the round robin database, including datasets, round robin
archives and any current data in the form of the RRA consolidated data points. Also, use these
commands to return a subset of your data using valid starting and ending dates and times.
[root@server ~]# rrdtool info /root/netping.rrd
[root@server ~]# rrdtool dump /root/netping.rrd
[root@server ~]# rrdtool fetch /root/netping.rrd AVERAGE
RRDtool create/update/graph September 24, 2012 Page 2
RRDtool example database creation, data update, graph display
6. Create the graphing scripts. Use man pages to learn about each option used.
[root@server ~]# vi /root/netping_plot_10min.sh
#!/bin/bash
rrdtool graph /var/www/html/netping_10min.png \
-l .1 -u .6 -y .01:5 -w 400 -h 400 --rigid \
-x SECOND:30:MINUTE:1:MINUTE:2:0:%l:%M%p \
--start=$(date --date=-10min +%s) --end=$(date +%s) \
DEF:netping=/root/netping.rrd:netping:AVERAGE \
AREA:netping#0000FFC0:"previous 10 minutes network latency"
[root@server ~]# vi /root/netping_plot_1hour.sh
#!/bin/bash
rrdtool graph /var/www/html/netping_1hour.png \
-l .1 -u .6 -y .01:5 -w 400 -h 400 --rigid \
-x MINUTE:2:MINUTE:10:MINUTE:10:0:%l:%M%p \
--start=$(date --date=-1hour +%s) --end=$(date +%s) \
DEF:netping=/root/netping.rrd:netping:AVERAGE \
AREA:netping#0000FFD0:"previous hour network latency"
[root@server ~]# vi /root/netping_plot_1day.sh
#!/bin/bash
rrdtool graph /var/www/html/netping_1day.png \
-l .1 -u .6 -y .01:5 -w 400 -h 400 --rigid \
-x HOUR:1:HOUR:3:HOUR:3:0:%l%p \
--start=$(date --date=-1day +%s) --end=$(date +%s) \
DEF:netping=/root/netping.rrd:netping:AVERAGE \
AREA:netping#0000FFE0:"previous day network latency"
[root@server ~]# chmod +x /root/netping_plot_10min.sh
[root@server ~]# chmod +x /root/netping_plot_1hour.sh
[root@server ~]# chmod +x /root/netping_plot_1day.sh
7. Configure cron to add the graphing scripts.
[root@server ~]# vi /etc/cron.d/netping
* * * * * root /root/netping_update.sh
* * * * * root /root/netping_plot_10min.sh >/dev/null
*/5 * * * * root /root/netping_plot_1hour.sh >/dev/null
*/12 * * * * root /root/netping_plot_1day.sh >/dev/null
8. Display the 10 minute graph first to see if enough data has gathered. Display the 1 hour and 1 day
graphs, noting that they are not yet complete. Return later today and tomorrow morning, to re-display
the 1 hour and 1 day graph after sufficient data has been stored.
[root@server ~]# eog /var/www/html/netping_10min.png
[root@server ~]# eog /var/www/html/netping_1hour.png
[root@server ~]# eog /var/www/html/netping_1day.png
End of workshop.
RRDtool create/update/graph September 24, 2012 Page 3
Wyszukiwarka
Podobne podstrony:
tech note ?dicated heartbeat interfacetech note rhel6 alternate boot methodstech note quick install of high availability?d onTech tech chem11[31] Z5 06 utech indWorksheet Long lasting hobby ansMazda Mx5 Tech Pt2001 07 Gimp Workshop Photograph Reprocessingmetr tech 1EABA Vehicles Worksheetzad tech techn zywn zad przykładoweinformator tech informatykeim1 worksheeteim1 worksheettech readmeChristmas Picture Gap Fill Worksheetwięcej podobnych podstron