Beispiel #1
0
    version=re.search('Version (.+)',info)
    build=re.search('\(build (.+)\)',info)
    if reboot_info is None:
        return ('Null', 'Null', 'Null', 'Null')
    else:
        return (up_time.group(1),reboot_info.group(1),version.group(1),build.group(1))

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 = {}
    aps = db.get_aps(tid)
    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_list.append(ap['name'])
            
            ret = swarm.OPCODE('support','show version', ap['ip'])
            ap['status'] = format_version(ret)[1]
            db.insert_ap(ap)
Beispiel #2
0
            ap['clients'] = _ap[4].strip()
            ap_list.append(ap['name'])
            
            if '*' in ap['ip']:
                ret = swarm.OPCODE('support','show version')
                fv = format_version(ret)
                db.update_cluster_version(tid, fv[2], fv[3])
            else:
                ret = swarm.OPCODE('support','show version', ap['ip'].strip('*'))

            version_info = format_version(ret)
            ap['status'] = version_info[1]
            ap['uptime'] = version_info[0]
            db.insert_ap(ap)

        aps = list(db.get_aps(tid))
        for _ap in aps:
            if _ap.name not in ap_list:
                db.delete_ap(_ap.id)
                continue
            print _ap.ip.strip('*')
            ret = swarm.OPCODE('support', 'show memory', _ap.ip.strip('*'))
            ret = format_mem(ret)
            if ret.has_key('MemFree') and ret.has_key('MemTotal'):
                db.insert_memory(_ap.id, ret['MemFree'].strip(' kB'), ret['MemTotal'].strip(' kB'))
            else:
                print ret

            ret = swarm.OPCODE('support', 'show cpu', _ap.ip.strip('*'))
            ret = format_cpu(ret)
            if ret.has_key('idle'):
Beispiel #3
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)