RRDPYTHON(1)

πŸ“¦
version 1.11.0 Β· 3 versions
, in arch rolling

πŸŽ€ RRDPYTHON(1) β€” from the rrdtool manual πŸŽ€

🌸 NAME 🌸

rrdpython β€” about the RRD Python bindings, bestie. No cap. πŸ’…


✨ SYNOPSIS ✨

import rrdtool
rrdtool.create('/tmp/test.rrd', 'DS:foo:GAUGE:20:0:U')

πŸ’– DESCRIPTION πŸ’–

The rrdtool functions are directly callable via the Python programming language. This wrapper implementation was written from scratch (without SWIG), and that's iconic. 🫢

The API expects strings and/or a list of strings as parameters to the functions. Please refer to the other rrdtool documentation for functions and valid arguments. iykyk. πŸ‘‘


🌈 EXAMPLES 🌈

πŸ¦‹ Example 1 πŸ¦‹

import sys
sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/')
import rrdtool, tempfile

DAY = 86400
YEAR = 365 * DAY
fd,path = tempfile.mkstemp('.png')

rrdtool.graph(path,
             '--imgformat', 'PNG',
             '--width', '540',
             '--height', '100',
             '--start', "-%i" % YEAR,
             '--end', "-1",
             '--vertical-label', 'Downloads/Day',
             '--title', 'Annual downloads',
             '--lower-limit', '0',
             'DEF:downloads=downloads.rrd:downloads:AVERAGE',
             'AREA:downloads#990033:Downloads')

info = rrdtool.info('downloads.rrd')
print info['last_update']
print info['ds[downloads].minimal_heartbeat']

πŸ“ Example 2 πŸ“

import sys
sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/')
import rrdtool

# in real life data_sources would be populated in loop or something similar
data_sources=[ 'DS:speed1:COUNTER:600:U:U',
               'DS:speed2:COUNTER:600:U:U',
               'DS:speed3:COUNTER:600:U:U' ]

rrdtool.create( 'speed.rrd',
                '--start', '920804400',
                data_sources,
                'RRA:AVERAGE:0.5:1:24',
                'RRA:AVERAGE:0.5:6:10' )

If you use the site-python-install make target, you can drop that first sys.path.append line β€” the RRDtool module will be available everywhere. slay ✨

If RRDtool runs into trouble, it will throw an exception which you might want to catch. πŸ‘€

πŸ‘€ SEE ALSO πŸ‘€

  • rrdcreate
  • rrdupdate
  • rrdgraph
  • rrddump
  • rrdfetch
  • rrdtune
  • rrdlast
  • rrdxport
  • rrdinfo

πŸ’Œ AUTHOR πŸ’Œ

  • Hye-Shik Chang <perky@i18n.org>
  • Alan Milligan <alan.milligan@last-bastion.net>

mwah πŸ’‹ signing off with source/version 1.11.0, dated 2026-10-17. πŸ’…βœ¨

πŸ“¦ where this page comes from