Import rrdtool Script

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
Wirthmueller
Cacti User
Posts: 60
Joined: Wed Mar 02, 2011 9:02 am

Import rrdtool Script

Post by Wirthmueller »

I have adapted a bash script I have found here: https://www.blesk.ca/wp-content/uploads ... RDtool.pdf

Code: Select all

#!/bin/sh
rrdtool graph ozone2.png \
--imgformat=PNG \
--start='-432000' \
--end='+86400' \
--pango-markup \
--upper-limit=100 \
--title='FHEM Atmosphere' \
--units-exponent=2 \
--vertical-label='Ozone Concentration (O3 ppm)' \
--slope-mode \
--base=1000 \
--height=200 \
--width=650 \
--alt-autoscale \
COMMENT:"From 18-07-2022 10\:48\:23 To 19-07-2022 10\:47\:23\c" \
COMMENT:"  \n" \
--color BACK#F3F3F3 \
--color CANVAS#FDFDFD \
--color SHADEA#CBCBCB \
--color SHADEB#999999 \
--color FONT#000000 \
--color AXIS#2C4D43 \
--color ARROW#2C4D43 \
--color FRAME#2C4D43 \
--font AXIS:8:'Arial' \
--font LEGEND:8:'Courier' \
--font UNIT:8:'Arial' \
--font WATERMARK:6:'Arial' \
--slope-mode \
--watermark 'Generated by Cacti' \
DEF:a='/usr/share/cacti/site/rra/localhost_no2_1201.rrd':O3:AVERAGE:step=300 \
DEF:a1='/usr/share/cacti/site/rra/localhost_no2_1201.rrd':O3:MAX:step=300 \
DEF:a2='/usr/share/cacti/site/rra/localhost_no2_1201.rrd':O3:MIN:step=300 \
DEF:a3='/usr/share/cacti/site/rra/localhost_no2_1201.rrd':O3:LAST:step=300 \
CDEF:idle=a,0.00,EQ,INF,0,IF \
CDEF:smooth=a,1800,TREND \
CDEF:predict=86400,-7,900,a,PREDICT \
CDEF:sigma=86400,-7,900,a,PREDICTSIGMA \
VDEF:avg=a,AVERAGE \
GPRINT:a:AVERAGE:"Ozone Concentration Avg\: %8.0lf" \
GPRINT:a1:MAX:"Max\: %8.0lf" \
GPRINT:a2:MIN:"Min\: %8.0lf" \
GPRINT:a3:LAST:"Last\: %8.0lf\n" \
AREA:a#00B2EE:"CPU Util\n" \
AREA:idle#AFEEEE \
LINE2:avg#00FF00:"Avg\n":dashes=5 \
LINE2:predict#FF00FF:"Trend Prediction\n":dashes=5 \
LINE1:smooth#FF0000:"Sliding Window Smoothing":dashes=5 \
The graph is successfully created using bash command:
ozone2.png
ozone2.png (46.49 KiB) Viewed 497 times
Now my question is if there is a way to import such a script into cacti?
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Import rrdtool Script

Post by TheWitness »

Give us the output of rrdtool info localhost_no2_1201.rrd

Very cool BTW. The answer could be yes.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Import rrdtool Script

Post by TheWitness »

Disregard that comment. Cacti can do it. This is super cool BTW. Thanks for the tip.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Wirthmueller
Cacti User
Posts: 60
Joined: Wed Mar 02, 2011 9:02 am

Re: Import rrdtool Script

Post by Wirthmueller »

So how would I do it with cacti? Do I need to create a graph template or can I use a cli-command?

rrdtool info localhost_no2_1201.rrd gives:

Code: Select all

filename = "/usr/share/cacti/site/rra/localhost_no2_1201.rrd"
rrd_version = "0003"
step = 60
last_update = 1658300222
header_size = 10032
ds[NO2].index = 0
ds[NO2].type = "GAUGE"
ds[NO2].minimal_heartbeat = 600
ds[NO2].min = 0.0000000000e+00
ds[NO2].max = NaN
ds[NO2].last_ds = "29"
ds[NO2].value = 5.8000000000e+01
ds[NO2].unknown_sec = 0
ds[O3].index = 1
ds[O3].type = "GAUGE"
ds[O3].minimal_heartbeat = 600
ds[O3].min = 0.0000000000e+00
ds[O3].max = NaN
ds[O3].last_ds = "38"
ds[O3].value = 7.6000000000e+01
ds[O3].unknown_sec = 0
ds[PM25].index = 2
ds[PM25].type = "GAUGE"
ds[PM25].minimal_heartbeat = 600
ds[PM25].min = 0.0000000000e+00
ds[PM25].max = NaN
ds[PM25].last_ds = "15"
ds[PM25].value = 3.0000000000e+01
ds[PM25].unknown_sec = 0
ds[PM10].index = 3
ds[PM10].type = "GAUGE"
ds[PM10].minimal_heartbeat = 600
ds[PM10].min = 0.0000000000e+00
ds[PM10].max = NaN
ds[PM10].last_ds = "33"
ds[PM10].value = 6.6000000000e+01
ds[PM10].unknown_sec = 0
rra[0].cf = "AVERAGE"
rra[0].rows = 240
rra[0].cur_row = 81
rra[0].pdp_per_row = 1
rra[0].xff = 5.0000000000e-01
rra[0].cdp_prep[0].value = NaN
rra[0].cdp_prep[0].unknown_datapoints = 0
rra[0].cdp_prep[1].value = NaN
rra[0].cdp_prep[1].unknown_datapoints = 0
rra[0].cdp_prep[2].value = NaN
rra[0].cdp_prep[2].unknown_datapoints = 0
rra[0].cdp_prep[3].value = NaN
rra[0].cdp_prep[3].unknown_datapoints = 0
rra[1].cf = "AVERAGE"
rra[1].rows = 290
rra[1].cur_row = 114
rra[1].pdp_per_row = 5
rra[1].xff = 5.0000000000e-01
rra[1].cdp_prep[0].value = 5.8000000000e+01
rra[1].cdp_prep[0].unknown_datapoints = 0
rra[1].cdp_prep[1].value = 7.6000000000e+01
rra[1].cdp_prep[1].unknown_datapoints = 0
rra[1].cdp_prep[2].value = 3.0000000000e+01
rra[1].cdp_prep[2].unknown_datapoints = 0
rra[1].cdp_prep[3].value = 6.6000000000e+01
rra[1].cdp_prep[3].unknown_datapoints = 0
rra[2].cf = "AVERAGE"
rra[2].rows = 336
rra[2].cur_row = 110
rra[2].pdp_per_row = 30
rra[2].xff = 5.0000000000e-01
rra[2].cdp_prep[0].value = 7.8300000000e+02
rra[2].cdp_prep[0].unknown_datapoints = 0
rra[2].cdp_prep[1].value = 1.0342666667e+03
rra[2].cdp_prep[1].unknown_datapoints = 0
rra[2].cdp_prep[2].value = 4.0500000000e+02
rra[2].cdp_prep[2].unknown_datapoints = 0
rra[2].cdp_prep[3].value = 8.8996666667e+02
rra[2].cdp_prep[3].unknown_datapoints = 0
rra[3].cf = "AVERAGE"
rra[3].rows = 372
rra[3].cur_row = 159
rra[3].pdp_per_row = 120
rra[3].xff = 5.0000000000e-01
rra[3].cdp_prep[0].value = 1.6530000000e+03
rra[3].cdp_prep[0].unknown_datapoints = 0
rra[3].cdp_prep[1].value = 2.4142666667e+03
rra[3].cdp_prep[1].unknown_datapoints = 0
rra[3].cdp_prep[2].value = 8.5500000000e+02
rra[3].cdp_prep[2].unknown_datapoints = 0
rra[3].cdp_prep[3].value = 1.8499666667e+03
rra[3].cdp_prep[3].unknown_datapoints = 0
rra[4].cf = "AVERAGE"
rra[4].rows = 366
rra[4].cur_row = 361
rra[4].pdp_per_row = 1440
rra[4].xff = 5.0000000000e-01
rra[4].cdp_prep[0].value = 1.2354066667e+04
rra[4].cdp_prep[0].unknown_datapoints = 11
rra[4].cdp_prep[1].value = 2.9895500000e+04
rra[4].cdp_prep[1].unknown_datapoints = 11
rra[4].cdp_prep[2].value = 5.7309333333e+03
rra[4].cdp_prep[2].unknown_datapoints = 11
rra[4].cdp_prep[3].value = 1.2778900000e+04
rra[4].cdp_prep[3].unknown_datapoints = 11
rra[5].cf = "MIN"
rra[5].rows = 240
rra[5].cur_row = 186
rra[5].pdp_per_row = 1
rra[5].xff = 5.0000000000e-01
rra[5].cdp_prep[0].value = NaN
rra[5].cdp_prep[0].unknown_datapoints = 0
rra[5].cdp_prep[1].value = NaN
rra[5].cdp_prep[1].unknown_datapoints = 0
rra[5].cdp_prep[2].value = NaN
rra[5].cdp_prep[2].unknown_datapoints = 0
rra[5].cdp_prep[3].value = NaN
rra[5].cdp_prep[3].unknown_datapoints = 0
rra[6].cf = "MIN"
rra[6].rows = 290
rra[6].cur_row = 146
rra[6].pdp_per_row = 5
rra[6].xff = 5.0000000000e-01
rra[6].cdp_prep[0].value = 2.9000000000e+01
rra[6].cdp_prep[0].unknown_datapoints = 0
rra[6].cdp_prep[1].value = 3.8000000000e+01
rra[6].cdp_prep[1].unknown_datapoints = 0
rra[6].cdp_prep[2].value = 1.5000000000e+01
rra[6].cdp_prep[2].unknown_datapoints = 0
rra[6].cdp_prep[3].value = 3.3000000000e+01
rra[6].cdp_prep[3].unknown_datapoints = 0
rra[7].cf = "MIN"
rra[7].rows = 336
rra[7].cur_row = 56
rra[7].pdp_per_row = 30
rra[7].xff = 5.0000000000e-01
rra[7].cdp_prep[0].value = 2.9000000000e+01
rra[7].cdp_prep[0].unknown_datapoints = 0
rra[7].cdp_prep[1].value = 3.8000000000e+01
rra[7].cdp_prep[1].unknown_datapoints = 0
rra[7].cdp_prep[2].value = 1.5000000000e+01
rra[7].cdp_prep[2].unknown_datapoints = 0
rra[7].cdp_prep[3].value = 3.2000000000e+01
rra[7].cdp_prep[3].unknown_datapoints = 0
rra[8].cf = "MIN"
rra[8].rows = 372
rra[8].cur_row = 245
rra[8].pdp_per_row = 120
rra[8].xff = 5.0000000000e-01
rra[8].cdp_prep[0].value = 2.9000000000e+01
rra[8].cdp_prep[0].unknown_datapoints = 0
rra[8].cdp_prep[1].value = 3.8000000000e+01
rra[8].cdp_prep[1].unknown_datapoints = 0
rra[8].cdp_prep[2].value = 1.5000000000e+01
rra[8].cdp_prep[2].unknown_datapoints = 0
rra[8].cdp_prep[3].value = 3.2000000000e+01
rra[8].cdp_prep[3].unknown_datapoints = 0
rra[9].cf = "MIN"
rra[9].rows = 366
rra[9].cur_row = 4
rra[9].pdp_per_row = 1440
rra[9].xff = 5.0000000000e-01
rra[9].cdp_prep[0].value = 2.9000000000e+01
rra[9].cdp_prep[0].unknown_datapoints = 11
rra[9].cdp_prep[1].value = 3.8000000000e+01
rra[9].cdp_prep[1].unknown_datapoints = 11
rra[9].cdp_prep[2].value = 1.3000000000e+01
rra[9].cdp_prep[2].unknown_datapoints = 11
rra[9].cdp_prep[3].value = 3.0000000000e+01
rra[9].cdp_prep[3].unknown_datapoints = 11
rra[10].cf = "MAX"
rra[10].rows = 240
rra[10].cur_row = 198
rra[10].pdp_per_row = 1
rra[10].xff = 5.0000000000e-01
rra[10].cdp_prep[0].value = NaN
rra[10].cdp_prep[0].unknown_datapoints = 0
rra[10].cdp_prep[1].value = NaN
rra[10].cdp_prep[1].unknown_datapoints = 0
rra[10].cdp_prep[2].value = NaN
rra[10].cdp_prep[2].unknown_datapoints = 0
rra[10].cdp_prep[3].value = NaN
rra[10].cdp_prep[3].unknown_datapoints = 0
rra[11].cf = "MAX"
rra[11].rows = 290
rra[11].cur_row = 280
rra[11].pdp_per_row = 5
rra[11].xff = 5.0000000000e-01
rra[11].cdp_prep[0].value = 2.9000000000e+01
rra[11].cdp_prep[0].unknown_datapoints = 0
rra[11].cdp_prep[1].value = 3.8000000000e+01
rra[11].cdp_prep[1].unknown_datapoints = 0
rra[11].cdp_prep[2].value = 1.5000000000e+01
rra[11].cdp_prep[2].unknown_datapoints = 0
rra[11].cdp_prep[3].value = 3.3000000000e+01
rra[11].cdp_prep[3].unknown_datapoints = 0
rra[12].cf = "MAX"
rra[12].rows = 336
rra[12].cur_row = 281
rra[12].pdp_per_row = 30
rra[12].xff = 5.0000000000e-01
rra[12].cdp_prep[0].value = 2.9000000000e+01
rra[12].cdp_prep[0].unknown_datapoints = 0
rra[12].cdp_prep[1].value = 4.6000000000e+01
rra[12].cdp_prep[1].unknown_datapoints = 0
rra[12].cdp_prep[2].value = 1.5000000000e+01
rra[12].cdp_prep[2].unknown_datapoints = 0
rra[12].cdp_prep[3].value = 3.3000000000e+01
rra[12].cdp_prep[3].unknown_datapoints = 0
rra[13].cf = "MAX"
rra[13].rows = 372
rra[13].cur_row = 24
rra[13].pdp_per_row = 120
rra[13].xff = 5.0000000000e-01
rra[13].cdp_prep[0].value = 2.9000000000e+01
rra[13].cdp_prep[0].unknown_datapoints = 0
rra[13].cdp_prep[1].value = 4.6000000000e+01
rra[13].cdp_prep[1].unknown_datapoints = 0
rra[13].cdp_prep[2].value = 1.5000000000e+01
rra[13].cdp_prep[2].unknown_datapoints = 0
rra[13].cdp_prep[3].value = 3.3000000000e+01
rra[13].cdp_prep[3].unknown_datapoints = 0
rra[14].cf = "MAX"
rra[14].rows = 366
rra[14].cur_row = 239
rra[14].pdp_per_row = 1440
rra[14].xff = 5.0000000000e-01
rra[14].cdp_prep[0].value = 3.1000000000e+01
rra[14].cdp_prep[0].unknown_datapoints = 11
rra[14].cdp_prep[1].value = 8.9000000000e+01
rra[14].cdp_prep[1].unknown_datapoints = 11
rra[14].cdp_prep[2].value = 1.5000000000e+01
rra[14].cdp_prep[2].unknown_datapoints = 11
rra[14].cdp_prep[3].value = 3.3000000000e+01
rra[14].cdp_prep[3].unknown_datapoints = 11
rra[15].cf = "LAST"
rra[15].rows = 240
rra[15].cur_row = 147
rra[15].pdp_per_row = 1
rra[15].xff = 5.0000000000e-01
rra[15].cdp_prep[0].value = NaN
rra[15].cdp_prep[0].unknown_datapoints = 0
rra[15].cdp_prep[1].value = NaN
rra[15].cdp_prep[1].unknown_datapoints = 0
rra[15].cdp_prep[2].value = NaN
rra[15].cdp_prep[2].unknown_datapoints = 0
rra[15].cdp_prep[3].value = NaN
rra[15].cdp_prep[3].unknown_datapoints = 0
rra[16].cf = "LAST"
rra[16].rows = 290
rra[16].cur_row = 192
rra[16].pdp_per_row = 5
rra[16].xff = 5.0000000000e-01
rra[16].cdp_prep[0].value = 2.9000000000e+01
rra[16].cdp_prep[0].unknown_datapoints = 0
rra[16].cdp_prep[1].value = 3.8000000000e+01
rra[16].cdp_prep[1].unknown_datapoints = 0
rra[16].cdp_prep[2].value = 1.5000000000e+01
rra[16].cdp_prep[2].unknown_datapoints = 0
rra[16].cdp_prep[3].value = 3.3000000000e+01
rra[16].cdp_prep[3].unknown_datapoints = 0
rra[17].cf = "LAST"
rra[17].rows = 336
rra[17].cur_row = 203
rra[17].pdp_per_row = 30
rra[17].xff = 5.0000000000e-01
rra[17].cdp_prep[0].value = 2.9000000000e+01
rra[17].cdp_prep[0].unknown_datapoints = 0
rra[17].cdp_prep[1].value = 3.8000000000e+01
rra[17].cdp_prep[1].unknown_datapoints = 0
rra[17].cdp_prep[2].value = 1.5000000000e+01
rra[17].cdp_prep[2].unknown_datapoints = 0
rra[17].cdp_prep[3].value = 3.3000000000e+01
rra[17].cdp_prep[3].unknown_datapoints = 0
rra[18].cf = "LAST"
rra[18].rows = 372
rra[18].cur_row = 21
rra[18].pdp_per_row = 120
rra[18].xff = 5.0000000000e-01
rra[18].cdp_prep[0].value = 2.9000000000e+01
rra[18].cdp_prep[0].unknown_datapoints = 0
rra[18].cdp_prep[1].value = 3.8000000000e+01
rra[18].cdp_prep[1].unknown_datapoints = 0
rra[18].cdp_prep[2].value = 1.5000000000e+01
rra[18].cdp_prep[2].unknown_datapoints = 0
rra[18].cdp_prep[3].value = 3.3000000000e+01
rra[18].cdp_prep[3].unknown_datapoints = 0
rra[19].cf = "LAST"
rra[19].rows = 366
rra[19].cur_row = 217
rra[19].pdp_per_row = 1440
rra[19].xff = 5.0000000000e-01
rra[19].cdp_prep[0].value = 2.9000000000e+01
rra[19].cdp_prep[0].unknown_datapoints = 11
rra[19].cdp_prep[1].value = 3.8000000000e+01
rra[19].cdp_prep[1].unknown_datapoints = 11
rra[19].cdp_prep[2].value = 1.5000000000e+01
rra[19].cdp_prep[2].unknown_datapoints = 11
rra[19].cdp_prep[3].value = 3.3000000000e+01
rra[19].cdp_prep[3].unknown_datapoints = 11
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Import rrdtool Script

Post by TheWitness »

Most of this is CDEF and VDEF magic. You have to create the CDEFS and CDEFS and then build the Graph Template with them. The trick is to use the SPECIAL DATA SOURCE of "Current Data Source" when building them.

Those prediction functions my not be defined yet, and we have to determine in what release the were introduced. But in the mean time you can use a string to emulate.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests