Linux/RRDtool

From Omnia
(Redirected from Rrdtool)
Jump to navigation Jump to search

RRDtool

http://oss.oetiker.ch/rrdtool/

rrdtool - time-series data storage and display system (programs) The Round Robin Database Tool (RRDtool) is a system to store and display time-series data (e.g. network bandwidth, machine-room temperature, server load average). It stores the data in Round Robin Databases (RRDs), a very compact way that will not expand over time. RRDtool processes the extracted data to enforce a certain data density, allowing for useful graphical representation of data values.

RRDtool is often used via various wrappers that can poll data from devices and feed data into RRDs, as well as provide a friendlier user interface and customized graphs.

Documentation

RRDtool - RRDtool Documentation - https://oss.oetiker.ch/rrdtool/doc/index.en.html

Tools

rrdtool

   Round Robin Database Tool 

rrdcached

   Data caching daemon for rrdtool 

librrd

   RRD library functions 

rrdbuild

   Instructions for building RRDtool 

rrdcgi

   Create web pages containing RRD graphs based on templates 

rrdcreate

   Set up a new Round Robin Database 

rrddump

   dump the contents of an RRD to XML format 

rrdfetch

   Fetch data from an RRD. 

rrdfirst

   Return the date of the first data sample in an RRA within an RRD 

rrdflushcached

   Flush the values for a spcific RRD file from memory. 

rrdgraph_data

   preparing data for graphing in rrdtool graph 

rrdgraph_examples

   Examples for rrdtool graph 

rrdgraph_graph

   rrdtool graph command reference 

rrdgraph_libdbi

   fetching data for graphing in rrdtool graph via libdbi 

rrdgraph

   Round Robin Database tool graphing functions 

rrdgraph_rpn

   About RPN Math in rrdtool graph 

rrdinfo

   extract header information from an RRD 

rrdlast

   Return the date of the last data sample in an RRD 

rrdlastupdate

   Return the most recent update to an RRD 

rrdrados

   Creating, updating and retrieving RRD files from Ceph 

rrdresize

   alters the size of an RRA and creates a new .rrd file 

rrdrestore

   Restore the contents of an RRD from its XML dump format 

rrdtune

   Modify some basic properties of a Round Robin Database 

rrdupdate

   Store a new set of values into the RRD 

rrdxport

   Export data in XML format based on data from one or several RRD

Installation =

yum install rrdtool
apt-get install rrdtool

Guide

Getting Started with RRDtool - http://www.cuddletech.com/articles/rrd/

Overview:

  1. Create an empty RRD database using rrdtool create.
  2. Utilize a script and/or the cron to add data to the database using rrdtool update.
  3. Generate, usually via script, custom output graphs using rrdtool graph.

Create RRD:

rrdtool create records.rrd \
--start N --step 300 \
DS:probe1-temp:GAUGE:600:55:95 \
DS:probe2-temp:GAUGE:600:55:95 \
DS:probe3-temp:GAUGE:600:55:95 \
DS:probe4-temp:GAUGE:600:55:95 \
RRA:MIN:0.5:12:1440 \
RRA:MAX:0.5:12:1440 \
RRA:AVERAGE:0.5:1:1440

This will create a RRD with 5 min interval (300), 4 guages, 10 min till error (600), 55-95 range, with 50% unknowns, 12 points per record, and 1440 records

Update RRD:

rrdtool update records.rrd "N:64:57:92:86"

Graph:

rrdtool graph records.png -a PNG --title="TempTrax" \
--vertical-label "Deg F" \
'DEF:probe1=records.rrd:probe1-temp:AVERAGE' \
'DEF:probe2=records.rrd:probe2-temp:AVERAGE' \
'DEF:probe3=records.rrd:probe3-temp:AVERAGE' \
'DEF:probe4=records.rrd:probe4-temp:AVERAGE' \
'LINE1:probe1#ff0000:Switch Probe' \
'LINE1:probe2#0400ff:Server Probe' \
'AREA:probe3#cccccc:HVAC' \
'LINE1:probe4#35b73d:QA Lab Probe' \
'GPRINT:probe1:LAST:Switch Side Last Temp\: %2.1lf F' \
'GPRINT:probe3:LAST:HVAC Output Last Temp\: %2.1lf F\j' \
'GPRINT:probe2:LAST:Server Side Last Temp\: %2.1lf F' \
'GPRINT:probe4:LAST:QA Lab Last Temp\: %2.1lf F\j'

---

See last update:

rrdtool lastupdate records.rrd

Dump table: (import into Excel)

rrdtool dump records.rrd > records.xml

My Example

#!/bin/sh

# Created Using:
#   rrdtool create temperature.rrd --step 300 DS:cpu:GAUGE:600:0:100 DS:disk1:GAUGE:600:0:100 DS:disk2:GAUGE:600:0:100 DS:disk3:GAUGE:600:0:100 DS:disk4:GAUGE:600:0:100 DS:disk5:GAUGE:600:0:100 DS:disk6:GAUGE:600:0:100 DS:disk7:GAUGE:600:0:100 DS:disk8:GAUGE:600:0:100 DS:disk9:GAUGE:600:0:100 RRA:AVERAGE:0.5:1:14400 RRA:AVERAGE:0.5:6:9600 RRA:AVERAGE:0.5:36:6000

# Update Using:
# rrdtool update temperature.rrd N:$CPU:$DISK1:$DISK2:$DISK3:$DISK4:$DISK5:$DISK6:$DISK7:$DISK8:$DISK9

if [ "$1" != "graph" ] ; then


#DISK1=`/usr/sbin/hddtemp -n /dev/sda`
#DISK2=`/usr/sbin/hddtemp -n /dev/sdb`
#DISK3=`/usr/sbin/hddtemp -n /dev/sdc`
DISK1=
DISK2=
DISK3=

DISK4=`/usr/sbin/hddtemp -n /dev/hdc`
DISK5=`/usr/sbin/hddtemp -n /dev/hdd`
DISK6=`/usr/sbin/hddtemp -n /dev/hde`
DISK7=`/usr/sbin/hddtemp -n /dev/hdf`
DISK8=`/usr/sbin/hddtemp -n /dev/hdg`
DISK9=`/usr/sbin/hddtemp -n /dev/hdh`

echo "$DISK1" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK1= ; fi
echo "$DISK2" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK2= ; fi
echo "$DISK3" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK3= ; fi
echo "$DISK4" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK4= ; fi
echo "$DISK5" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK5= ; fi
echo "$DISK6" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK6= ; fi
echo "$DISK7" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK7= ; fi
echo "$DISK8" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK8= ; fi
echo "$DISK9" | grep -e "^[0-9]*$" ; if [ $? != 0 ] ; then DISK9= ; fi

# K8:
#   /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp1_input
# K10:
#   /sys/bus/pci/drivers/k10temp/0000:00:18.3/temp1_input
#   /sys/devices/pci0000:00/0000:00:18.3/temp1_input
CPU=`cat /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp1_input`
CPU=$(( ( $CPU + 500 ) / 1000 ))

/usr/bin/rrdtool update /opt/admin/temperature.rrd N:$CPU:$DISK1:$DISK2:$DISK3:$DISK4:$DISK5:$DISK6:$DISK7:$DISK8:$DISK9
echo '/usr/bin/rrdtool update /opt/admin/temperature.rrd N:$CPU:$DISK1:$DISK2:$DISK3:$DISK4:$DISK5:$DISK6:$DISK7:$DISK8:$DISK9'
echo "/usr/bin/rrdtool update /opt/admin/temperature.rrd N:$CPU:$DISK1:$DISK2:$DISK3:$DISK4:$DISK5:$DISK6:$DISK7:$DISK8:$DISK9"
logger "/usr/bin/rrdtool update /opt/admin/temperature.rrd N:$CPU:$DISK1:$DISK2:$DISK3:$DISK4:$DISK5:$DISK6:$DISK7:$DISK8:$DISK9"

fi


AREAOPTIONS=" \
 CDEF:online=ds,UN,0,ds,IF,0,GT,INF,UNKN,IF \
 CDEF:offline=ds,UN,0,ds,IF,0,GT,UNKN,INF,IF \
 AREA:online#EDFEED \
 AREA:offline#FEEDED \
 AREA:ds#ffcccc "


GRAPHOPTIONS="-v "Celcius" -x none -l 35 -u 45 -r -E"

/usr/bin/rrdtool graph /www/t0e/cputemp.png DEF:ds=/opt/admin/temperature.rrd:cpu:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"CPU Temperature" $GRAPHOPTIONS


GRAPHOPTIONS="-v "Celcius" -x none -l 30 -u 45 -r -E"

/usr/bin/rrdtool graph /www/t0e/disk1temp.png DEF:ds=/opt/admin/temperature.rrd:disk1:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk1 HDD Temperature" $GRAPHOPTIONS
/usr/bin/rrdtool graph /www/t0e/disk2temp.png DEF:ds=/opt/admin/temperature.rrd:disk2:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk2 HDD Temperature" $GRAPHOPTIONS
/usr/bin/rrdtool graph /www/t0e/disk3temp.png DEF:ds=/opt/admin/temperature.rrd:disk3:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk3 HDD Temperature" $GRAPHOPTIONS
/usr/bin/rrdtool graph /www/t0e/disk4temp.png DEF:ds=/opt/admin/temperature.rrd:disk4:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk4 HDD Temperature" $GRAPHOPTIONS
/usr/bin/rrdtool graph /www/t0e/disk5temp.png DEF:ds=/opt/admin/temperature.rrd:disk5:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk5 HDD Temperature" $GRAPHOPTIONS
/usr/bin/rrdtool graph /www/t0e/disk6temp.png DEF:ds=/opt/admin/temperature.rrd:disk6:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk6 HDD Temperature" $GRAPHOPTIONS
/usr/bin/rrdtool graph /www/t0e/disk7temp.png DEF:ds=/opt/admin/temperature.rrd:disk7:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk7 HDD Temperature" $GRAPHOPTIONS
/usr/bin/rrdtool graph /www/t0e/disk8temp.png DEF:ds=/opt/admin/temperature.rrd:disk8:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk8 HDD Temperature" $GRAPHOPTIONS
/usr/bin/rrdtool graph /www/t0e/disk9temp.png DEF:ds=/opt/admin/temperature.rrd:disk9:AVERAGE \
 $AREAOPTIONS \
 LINE3:ds#ff0000:"Disk9 HDD Temperature" $GRAPHOPTIONS