1RRDPYTHON(1) rrdtool RRDPYTHON(1)
2
3
4
6 rrdpython - About the RRD Python bindings
7
9 import rrdtool
10 rrdtool.create('/tmp/test.rrd', 'DS:foo:GAUGE:20:0:U')
11
13 The rrdtool functions are directly callable via the Python programming
14 language. This wrapper implementation has been written from the scratch
15 (without SWIG)
16
17 The API expects strings and/or a list of strings as parameters to the
18 functions. Please refer to the other rrdtool documentation for
19 functions and valid arguments.
20
22 Example 1
23 import sys
24 sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/')
25 import rrdtool, tempfile
26
27 DAY = 86400
28 YEAR = 365 * DAY
29 fd,path = tempfile.mkstemp('.png')
30
31 rrdtool.graph(path,
32 '--imgformat', 'PNG',
33 '--width', '540',
34 '--height', '100',
35 '--start', "-%i" % YEAR,
36 '--end', "-1",
37 '--vertical-label', 'Downloads/Day',
38 '--title', 'Annual downloads',
39 '--lower-limit', '0',
40 'DEF:downloads=downloads.rrd:downloads:AVERAGE',
41 'AREA:downloads#990033:Downloads')
42
43 info = rrdtool.info('downloads.rrd')
44 print info['last_update']
45 print info['ds[downloads].minimal_heartbeat']
46
47 Example 2
48 import sys
49 sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/')
50 import rrdtool
51
52 # in real life data_sources would be populated in loop or something similar
53 data_sources=[ 'DS:speed1:COUNTER:600:U:U',
54 'DS:speed2:COUNTER:600:U:U',
55 'DS:speed3:COUNTER:600:U:U' ]
56
57 rrdtool.create( 'speed.rrd',
58 '--start', '920804400',
59 data_sources,
60 'RRA:AVERAGE:0.5:1:24',
61 'RRA:AVERAGE:0.5:6:10' )
62
63 If you use the site-python-install make target you can drop to first
64 sys.path.append line since the RRDtool module will be available
65 everywhere.
66
67 If RRDtool runs into trouble, it will throw an exception which you
68 might want to catch.
69
71 rrdcreate, rrdupdate, rrdgraph, rrddump, rrdfetch, rrdtune, rrdlast,
72 rrdxport, rrdinfo
73
75 Hye-Shik Chang <perky@i18n.org>
76
77 Alan Milligan <alan.milligan@last-bastion.net>
78
79
80
811.8.0 2022-03-14 RRDPYTHON(1)