Beispiel #1
0
 def update_rrd(self, path, time_at, values):
     import rrdtool
     import time
     from utilities.utils import flatten
     time_at = int(time.mktime(time_at.timetuple()))
     vals = list(flatten([time_at, values]))
     vals = map(lambda x: str(x), vals)
     rrdtool.update(str(path), ':'.join(vals))
Beispiel #2
0
 def table_graph(self, tables, since, type_='full'):
     msgs = []
     ok = True
     for tbl in flatten([tables]):
         path = settings.FORMATTER_OPTIONS.get('rrd', {}).get('path', '')
         rrd_path = os.path.join(path, tbl.schema.server.name, tbl.schema.name, '%s.rrd' % (tbl.name))
         opts = self.__common_opts('table_%s_%s_%s' % (tbl.schema.server.name, tbl.schema.name, tbl.name),
                                     since, type_, 'Table - %s.%s.%s' % (tbl.schema.server.name, tbl.schema.name, tbl.name))
                                     
         opts.append(map(lambda ds: self.__common_ds_opts(ds, rrd_path), [
             ['data_length', ['AREA%s:STACK', '#00ff40']],
             ['index_length', ['AREA%s', '#0040ff']],
             #['data_free', ['LINE2%s', '#0f00f0']],
         ]))
         
         opts = flatten(opts)
         opts = map(lambda x: str(x), opts)
         try:
             rrdtool.graph(opts)
         except Exception, e:
             msgs.append(e)
             ok = False
Beispiel #3
0
 def server_graph(self, servers, since, type_='full'):
     msgs = []
     ok = True
     for srv in flatten([servers]):
         path = settings.FORMATTER_OPTIONS.get('rrd', {}).get('path', '')
         rrd_path = os.path.join(path, srv.name, 'server_%s.rrd' % (srv.name))
         opts = self.__common_opts('server_%s' % (srv.name), since, type_, 'Server Aggregate - %s' % (srv.name))
         
         opts.append(map(lambda ds: self.__common_ds_opts(ds, rrd_path), [
             ['data_length', ['AREA%s:STACK', '#00ff40']],
             ['index_length', ['AREA%s', '#0040ff']],
             #['data_free', ['LINE2%s', '#0f00f0']],
         ]))
         
         opts = flatten(opts)
         opts = map(lambda x: str(x), opts)
         
         try:
             rrdtool.graph(opts)
         except Exception, e:
             msgs.append(e)
             ok = False
Beispiel #4
0
 def test_flatten(self):
     sample_list = [[1,[2],[3, [4, [5]]]]]
     flat_list = [1,2,3,4,5]
     self.assertEqual(flat_list, list(flatten(sample_list)))
 def __init__(self, debug, *args):
     self.debug = debug
     self.args = list(flatten(args))