====== RRDTOOL ====== Referencia: http://oss.oetiker.ch/rrdtool/ ===== Crear la Base de datos ===== Por ejemplo queremos hacer una gráfica de tiempo de respuesta de una servicio Los datos serían estos: Día: 26/11/2010 ^^Hora^^msecs^^ ||0800||1245|| ||0830||807|| ||0900||1876|| ||0930||572|| ||1000||549|| ||1030||590|| ||1100||410|| ||1130||611|| ||1200||0|| ||1230||788|| ||1300||349|| ||1330||542|| ||1400||576|| ||1430||661|| ||1500||659|| La fecha tiene que estar en UNIX time, que son los segundos que han pasado desde el 1 enero de 1970, para convertir una fecha a unixtime usamos: # date +%s -d"2010-11-26 08:00:00" 1290754800 Para crear la Base de Datos seguimos el siguiente formato: rrdtool create .rrd --start --step= DS::::: RRA:CF:xff:step:rows * tiempo_inicio= tiempo de la primera medición en UNIX TIME * tiempo_medicion= cada cuanto tiempo se toma una muestra en segundos. Si se omite esta opción, son 300 (5 minutos) * nombre_variable= nombre del campo en la base de datos * DST= puede ser COUNTER, DERIVE, ABSOLUTE, GAUGE * heartbeat= cada cuanto se fuerza la medida. Si por ejemplo son 300 segundos y el heartbeat es de 600, esperarà 600 segundos y sinó pondrá un UNKNOWN * min y max: si no se sabe se pone U y lo cálcula Falta traducir y resumir de http://oss.oetiker.ch/rrdtool/tut/rrd-beginners.en.html RRA:CF:xff:step:rows Lets have a look at the example above. For the first RRA, 12 (steps) PDPs (DS variables) are AVERAGEed (CF) to form one CDP. 24 (rows) of theses CDPs are archived. Each PDP occurs at 300 seconds. 12 PDPs represent 12 times 300 seconds which is 1 hour. It means 1 CDP (which is equal to 12 PDPs) represents data worth 1 hour. 24 such CDPs represent 1 day (1 hour times 24 CDPs). This means, this RRA is an archive for one day. After 24 CDPs, CDP number 25 will replace the 1st CDP. The second RRA saves 31 CDPs; each CPD represents an AVERAGE value for a day (288 PDPs, each covering 300 seconds = 24 hours). Therefore this RRA is an archive for one month. A single database can have many RRAs. If there are multiple DSs, each individual RRA will save data for all the DSs in the database. For example, if a database has 3 DSs and daily, weekly, monthly, and yearly RRAs are declared, then each RRA will hold data from all 3 data sources. * CF= AVERAGE, MINIMUM, MAXIMUM, and LAST Ponemos que empieza 30 minutos antes que la primera medición: rrdtool create tiempo_respuesta.rrd --start 1290753000 --step=1800 DS:respuesta:GAUGE:1800:0:10000 RRA:LAST:0.5:1:24 ===== Introduciendo los datos ===== Cambiamos las fechas a UNIX Time, queda tal que así: Con lo que los datos nos quedarían: ^^Hora^^msecs^^ ||1290754800||1245|| ||1290756600||807|| ||1290758400||1876|| ||etc...|| rrdtool update tiempo_respuesta.rrd 1290754800:1245 1290756600:807 1290758400:1876 1290760200:572 1290762000:549 1290763800:590 1290765600:410 1290767400:611 1290769200:0 1290771000:788 1290772800:349 1290774600:542 1290776400:576 1290778200:661 1290780000:659 ===== Crear el gráfico ===== rrdtool graph tiempo_respuesta.png --start 1290754800 --end 1290780000 DEF:respuesta=tiempo_respuesta.rrd:respuesta:LAST LINE2:respuesta#FF0000 {{informatica:linux:tiempo_respuesta.png|}} ===== Ejemplos ===== ==== Max, min y media ==== rrdtool create min.rrd --start 1290753000 --step=1800 DS:respuesta:GAUGE:1800:0:10000 RRA:LAST:0.5:1:24 rrdtool create max.rrd --start 1290753000 --step=1800 DS:respuesta:GAUGE:1800:0:10000 RRA:LAST:0.5:1:24 rrdtool create avg.rrd --start 1290753000 --step=1800 DS:respuesta:GAUGE:1800:0:10000 RRA:LAST:0.5:1:24 rrdtool update min.rrd 1290754800:1245 1290756600:807 1290758400:1876 1290760200:572 1290762000:549 1290763800:590 1290765600:410 1290767400:611 1290769200:0 1290771000:788 1290772800:349 1290774600:542 1290776400:576 1290778200:661 1290780000:659 rrdtool update avg.rrd 1290754800:2345 1290756600:1407 1290758400:2176 1290760200:672 1290762000:749 1290763800:790 1290765600:810 1290767400:611 1290769200:123 1290771000:988 1290772800:649 1290774600:742 1290776400:976 1290778200:671 1290780000:959 rrdtool update max.rrd 1290754800:2845 1290756600:1607 1290758400:2276 1290760200:772 1290762000:949 1290763800:1090 1290765600:1010 1290767400:811 1290769200:423 1290771000:1488 1290772800:949 1290774600:942 1290776400:1376 1290778200:871 1290780000:1559 rdtool graph tiempo_respuesta.png --start 1290754800 --end 1290780000 DEF:min=min.rrd:respuesta:LAST LINE1:min#002A97FF DEF:avg=avg.rrd:respuesta:LAST LINE1:avg#000000 DEF:max=max.rrd:respuesta:LAST LINE1:max#FF0000 {{informatica:linux:minavgmax.png|}} ====== XGRAPH ====== Se instala la aplicación xgraph ===== Salida por las X ===== Genera una gráfica en entorno gráfico.\\ Se crea un fichero.txt con estos datos: TitleText: Sample Data 0.5 7.8 1.0 6.2 "set one 1.5 8.9 "set two" -3.4 1.4e-3 -2.0 1.9e-2 move -1.0 2.0e-2 -0.65 2.2e-4 2.2 12.8 2.4 -3.3 2.6 -32.2 2.8 -10.3 Y se ejecuta: xgraph fichero.txt {{informatica:linux:grafico_xgrap.png|}} ===== Salida en un fichero ===== Hay que bajarse la versión de la web http://www.xgraph.org # xgraph -pdf fichero.txt -out_file fichero.pdf Da error con la versión de repositorios: # xgraph -device ps -o prueba.ps pruebaxgraph.txt Fallo de segmentación