Exemple #1
0
    lines = info.split('\n')
    ps = []
    for line in lines:
        m = re.search('([\d]+) root\s+(\d*)[A-Z <]+(.+)', line)
        if m:
            ps.append(m.group(1, 2, 3))
    return ps


processes = ["/aruba/bin/cli -I", "/aruba/bin/awc", "dpimgr", "/aruba/bin/mdns", "/aruba/bin/stm",
             "/aruba/bin/sapd"]

if __name__ == '__main__':
    sys.argv.pop(0)
    tid = sys.argv.pop(0)
    cluster = db.get_cluster(tid)
    vc_url = cluster.vcip
    username = cluster.username
    password = cluster.password
    ap = {}
    ap_list = []

    with SWARM(vc_url,4343,username,password) as swarm:
        ret = swarm.OPCODE('support','show aps')
        _aps = format_aps(ret)
        for _ap in _aps:
            ap['tid'] = tid
            ap['name'] = _ap[0].strip()
            ap['ip'] = _ap[1].strip()
            ap['status'] = 'Up'
            ap['type'] = _ap[5].strip()
Exemple #2
0
    def GET(self, tid):
        global fail_filter
        clusters = db.get_clusters()
        clusters = list(clusters)
        cluster = db.get_cluster(tid)
        cluster_version = db.get_cluster_version(tid)
        if cluster_version is None:
            cluster_version = web.Storage(version='0.0.0.0', build='9999', oem='ARUBA')
        _aps = db.get_aps(tid)
        aps = []
        ap = {}
        ap_count = 0
        entry_count=web.Storage(warning=0, error=0, passed=0)
        for _ap in _aps:
            ap_count += 1
            ap['name'] = _ap.name
            ap['type'] = _ap.type
            ap['uptime'] = _ap.uptime
            ap['status'] = _ap.status
            ap['time'] = _ap.time
            ap['ip'] = _ap.ip
            ap['clients'] = _ap.clientCount
            ap['entry_status'] = 0
            ap['id'] = _ap.id
            mem = db.get_memory(_ap.id)
            if mem:
                ap['mem_free'] = mem.memoryFree
                ap['mem_used'] = mem.memoryTotal - mem.memoryFree
                ap['mem_time'] = mem.time
            else:
                ap['mem_free'] = 'NULL'
                ap['mem_used'] = 'NULL'
                ap['mem_time'] = 'NULL'
            cpu = db.get_cpu(_ap.id)
            if cpu:
                ap['cpu_idle'] = cpu.idle
                ap['cpu_time'] = cpu.time
            else:
                ap['cpu_idle'] = 'NULL'
                ap['cpu_time'] = 'NULL'

            for f in fail_filter:
                if f in _ap.status:
                    ap['entry_status'] += -1
                    break
            if ap['cpu_idle'] <= 10:
                ap['entry_status'] += -2
            if ap['entry_status'] == 0 and \
                ('Null' in ap['status'] or \
                'NULL' in str(ap['mem_free']) or \
                'NULL' in str(ap['cpu_idle'])):
                ap['entry_status'] = 1

            if ap['entry_status'] == 1:
                entry_count.warning += 1
            elif ap['entry_status'] < 0:
                entry_count.error += 1
            else:
                entry_count.passed += 1

            aps.append(ap)
            ap = {}
        return render.view(clusters, cluster, cluster_version, aps, ap_count, entry_count)