示例#1
0
 def save(self, **params):
     try:
         hosts.saveHost(params)
     except Exception as e:
         return e.message
     if len(hosts.getHosts()) == 0:
         return "Saved...NB! Dummy User/Password inserted, please correct in DB"
     return "OK"
示例#2
0
 def save(self, **params):
     try:
         hosts.saveHost(params)
     except Exception as e:
         return e.message
     if len(hosts.getHosts()) == 0:
         return 'Saved...NB! Dummy User/Password inserted, please correct in DB'
     return 'OK'
示例#3
0
    def default(self, *p, **params):
        if len(p) < 2:
            return ""

        hostId = int(p[0]) if p[0].isdigit() else hosts.uiShortnameToHostId(p[0])
        hostUiName = p[0] if not p[0].isdigit() else hosts.hostIdToUiShortname(p[0])
        table_name = p[1]
        if table_name.find('.') == -1:
            raise Exception('Full table name needed, e.g. schema_x.table_y')
        schema = table_name.split('.')[0]

        if 'from' in params and 'to' in params:
            interval = {}
            interval['from'] = params['from']
            interval['to'] = params['to']
        else:
            interval = {}
            interval['from'] = (datetime.datetime.now() - datetime.timedelta(days=14)).strftime('%Y-%m-%d')
            interval['to'] = (datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%Y-%m-%d')

        data = indexdata.getIndexesDataForTable(hostId, table_name, interval['from'], interval['to'])

        all_graphs=[]
        i=0
        for x in data:
            one_index_graphs=[]
            for k,v in x['data'].iteritems():
                i+=1
                if k == 'size':
                    graph = flotgraph.SizeGraph ("index"+str(i),"right")
                else:
                    graph = flotgraph.Graph ("index"+str(i),"right")
                graph.addSeries(k,k)
                for p in v:
                    graph.addPoint(k, int(time.mktime(p[0].timetuple()) * 1000) , p[1])
                graph = graph.render()

                one_index_graphs.append({'data':graph, 'i':i, 'type':k})
                one_index_graphs.sort(key=lambda x:x['type'])
            all_graphs.append({'name':x['index_name'], 'graphs': one_index_graphs, 'last_index_size':x['last_index_size'], 'total_end_size':x['total_end_size'], 'pct_of_total_end_size':x['pct_of_total_end_size']})

        all_graphs = sorted(all_graphs, key=lambda x:x['last_index_size'], reverse=True)

        tpl = tplE.env.get_template('table_indexes.html')
        return tpl.render(table_name=table_name,
                          host=hostId,
                          schema=schema,
                          interval=interval,
                          hostuiname = hostUiName,
                          hostname = hosts.getHosts()[hostId]['uilongname'],
                          all_graphs=all_graphs,
                          target='World')
示例#4
0
    def index(self):
        hosts_with_last_stats_by_groups = OrderedDict()

        if len(hosts.getHosts()) > 0:
            hosts_with_last_stats = self.get_last_loads_and_sizes()
            for h in hosts_with_last_stats:
                if h['group_name'] not in hosts_with_last_stats_by_groups:
                    hosts_with_last_stats_by_groups[h['group_name']] = []
                hosts_with_last_stats_by_groups[h['group_name']].append(h)

        tmpl = tplE.env.get_template('welcome.html')
        return tmpl.render(hosts_with_last_stats_by_groups=hosts_with_last_stats_by_groups,
                           target='World')
示例#5
0
    def index(self):
        hosts_with_last_stats_by_groups = OrderedDict()

        if len(hosts.getHosts()) > 0:
            hosts_with_last_stats = self.get_last_loads_and_sizes()
            for h in hosts_with_last_stats:
                if h['group_name'] not in hosts_with_last_stats_by_groups:
                    hosts_with_last_stats_by_groups[h['group_name']] = []
                hosts_with_last_stats_by_groups[h['group_name']].append(h)

        tmpl = tplE.env.get_template('welcome.html')
        return tmpl.render(
            hosts_with_last_stats_by_groups=hosts_with_last_stats_by_groups,
            target='World')
示例#6
0
def main(rxn):
    rxnStatus = status.findStatus(rxn)
    # NOTE: This must be kept current as new nodes are added and the "final 2"
    # nodes change from 33 and 34
    if 33 in rxnStatus and 34 in rxnStatus:
        print('COMPLETED')
        return

    newInputFile = processNodes(
        rxn,
        '/home/rcf-proj2/ddd2/ddepew/gamess/src/scripts/gamessWorkflow/nodes.txt',
        rxnStatus)

    numSubprocesses = len(newInputFile)
    if numSubprocesses == 0:
        raise ValueError(
            "No input files were created!! Check results from completed runs")
    else:
        getHosts(len(newInputFile))

    [print(inpFile.strip(".inp")) for inpFile in newInputFile]
    #rungamessline = '$GMS_PATH/rungms ' + inpFile + ' 00 $NCPUS $PPN > ' + inpFile.replace('.inp','.log')
    return
示例#7
0
def setup(settings=None):
    global env, _settings

    if env != None:
        return

    if settings == None:
        _settings = {"tags": False, "sizeoverview": False, "logfiles": False}
    else:
        _settings = settings['features']

    env = Environment(loader=FileSystemLoader('templates'))

    env.globals['hosts'] = hosts.getHostData()
    env.globals['settings'] = _settings
    hl = sorted(env.globals['hosts'].values(),
                key=lambda h: h['settings']['uiShortName'])

    gs = {}
    hlf = []
    for h in hl:
        if h['host_group_id'] == None:
            hlf.append(h)
        else:
            if h['host_group_id'] in gs:
                continue
            else:
                gs[h['host_group_id']] = True
                hlf.append(h)

    env.globals['hostlist'] = hlf

    groups = {}

    for h in hosts.getHosts().values():
        if h['host_group_id'] > 0:
            if not (h['host_group_id'] in groups):
                groups[h['host_group_id']] = []

            groups[h['host_group_id']].append(h)

    for g in groups.keys():
        groups[g] = sorted(groups[g],
                           key=lambda x: x['settings']['uiShortName'])

    env.globals['hostgroups'] = groups
    env.globals['groups'] = hosts.getGroups()
示例#8
0
def setup(settings = None):
    global env, _settings

    if env != None:
        return

    if settings == None:
        _settings = {"tags":False,"sizeoverview":False,"logfiles":False}
    else:
        _settings = settings['features']

    env = Environment(loader=FileSystemLoader('templates'))

    env.globals['hosts'] = hosts.getHostData()
    env.globals['hosts_json'] = json.dumps(env.globals['hosts'])
    env.globals['settings'] = _settings;
    hl = sorted( env.globals['hosts'].values() , key = lambda h : h['settings']['uiShortName'] )

    gs = {}
    hlf = []
    for h in hl:
        if h['host_group_id'] == None:
            hlf.append(h)
        else:
            if h['host_group_id'] in gs:
                continue
            else:
                gs[h['host_group_id']] = True
                hlf.append(h)

    env.globals['hostlist'] = hlf

    groups = {}

    for h in hosts.getHosts().values():
        if h['host_group_id'] > 0:
            if not (h['host_group_id'] in groups):
                groups[h['host_group_id']] = []

            groups[h['host_group_id']].append(h);

    for g in groups.keys():
        groups[g] = sorted(groups[g], key = lambda x : x['settings']['uiShortName'])

    env.globals['hostgroups'] = groups
    env.globals['groups'] = hosts.getGroups()
    env.globals['groups_json'] = json.dumps(hosts.getGroups())
示例#9
0
文件: tplE.py 项目: a1exsh/PGObserver
def setup(settings = None):
    global env, _settings
    hosts.resetHostsAndGroups()

    if settings == None:
        _settings = {"show_load":True, "show_wal":True, "show_top_sprocs":True, "show_db_size":True, "show_db_stats":True}
    else:
        _settings = settings['features']

    if env is None:
        env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))

    env.globals['hosts'] = hosts.getHostData()
    env.globals['hosts_json'] = json.dumps(env.globals['hosts'])
    env.globals['settings'] = _settings
    hl = sorted( env.globals['hosts'].values() , key = lambda h : h['uishortname'] )

    gs = {}
    hlf = []
    for h in hl:
        if h['host_group_id'] == None:
            hlf.append(h)
        else:
            if h['host_group_id'] in gs:
                continue
            else:
                gs[h['host_group_id']] = True
                hlf.append(h)

    env.globals['hostlist'] = hlf

    groups = {}

    for h in hosts.getHosts().values():
        if not (h['host_group_id'] in groups):
            groups[h['host_group_id']] = []

        groups[h['host_group_id']].append(h)

    for g in groups.keys(): # TODO remove?
        groups[g] = sorted(groups[g], key = lambda x : x['uishortname'])

    env.globals['hostgroups'] = groups
    env.globals['groups'] = hosts.getGroups()
    env.globals['groups_json'] = json.dumps(hosts.getGroups())
示例#10
0
    def default(self, *p, **params):
        if len(p) < 2:
            return ""
        hostId = int(p[0]) if p[0].isdigit() else hosts.uiShortnameToHostId(p[0])
        hostUiName = p[0] if not p[0].isdigit() else hosts.hostIdToUiShortname(p[0])
        name = p[1]
        interval = {}

        if 'interval' in params:
            interval['interval'] = str(params['interval'])+' days'
        elif 'from' in params and 'to' in params:
            interval['from'] = params['from']
            interval['to'] = params['to']
        else:
            days = int(cherrypy.request.cookie['days'].value) if 'days' in cherrypy.request.cookie else 8
            interval['from'] = (datetime.datetime.now() - datetime.timedelta(days=days)).strftime('%Y-%m-%d')
            interval['to'] = (datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%Y-%m-%d')

        data = tabledata.getTableData(hostId, name, interval)

        graph_table_size = flotgraph.SizeGraph ("graphtablesize","right")
        graph_table_size.addSeries("Table Size","size")
        for p in data['table_size']:
            graph_table_size.addPoint("size", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_index_size = flotgraph.SizeGraph ("graphindexsize","right")
        graph_index_size.addSeries("Index Size", "size")
        for p in data['index_size']:
            graph_index_size.addPoint("size", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_seq_scans = flotgraph.Graph ("graphseqscans","right")
        graph_seq_scans.addSeries("Sequential Scans","count")
        for p in data['seq_scans']:
            graph_seq_scans.addPoint("count", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_index_scans = flotgraph.Graph ("graphindexscans","right")
        graph_index_scans.addSeries("Index Scans","count")
        for p in data['index_scans']:
            graph_index_scans.addPoint("count", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_t_ins = flotgraph.Graph ("gtupins","right")
        graph_t_ins.addSeries("Inserts","count",'#FF0000')
        for p in data['ins']:
            graph_t_ins.addPoint("count", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_t_upd = flotgraph.Graph ("gtupupd","right")
        graph_t_upd.addSeries("Updates","count",'#FF8800')
        graph_t_upd.addSeries("Hot Updates","hotcount",'#885500')
        for p in data['upd']:
            graph_t_upd.addPoint("count", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        for p in data['hot']:
            graph_t_upd.addPoint("hotcount", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_t_del = flotgraph.Graph ("gtupdel","right")
        graph_t_del.addSeries("Deletes","count")
        for p in data['del']:
            graph_t_del.addPoint("count", int(time.mktime(p[0].timetuple()) * 1000) , p[1])


        data = tabledata.getTableIOData(hostId, name, interval)

        graph_index_iob = flotgraph.Graph ("graphindexiob","right")
        graph_index_iob.addSeries("Index_hit","ihit")
        for p in data['index_hit']:
            graph_index_iob.addPoint("ihit", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_index_iod = flotgraph.Graph ("graphindexiod","right")
        graph_index_iod.addSeries("Index_read","iread",'#FF0000')
        for p in data['index_read']:
            graph_index_iod.addPoint("iread", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_heap_iod = flotgraph.Graph ("graphheapiod","right")
        graph_heap_iod.addSeries("Heap_read","hread",'#FF0000')
        for p in data['heap_read']:
            graph_heap_iod.addPoint("hread", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        graph_heap_iob = flotgraph.Graph ("graphheapiob","right")
        graph_heap_iob.addSeries("Heap_hit","hhit")
        for p in data['heap_hit']:
            graph_heap_iob.addPoint("hhit", int(time.mktime(p[0].timetuple()) * 1000) , p[1])

        tpl = tplE.env.get_template('table_detail.html')
        return tpl.render(name=name,
                          schema_name=name[:name.find('.')],
                          host=hostId,
                          interval=interval,
                          hostuiname = hostUiName,
                          hostname = hosts.getHosts()[hostId]['uilongname'],
                          graphtablesize=graph_table_size.render(),
                          graphindexsize=graph_index_size.render(),
                          graphseqscans=graph_seq_scans.render(),
                          graphindexscans=graph_index_scans.render(),

                          graphindexiod=graph_index_iod.render(),
                          graphindexiob=graph_index_iob.render(),
                          graphheapiod=graph_heap_iod.render(),
                          graphheapiob=graph_heap_iob.render(),

                          gtupins=graph_t_ins.render(),
                          gtupupd=graph_t_upd.render(),
                          gtupdel=graph_t_del.render(),

                          target='World')
示例#11
0
    def default(self, *p, **params):
        if len(p) < 2:
            return ""

        hostId = int(p[0]) if p[0].isdigit() else hosts.uiShortnameToHostId(
            p[0])
        hostUiName = p[0] if not p[0].isdigit() else hosts.hostIdToUiShortname(
            p[0])
        table_name = p[1]
        if table_name.find('.') == -1:
            raise Exception('Full table name needed, e.g. schema_x.table_y')
        schema = table_name.split('.')[0]

        if 'from' in params and 'to' in params:
            interval = {}
            interval['from'] = params['from']
            interval['to'] = params['to']
        else:
            interval = {}
            interval['from'] = (
                datetime.datetime.now() -
                datetime.timedelta(days=14)).strftime('%Y-%m-%d')
            interval['to'] = (datetime.datetime.now() +
                              datetime.timedelta(days=1)).strftime('%Y-%m-%d')

        data = indexdata.getIndexesDataForTable(hostId, table_name,
                                                interval['from'],
                                                interval['to'])

        all_graphs = []
        i = 0
        for x in data:
            one_index_graphs = []
            for k, v in x['data'].iteritems():
                i += 1
                if k == 'size':
                    graph = flotgraph.SizeGraph("index" + str(i), "right")
                else:
                    graph = flotgraph.Graph("index" + str(i), "right")
                graph.addSeries(k, k)
                for p in v:
                    graph.addPoint(k,
                                   int(time.mktime(p[0].timetuple()) * 1000),
                                   p[1])
                graph = graph.render()

                one_index_graphs.append({'data': graph, 'i': i, 'type': k})
                one_index_graphs.sort(key=lambda x: x['type'])
            all_graphs.append({
                'name':
                x['index_name'],
                'graphs':
                one_index_graphs,
                'last_index_size':
                x['last_index_size'],
                'total_end_size':
                x['total_end_size'],
                'pct_of_total_end_size':
                x['pct_of_total_end_size']
            })

        all_graphs = sorted(all_graphs,
                            key=lambda x: x['last_index_size'],
                            reverse=True)

        tpl = tplE.env.get_template('table_indexes.html')
        return tpl.render(table_name=table_name,
                          host=hostId,
                          schema=schema,
                          interval=interval,
                          hostuiname=hostUiName,
                          hostname=hosts.getHosts()[hostId]['uilongname'],
                          all_graphs=all_graphs,
                          target='World')
示例#12
0
 def reload(self):
     hosts.getHosts(force_refresh_from_db=True)
     hosts.getAllHosts(force_refresh_from_db=True)
     tplE.setup({'features': tplE.env.globals['settings']})
     raise cherrypy.HTTPRedirect(cherrypy.url('/hosts'))
示例#13
0
 def reload(self):
     hosts.getHosts(force_refresh_from_db=True)
     hosts.getAllHosts(force_refresh_from_db=True)
     tplE.setup({'features': tplE.env.globals['settings']})
     raise cherrypy.HTTPRedirect(cherrypy.url('/hosts'))