コード例 #1
0
ファイル: performance.py プロジェクト: leonardocfor/cofl
def killProcess(user, server, command):
    """
	Kill a process in a remote machine
	"""
    try:
        process = executeCommand(
            'ssh ' + user + '@' + server + ' -C "ps aux | grep ' + command +
            ' | head -1 | awk {\'print $2\'}"', '', True)[0][0:-1]
        executeCommand(
            'ssh ' + user + '@' + server + ' -C "kill -9 ' + process + '"', '',
            True)
    except Exception as e:
        raise
コード例 #2
0
def main():

    tcFolder = '/mnt/HDDextra2TB/cofl/scenarios/S2/'
    subFolders = os.listdir(tcFolder)
    subFolders = [
        '/mnt/HDDextra2TB/cofl/scenarios/S2/' + f for f in subFolders
    ]
    clustersInfoTestCases = {}
    for folder in subFolders:
        temp = folder.split('/')[6].split('_')
        idTC = temp[2] + '-' + temp[3]
        print('Calculating testcase ' + idTC)
        command = 'ls ' + folder + '/output/summary*'
        out = executeCommand(command)
        if out[2] == 0:

            logsFolder = folder + '/logs'
            logs = os.listdir(logsFolder)
            logs.remove('0.log')
            logs = [logsFolder + '/' + f for f in logs]

            cruiseTimes = []
            for log in logs:
                cruiseTimes.append(
                    int(
                        os.popen("cat " +
                                 log + " | grep 'Cruise starts at time'").read(
                                 ).split()[5]))
            clustersInfoTestCases[idTC] = max(cruiseTimes) - min(cruiseTimes)
            print('Cruise duration is ' + str(clustersInfoTestCases[idTC]))
        else:
            print('Test case not done')
    for tc in clustersInfoTestCases:
        print(tc + ': ' + str(clustersInfoTestCases[tc]))
コード例 #3
0
def main():

	folder ='/mnt/HDDextra2TB/cofl/scenarios/S2/'
	subFolders = os.listdir(folder)
	subFolders=['/mnt/HDDextra2TB/cofl/scenarios/S2/'+f for f in subFolders]
	clustersInfoTestCases ={}
	for folder in subFolders:

		command = 'ls '+folder+'/output/summary*'
		out = executeCommand(command)
		if out[2] == 0:
			temp=folder.split('/')[6].split('_')
			idTC = temp[2]+'-'+temp[3]
			clustersInfoTestCases[idTC] = {}
			clustersInfoTestCases[idTC]['ATST'] = {}
			clustersInfoTestCases[idTC]['CS'] = {}
			logsFolder = folder+'/logs'
			clustersSizes = []
			clustersATST = []
			lines = os.popen("cat "+logsFolder+"/0.log | grep 'Clusters calculated by Network Manager: '").read().split('\n')
			for line in lines:
				clustersline='{'+line.replace("[STD] Clusters calculated by Network Manager: ", "")[0:-1].replace(']','],')[0:-1]+'}'
				clusters = eval(clustersline)
				clusteredFlights = []
				atst = 0
				for flight in clusters:
					if flight not in clusteredFlights and len(clusters[flight])>0:
						clustersSizes.append(len(clusters[flight]))
						atst +=1
						for f in clusters[flight]: clusteredFlights.append(f)
				clustersATST.append(atst)
			maxSize = max(clustersSizes) if len(clustersSizes) > 0 else 0
			minSize = min(clustersSizes) if len(clustersSizes) > 0 else 0
			avgSize = float(sum(clustersSizes))/len(clustersSizes) if len(clustersSizes) > 0 else 0
			clustersInfoTestCases[idTC]['CS']['max'] = maxSize
			clustersInfoTestCases[idTC]['CS']['min'] = minSize
			clustersInfoTestCases[idTC]['CS']['avg'] = avgSize
			maxATST = max(clustersATST)
			minATST = min(clustersATST)
			avgATST = float(sum(clustersATST))/len(clustersATST)
			clustersInfoTestCases[idTC]['ATST']['max'] = maxATST
			clustersInfoTestCases[idTC]['ATST']['min'] = minATST
			clustersInfoTestCases[idTC]['ATST']['avg'] = avgATST
コード例 #4
0
ファイル: performance.py プロジェクト: leonardocfor/cofl
def checkLatency(nodes, rankMsg, myLogFile):
    """
	Checking average latency between nodes in the cluster
	"""

    try:

        qOfNodes = len(nodes)
        user = os.popen('whoami').read()[0:-1]
        IPS = []
        for node in nodes:
            IPS.append(
                os.popen("cat /etc/hosts | grep " + node +
                         " | tail -1 | awk '{print $1}'").read()[0:-1])
        logger(
            myLogFile, rankMsg, LOG_STD,
            'Checking average latency between nodes in COFL simulation cluster'
        )
        averageLatency = 0.0
        for IP in IPS:
            for otherIP in filter(lambda otherIP: otherIP != IP, IPS):
                lat = executeCommand(
                    'ssh ' + user + '@' + otherIP + ' -C "ping -c 4 ' + IP +
                    '" | grep from | awk {\'print $7\'} | cut -d \'=\' -f2 ',
                    '', True)[0][0:-1].split('\n')
                latency = sum([float(x) for x in lat]) / len(lat)
                averageLatency += float(latency)
                logger(
                    myLogFile, rankMsg, LOG_STD,
                    'Latency between ' + str(otherIP) + ' and ' + str(IP) +
                    ' = ' + str(latency) + ' [mS]')

        averageLatency = averageLatency / (qOfNodes * (qOfNodes - 1))
        logger(
            myLogFile, rankMsg, LOG_STD,
            'Average latency between nodes in COFL simulation cluster = ' +
            str(averageLatency) + ' [mS]')
        return averageLatency

    except Exception as e:
        raise
コード例 #5
0
ファイル: performance.py プロジェクト: leonardocfor/cofl
def checkBandwidth(nodes, rankMsg, myLogFile):
    """
	Checking average bandwidth between nodes in the cluster
	"""
    try:
        qOfNodes = len(nodes)
        protocols = ['UDP', 'TCP']
        user = os.popen('whoami').read()[0:-1]
        IPS = []
        for node in nodes:
            IPS.append(
                os.popen("cat /etc/hosts | grep " + node +
                         " | tail -1 | awk '{print $1}'").read()[0:-1])

        logger(
            myLogFile, rankMsg, LOG_STD,
            'Checking average bandwith between nodes in COFL simulation cluster'
        )
        averageBandwidth = {'UDP': 0.0, 'TCP': 0.0}
        for protocol in protocols:
            bandwidth = 0.0
            for IP in IPS:
                for otherIP in filter(lambda otherIP: otherIP != IP, IPS):
                    server = IP
                    client = otherIP
                    commandServer = 'iperf -s'
                    commandClient = 'iperf -c' + ' ' + server
                    if (protocol == 'UDP'):
                        [commandServer, commandClient] = [
                            x + y
                            for x, y in zip([commandServer, commandClient],
                                            [' -u', ' -u | grep sec'])
                        ]
                    proc = Process(target=executeCommandInNode,
                                   args=(
                                       server,
                                       user,
                                       commandServer,
                                   ))
                    proc.daemon = True
                    proc.start()
                    executeCommand('sleep 2', '', True)
                    out = executeCommandInNode(client, user, commandClient)[0]
                    bValue = out.split(' ')[-2]
                    units = out.split(' ')[-1][0:-1]
                    if (units == 'Gbits/sec'): bValue = float(bValue) * 1024
                    if (units == 'Kbits/sec'): bValue = float(bValue) / 1024
                    bandwidth += float(bValue)
                    killProcess(user, server, 'iperf')
                    killProcess(user, server, 'iperf')
                    executeCommandInNode(server, user, 'killall iperf')
                    logger(
                        myLogFile, rankMsg, LOG_STD, 'Bandwith between ' +
                        str(IP) + ' and ' + str(otherIP) + ', protocol ' +
                        str(protocol) + ' = ' + str(bValue) + ' [MB]')
            averageBandwidth[protocol] = bandwidth / (qOfNodes *
                                                      (qOfNodes - 1))
        logger(
            myLogFile, rankMsg, LOG_STD,
            'Average bandwith between nodes in COFL simulation cluster = ' +
            str(averageBandwidth) + ' [MB]')
        return averageBandwidth

    except Exception as e:
        raise