Last change
on this file since 179 was
1,
checked in by bastiaans, 19 years ago
|
Initial import in repository
|
File size:
939 bytes
|
Rev | Line | |
---|
[1] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import rrdtool |
---|
| 4 | import os |
---|
| 5 | |
---|
| 6 | class Toga: |
---|
| 7 | |
---|
| 8 | def RrdMerge(self, rrd1, rrd2, newrrd): |
---|
| 9 | |
---|
| 10 | rrdtool.resize( rrd1, '0', 'GROW', '240' ) |
---|
| 11 | os.rename( './resize.rrd', newrrd ) |
---|
| 12 | |
---|
| 13 | newvals = rrdtool.fetch( rrd2, 'AVERAGE', '-r', '15', '-s', '10:55', '-e', '11:55' ) |
---|
| 14 | print newvals |
---|
| 15 | times = newvals[0] |
---|
| 16 | |
---|
| 17 | start_time = times[0] |
---|
| 18 | end_time = times[1] |
---|
| 19 | time_interval = times[2] |
---|
| 20 | |
---|
| 21 | last = rrdtool.last( rrd1 ) |
---|
| 22 | |
---|
| 23 | dss = newvals[1] |
---|
| 24 | ds = dss[0] |
---|
| 25 | |
---|
| 26 | values = newvals[2] |
---|
| 27 | |
---|
| 28 | loop_count = 0 |
---|
| 29 | for val in values: |
---|
| 30 | timestamp = start_time + ( loop_count * time_interval ) |
---|
| 31 | update_string = '%s:%s' %(timestamp, val[0]) |
---|
| 32 | if timestamp > last and val[0]: |
---|
| 33 | print 'rrdtool update %s -t sum %s' %(newrrd, update_string) |
---|
| 34 | rrdtool.update( newrrd, '-t', 'sum', update_string ) |
---|
| 35 | loop_count = loop_count + 1 |
---|
| 36 | |
---|
| 37 | def main(): |
---|
| 38 | |
---|
| 39 | t = Toga() |
---|
| 40 | |
---|
| 41 | t.RrdMerge( '/tmp/test_cpu_num01.rrd', '/tmp/test_cpu_num02.rrd', './test_cpu_merged.rrd' ) |
---|
| 42 | |
---|
| 43 | main() |
---|
Note: See
TracBrowser
for help on using the repository browser.