コード例 #1
0
def build_interfaces(dclass, seq):
    graphs = []
    groups = []
    intf = conf.get('interfaces', 'collection').split('=')
    for gpName in conf.get('interfaces', 'include').split(','):
        seq = seq + 1
        newgraph, newgroup = convert_graphs(gpName, seq, dclass,
                                            '/Server/ethernetCsmacd')
        graphs.append(newgraph)
        groups.append(newgroup)
    for g in groups:
        g['collectionId'] = '%s %s interface' % (dclass.split('/')[-1],
                                                 intf[0])
    cnt = -1
    colls = {
        'collectionName': '%s %s interface' % (dclass.split('/')[-1], intf[0]),
        'CollectionItems': []
    }
    for d in sorted(z.export_devices(dclass, net=True)):
        for i in intf[1].split('|'):
            if i in d['interfaces']:
                cnt = cnt + 1
                colls['CollectionItems'].append(
                    build_collitem(comp='os/interfaces/%s' % i,
                                   id=d['deviceName'],
                                   seq=cnt))
                break
    return [colls], groups, graphs, seq
コード例 #2
0
def build_processes(dclass, seq):
    graphs = []
    groups = []
    pgroups = []
    colls = []
    for gpName in conf.get('processes', 'include').split(','):
        seq = seq + 1
        newgraph, newgroup = convert_graphs(gpName, seq, dclass,
                                            '/Server/OSProcess')
        graphs.append(newgraph)
        pgroups.append(newgroup)
    for g in graphs:
        g['gdName'] = g['gdName'].replace('Used', 'Process')
    ps = {}
    cnt = -1
    for d in sorted(z.export_devices(dclass, ps=True)):
        cnt = cnt + 1
        for p in sorted(d['processes']):
            if p not in ps.keys():
                ps[p] = []
            ps[p].append(
                build_collitem(comp='os/processes/%s' % p,
                               id=d['deviceName'],
                               seq=cnt))
    plist = z.list_processhash()
    for p in ps:
        pname = p.split('-')[0].split('_')[-1]
        if pname.startswith('java'):
            for ph in plist:
                if ph['md5'] in pname:
                    pname = '%s %s' % (pname.split(' ')[0],
                                       re.sub('=(\w+).*$', r' \1',
                                              ph['parameters'].split(' ')[0]))
        colls.append({
            'collectionName':
            '%s %s process' % (dclass.split('/')[-1], pname),
            'CollectionItems':
            ps[p]
        })
        for pg in pgroups:
            pgroup = {}
            for k in pg.keys():
                if k == 'collectionId':
                    pgroup[k] = '%s %s process' % (dclass.split('/')[-1],
                                                   pname)
                elif k == 'ggName':
                    pgroup[k] = '%s %s' % (pg[k].replace('Used',
                                                         'Process'), pname)
                elif k == 'graphDefId':
                    pgroup[k] = pg[k].replace('Used', 'Process')
                elif k == 'sequence':
                    pgroup[k] = seq
                else:
                    pgroup[k] = pg[k]
                seq = seq + 1
            groups.append(pgroup)
    return colls, groups, graphs, seq
コード例 #3
0
def build_processes(dclass, seq):
    graphs = []
    groups = []
    pgroups = []
    colls = []
    for gpName in conf.get('processes', 'include').split(','):
        seq = seq + 1
        newgraph, newgroup = convert_graphs(gpName, seq, dclass, '/Server/OSProcess')
        graphs.append(newgraph)
        pgroups.append(newgroup)
    for g in graphs:
        g['gdName'] = g['gdName'].replace('Used', 'Process')
    ps = {}
    cnt = -1
    for d in sorted(z.export_devices(dclass, ps=True)):
        cnt = cnt + 1
        for p in sorted(d['processes']):
            if p not in ps.keys():
                ps[p] = []
            ps[p].append(build_collitem(comp='os/processes/%s' % p,
                id=d['deviceName'], seq=cnt))
    plist = z.list_processhash()
    for p in ps:
        pname = p.split('-')[0].split('_')[-1]
        if pname.startswith('java'):
            for ph in plist:
                if ph['md5'] in pname:
                    pname = '%s %s' % (pname.split(' ')[0], re.sub('=(\w+).*$', r' \1', ph['parameters'].split(' ')[0]))
        colls.append({ 'collectionName': '%s %s process' % (dclass.split('/')[-1], pname),
          'CollectionItems': ps[p] })
        for pg in pgroups:
           pgroup = {}
           for k in pg.keys():
               if k == 'collectionId':
                   pgroup[k] = '%s %s process' % (dclass.split('/')[-1], pname)
               elif k == 'ggName':
                   pgroup[k] = '%s %s' % (pg[k].replace('Used', 'Process'), pname)
               elif k == 'graphDefId':
                   pgroup[k] = pg[k].replace('Used', 'Process')
               elif k == 'sequence':
                   pgroup[k] = seq
               else:
                   pgroup[k] = pg[k]
               seq = seq + 1
           groups.append(pgroup)
    return colls, groups, graphs, seq
コード例 #4
0
def build_filesystems(dclass, seq):
    graphs = []
    groups = []
    colls = []
    seq = seq + 1
    newgraph, newgroup = convert_graphs('usedBlocks', seq, dclass,
                                        '/Server/FileSystem')
    graphs.append(newgraph)
    fs = {}
    cnt = -1
    excludes = conf.get('filesystems', 'exclude').split(',')
    for d in sorted(z.export_devices(dclass, disk=True)):
        for f in sorted(d['filesystems']):
            skip = False
            for e in excludes:
                if f.startswith(e):
                    skip = True
                    break
            if not skip:
                if f not in fs.keys():
                    fs[f] = []
                cnt = cnt + 1
                fs[f].append(
                    build_collitem(comp='os/filesystems/%s' % f,
                                   id=d['deviceName'],
                                   seq=cnt))
    for f in fs:
        fname = re.sub('^-$', 'root', f)
        colls.append({
            'collectionName':
            '%s %s filesystem' % (dclass.split('/')[-1], fname),
            'CollectionItems':
            fs[f]
        })
        fgroup = {}
        for k in newgroup.keys():
            if k == 'collectionId':
                fgroup[k] = '%s %s filesystem' % (dclass.split('/')[-1], fname)
            elif k == 'ggName':
                fgroup[k] = 'Disk %s %s' % (newgroup[k], fname)
            else:
                fgroup[k] = newgroup[k]
        groups.append(fgroup)
    return colls, groups, graphs, seq
コード例 #5
0
def build_interfaces(dclass, seq):
    graphs = []
    groups = []
    intf = conf.get('interfaces', 'collection').split('=')
    for gpName in conf.get('interfaces', 'include').split(','):
        seq = seq + 1
        newgraph, newgroup = convert_graphs(gpName, seq, dclass, '/Server/ethernetCsmacd')
        graphs.append(newgraph)
        groups.append(newgroup)
    for g in groups:
        g['collectionId'] = '%s %s interface' % (dclass.split('/')[-1], intf[0])
    cnt = -1
    colls = { 'collectionName': '%s %s interface' % (dclass.split('/')[-1], intf[0]),
              'CollectionItems': [] }
    for d in sorted(z.export_devices(dclass, net=True)):
        for i in intf[1].split('|'):
            if i in d['interfaces']:
                cnt = cnt + 1
                colls['CollectionItems'].append(build_collitem(comp='os/interfaces/%s' % i,
                    id=d['deviceName'], seq=cnt))
                break
    return [colls], groups, graphs, seq
コード例 #6
0
def build_filesystems(dclass, seq):
    graphs = []
    groups = []
    colls = []
    seq = seq + 1
    newgraph, newgroup = convert_graphs('usedBlocks', seq, dclass, '/Server/FileSystem')
    graphs.append(newgraph)
    fs = {}
    cnt = -1
    excludes = conf.get('filesystems', 'exclude').split(',')
    for d in sorted(z.export_devices(dclass, disk=True)):
        for f in sorted(d['filesystems']):
            skip = False
            for e in excludes:
                if f.startswith(e):
                    skip = True
                    break
            if not skip:
                if f not in fs.keys():
                    fs[f] = []
                cnt = cnt + 1
                fs[f].append(build_collitem(comp='os/filesystems/%s' % f,
                    id=d['deviceName'], seq=cnt))
    for f in fs:
        fname = re.sub('^-$', 'root', f)
        colls.append({ 'collectionName': '%s %s filesystem' % (dclass.split('/')[-1], fname),
          'CollectionItems': fs[f] })
        fgroup = {}
        for k in newgroup.keys():
            if k == 'collectionId':
                fgroup[k] = '%s %s filesystem' % (dclass.split('/')[-1], fname)
            elif k == 'ggName':
                fgroup[k] = 'Disk %s %s' % (newgroup[k], fname)
            else:
                fgroup[k] = newgroup[k]
        groups.append(fgroup)
    return colls, groups, graphs, seq