예제 #1
0
def main():
    parser = ArgumentParser(description='PGObserver Frontend')
    parser.add_argument('-c', '--config', help='Path to config file. (default: %s)' % DEFAULT_CONF_FILE, dest='config',
                        default=DEFAULT_CONF_FILE)
    parser.add_argument('-p', '--port', help='server port', dest='port', type=int)

    args = parser.parse_args()

    args.config = os.path.expanduser(args.config)

    if not os.path.exists(args.config):
        print 'Configuration file missing:', args.config
        parser.print_help()
        return

    with open(args.config, 'rb') as fd:
        settings = json.load(fd)

    conn_string = ' '.join((
        'dbname=' + settings['database']['name'],
        'host=' + settings['database']['host'],
        'user='******'database']['frontend_user'],
        'password='******'database']['frontend_password'],
        'port=' + str(settings['database']['port']),
    ))

    print 'Setting connection string to ... ' + conn_string

    DataDB.setConnectionString(conn_string)

    if 'logfiles' in settings:
        logdata.setFilter(settings['logfiles']['liveuserfilter'])

    current_dir = os.path.dirname(os.path.abspath(__file__))

    conf = {'global': {'server.socket_host': '0.0.0.0', 'server.socket_port': args.port or settings.get('frontend',
            {}).get('port') or 8080}, '/': {'tools.staticdir.root': current_dir},
            '/static': {'tools.staticdir.dir': 'static', 'tools.staticdir.on': True}}

    tplE.setup(settings)

    root = None

    for h in hosts.getHostData().values():
        mf = MonitorFrontend.MonitorFrontend(h['host_id'])

        if root == None:
            root = mf

        setattr(root, h['uishortname'], mf)

    root.report = report.Report()
    root.export = export.Export()
    root.perftables = performance.PerfTables()
    root.perfapi = performance.PerfApi()
    root.perfindexes = performance.PerfIndexes()
    root.sprocs = sprocsfrontend.SprocFrontend()
    root.tables = tablesfrontend.TableFrontend()

    cherrypy.quickstart(root, config=conf)
예제 #2
0
def main():
    parser = ArgumentParser(description = 'PGObserver Frontend')
    parser.add_argument('-c', '--config', help = 'Path to config file. (default: %s)' % DEFAULT_CONF_FILE, dest="config" , default = DEFAULT_CONF_FILE)

    args = parser.parse_args()

    args.config = os.path.expanduser(args.config)

    if not os.path.exists(args.config):
        print 'Configuration file missing:', args.config
        parser.print_help()
        return

    with open(args.config, 'rb') as fd:
        settings = json.load(fd)

    conn_string = ' '.join( ( "dbname=" + settings['database']['name'],
                              "host="+settings['database']['host'],
                              "user="******"password="******"port="+ str(settings['database']['port']) ) )

    print "Setting connection string to ... " + conn_string 

    DataDB.setConnectionString ( conn_string )

    if 'logfiles' in settings:
        logdata.setFilter( settings['logfiles']['liveuserfilter'] )

    current_dir = os.path.dirname(os.path.abspath(__file__))

    conf = ( { 'global': { 'server.socket_host': '0.0.0.0',
                           'server.socket_port': int(settings['frontend']['port']) } ,
               '/' :     {'tools.staticdir.root' : current_dir },
               '/static' : {'tools.staticdir.dir' : 'static' ,
                            'tools.staticdir.on' : True } } )

    tplE.setup( settings )

    root = None

    for h in hosts.getHostData().values():
        mf = MonitorFrontend.MonitorFrontend(h['host_id'])

        if root == None:
            root = mf

        setattr(root , h['settings']['uiShortName'].lower().replace('-','') , mf)

    root.report = report.Report()
    root.sprocs = sprocsfrontend.SprocFrontend()
    root.tables = tablesfrontend.TableFrontend()

    cherrypy.quickstart(root,config=conf)
예제 #3
0
        try:
            #print ('processing: {}', h)
            conn = psycopg2.connect(host=h['host_name'], dbname=h['host_db'], user=h['host_user'], password=h['host_password'],connect_timeout='3')
            cur = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
            cur.execute(q_invalid, (h['host_name'], h['host_id']))
            data_invalid += cur.fetchall()
            cur.execute(q_unused, (h['host_name'], h['host_id'], indexing_thresholds['pit_min_size_to_report'], indexing_thresholds['pit_max_scans_to_report']))
            data_unused += cur.fetchall()
            cur.execute(q_duplicate, (h['host_name'], h['host_id']))
            data_duplicate += cur.fetchall()
        except Exception, e:
            print ('ERROR could not connect to {}:{}'.format(h['host_name'], e))
            data_noconnect.append({'host_id':h['host_id'],'host_name': h['host_name']})
        finally:
            if conn and not conn.closed:
                conn.close()
    
    data_invalid.sort(key=lambda x:x['index_size_bytes'],reverse=True)
    data_unused.sort(key=lambda x:x['index_size_bytes'],reverse=True)
    data_duplicate.sort(key=lambda x:x['table_size_bytes'],reverse=True)

    return {'invalid':data_invalid, 'duplicate':data_duplicate, 'unused':data_unused, 'noconnect':data_noconnect}

if __name__ == '__main__':
    DataDB.setConnectionString("dbname=dbmonitor host=localost user=postgres password=postgres")
    #print (getTablePerformanceIssues('customer1.db.zalando',datetime.date(2013,8,23),datetime.date(2013,8,26)))
    #print (getApiPerformanceIssues('stock2.db.zalando','r13_00_33','r13_00_34'))
    #print (getIndexIssues('all'))
    print (getIndexIssues('bm-master.db.zalando')['data_unused'])

예제 #4
0
def main():
    parser = ArgumentParser(description='PGObserver Frontend')
    parser.add_argument('-c',
                        '--config',
                        help='Path to config file. (default: %s)' %
                        DEFAULT_CONF_FILE,
                        dest="config",
                        default=DEFAULT_CONF_FILE)

    args = parser.parse_args()

    args.config = os.path.expanduser(args.config)

    if not os.path.exists(args.config):
        print 'Configuration file missing:', args.config
        parser.print_help()
        return

    with open(args.config, 'rb') as fd:
        settings = json.load(fd)

    conn_string = ' '.join(
        ("dbname=" + settings['database']['name'],
         "host=" + settings['database']['host'],
         "user="******"password="******"port=" + str(settings['database']['port'])))

    print "Setting connection string to ... " + conn_string

    DataDB.setConnectionString(conn_string)

    if 'logfiles' in settings:
        logdata.setFilter(settings['logfiles']['liveuserfilter'])

    current_dir = os.path.dirname(os.path.abspath(__file__))

    conf = ({
        'global': {
            'server.socket_host': '0.0.0.0',
            'server.socket_port': int(settings['frontend']['port'])
        },
        '/': {
            'tools.staticdir.root': current_dir
        },
        '/static': {
            'tools.staticdir.dir': 'static',
            'tools.staticdir.on': True
        }
    })

    tplE.setup(settings)

    root = None

    for h in hosts.getHostData().values():
        mf = MonitorFrontend.MonitorFrontend(h['host_id'])

        if root == None:
            root = mf

        setattr(root, h['settings']['uiShortName'].lower().replace('-', ''),
                mf)

    root.report = report.Report()
    root.sprocs = sprocsfrontend.SprocFrontend()
    root.tables = tablesfrontend.TableFrontend()

    cherrypy.quickstart(root, config=conf)
예제 #5
0
                         indexing_thresholds['pit_min_size_to_report'],
                         indexing_thresholds['pit_max_scans_to_report']))
            data_unused += cur.fetchall()
        except Exception, e:
            print('ERROR could not connect to {}:{}'.format(h['host_name'], e))
            data_noconnect.append({
                'host_id': h['host_id'],
                'host_name': h['host_name']
            })
        finally:
            if conn and not conn.closed:
                conn.close()

    data_invalid.sort(key=lambda x: x['index_size_bytes'], reverse=True)
    data_unused.sort(key=lambda x: x['index_size_bytes'], reverse=True)

    return {
        'invalid': data_invalid,
        'unused': data_unused,
        'noconnect': data_noconnect
    }


if __name__ == '__main__':
    DataDB.setConnectionString(
        "dbname=dbmonitor host=localost user=postgres password=postgres")
    #print (getTablePerformanceIssues('customer1.db.zalando',datetime.date(2013,8,23),datetime.date(2013,8,26)))
    #print (getApiPerformanceIssues('stock2.db.zalando','r13_00_33','r13_00_34'))
    #print (getIndexIssues('all'))
    print(getIndexIssues('bm-master.db.zalando')['data_unused'])