source: trunk/daemon/rrd_gather.py @ 163

Last change on this file since 163 was 1, checked in by bastiaans, 19 years ago

Initial import in repository

File size: 1.3 KB
Line 
1#!/usr/bin/env python
2
3import os
4import time
5
6# Location of rrdtool
7RRDTOOL_BIN = '/usr/bin/rrdtool'
8
9# Location of Ganglia's rrd's
10GANGLIA_RRD_DIR = '/var/lib/ganglia/rrds'
11
12# Location where you want our own rrd's stored
13#MYDATA_DIR = '/data/myrrds'
14MYDATA_DIR = '/tmp/ramdisk/myrrds'
15
16for root, dirs, files in os.walk( GANGLIA_RRD_DIR, topdown=False ):
17
18        for name in files:
19                if name.find('.rrd') != -1 and name.find('__SummaryInfo__') == -1:
20
21                        ganglia_rrd = os.path.join( root, name )
22                        rel_dir = ganglia_rrd[len(GANGLIA_RRD_DIR):]
23                        mydata_rrd = MYDATA_DIR + rel_dir
24
25                        if not os.path.isdir( MYDATA_DIR + os.path.dirname(rel_dir) ):
26                                #print 'mkdir ' + MYDATA_DIR + os.path.dirname(rel_dir)
27                                os.makedirs( MYDATA_DIR + os.path.dirname(rel_dir) )
28
29                        if os.path.exists( '/tmp/ramdisk/myblatemp.xml' ):
30                                os.remove( '/tmp/ramdisk/myblatemp.xml' )
31
32                        xml = open( '/tmp/ramdisk/myblatemp.xml', 'w' )
33       
34                        #print RRDTOOL_BIN + ' dump "' + ganglia_rrd + '" | head -271' 
35                        rrd_dump = os.popen( RRDTOOL_BIN + ' dump "' + ganglia_rrd + '" | head -271', 'r')
36
37                        for regel in rrd_dump.readlines():
38                                xml.write( regel )
39
40                        rrd_dump.close()
41
42                        xml.write( '</rrd>' )
43
44                        xml.close()
45
46                        #print RRDTOOL_BIN + ' restore /tmp/ramdisk/myblatemp.xml "' + mydata_rrd + '"'
47                        os.system( RRDTOOL_BIN + ' restore /tmp/ramdisk/myblatemp.xml "' + mydata_rrd + '"' )
Note: See TracBrowser for help on using the repository browser.