make rrdtool compile with gcc 4.5 if -std=c99 is set -- anicka@suse.cz
[rrdtool.git] / doc / rrdpython.pod
1 =head1 NAME
2
3 rrdpython - About the RRD Python bindings
4
5 =head1 SYNOPSIS
6
7  import rrdtool
8  rrdtool.create('/tmp/test.rrd', 'DS:foo:GAUGE:20:0:U')
9
10 =head1 DESCRIPTION
11
12 The B<rrdtool> functions are directly callable via the Python programming
13 language. This wrapper implementation has been written from the scratch
14 (without  SWIG)
15
16 The API's expects strings and/or list of strings as parameters to the functions.
17 Please refer to the other B<rrdtool> documentation for functions and valid arguments.
18
19 =head1 EXAMPLES
20
21 =head2 Example 1
22
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 =head2 Example 2
48
49  import sys
50  sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/')
51  import rrdtool
52
53  # in real life data_sources would be populated in loop or something similar
54  data_sources=[ 'DS:speed1:COUNTER:600:U:U',
55                 'DS:speed2:COUNTER:600:U:U',
56                 'DS:speed3:COUNTER:600:U:U' ]
57
58  rrdtool.create( 'speed.rrd',
59                  '--start', '920804400',
60                  data_sources,
61                  'RRA:AVERAGE:0.5:1:24',
62                  'RRA:AVERAGE:0.5:6:10' )
63
64 If you use the B<site-python-install> make target you can drop to first sys.path.append
65 line since the RRDtool module will be available everywhere.
66
67 If RRDtool runs into trouble, it will throw an exception which you might want to catch.
68
69 =head1 SEE ALSO
70
71 rrdcreate, rrdupdate, rrdgraph, rrddump, rrdfetch, rrdtune, rrdlast,
72 rrdxport, rrdinfo
73
74 =head1 AUTHOR
75
76 Hye-Shik Chang E<lt>perky@i18n.orgE<gt>
77
78 Alan Milligan E<lt>alan.milligan@last-bastion.netE<gt>