def doCheck(self): global networkCards if (self.cluster): # Get node information LocalNodeInfo = self.cluster.getDbNodeByName(self.host) # Get the IP address serviceIP = LocalNodeInfo.backIps[0] elif (self.ipAddr): serviceIP = self.ipAddr else: serviceIP = SharedFuncs.getIpByHostName(self.host) networkCards = g_network.getAllNetworkInfo() for network in networkCards: if (network.ipAddress == serviceIP): networkCardNum = network.NICNum netBondMode = network.networkBondModeInfo break self.result.val = netBondMode self.result.rst = ResultStatus.OK self.result.raw = "%s\n%s\n" % (networkCardNum, netBondMode) bondFile = '/proc/net/bonding/%s' % networkCardNum if (os.path.exists(bondFile)): self.result.raw += bondFile flag1 = g_file.readFile(bondFile, 'BONDING_OPTS') flag2 = g_file.readFile(bondFile, 'BONDING_MODULE_OPTS') if (not flag1 and not flag2): self.result.rst = ResultStatus.NG self.result.val += "\nNo 'BONDING_OPTS' or" \ " 'BONDING_MODULE_OPTS' in bond" \ " config file[%s]." % bondFile
def doCheck(self): flag = "Normal" networkCardNums = [] if (self.cluster): LocalNodeInfo = self.cluster.getDbNodeByName(self.host) backIP = LocalNodeInfo.backIps[0] else: backIP = SharedFuncs.getIpByHostName(self.host) allNetworkInfo = g_network.getAllNetworkInfo() for network in allNetworkInfo: if (network.ipAddress == backIP): networkNum = network.NICNum BondMode = network.networkBondModeInfo confFile = network.networkConfigFile break if (not networkNum or not BondMode or not confFile): raise Exception(ErrorCode.GAUSS_506["GAUSS_50619"]) if (BondMode != "BondMode Null"): bondFile = '/proc/net/bonding/%s' % networkNum bondInfoList = g_file.readFile(bondFile, "Slave Interface") for bondInfo in bondInfoList: networkNum = bondInfo.split(':')[-1].strip() networkCardNums.append(networkNum) else: networkCardNums.append(networkNum) for networkCardNum in networkCardNums: RXvalue = "" TXvalue = "" for network in allNetworkInfo: if (network.NICNum == networkCardNum and str(network.RXValue).strip() != "" and str(network.TXValue).strip() != ""): RXvalue = network.RXValue TXvalue = network.TXValue if (not RXvalue or not TXvalue): flag = "Error" self.result.val += "Failed to obtain network card [%s]" \ " RX or TX value." % networkCardNum continue if (int(RXvalue) < int(EXPECTED_RXTX)) or (int(TXvalue) < int(EXPECTED_RXTX)): flag = "Error" self.result.val += "NetWork[%s]\nRX: %s\nTX: %s\n" % ( networkCardNum, RXvalue, RXvalue) self.result.raw = self.result.val if (flag == "Normal"): self.result.rst = ResultStatus.OK else: self.result.rst = ResultStatus.NG
def doCheck(self): global errorMsg global serviceIP global MaxDelayFailFlag self.getTestFile() serviceIP = SharedFuncs.getIpByHostName(self.host) for network in g_network.getAllNetworkInfo(): if (network.ipAddress == serviceIP): networkCardNum = network.NICNum break if (not networkCardNum): raise Exception(ErrorCode.GAUSS_506["GAUSS_50619"]) ethName = networkCardNum ipList = self.makeIpList() index = ipList.index(serviceIP) self.runServer(serviceIP) self.runClient(index, ipList) try: before_recv = psutil.net_io_counters(True)[ethName].packets_recv before_drop = psutil.net_io_counters(True)[ethName].dropin except Exception as e: self.doClean() self.result.rst = ResultStatus.NG self.result.val = "get %s RX drop percentage failed." % ethName raise Exception(ErrorCode.GAUSS_506["GAUSS_50621"] + "Error: %s" % str(e)) time.sleep(10) MaxDelayMsg = "Failde to get max delay." MaxDelayFailFlag = False pool = ThreadPool(self.getCpuSet()) results = pool.map(self.checkMaxDelay, ipList) pool.close() pool.join() if MaxDelayFailFlag: errorMsg.append(MaxDelayMsg) self.checkSar(ethName) self.checkDrop(ethName, before_recv, before_drop) if errorMsg == []: self.result.rst = ResultStatus.OK self.result.val = "Check passed.\n%s" % speedMsg else: self.result.rst = ResultStatus.WARNING self.result.val = "Check not passed:\n" + "\n".join( errorMsg) + "\n%s" % speedMsg
def doCheck(self): global networkCardNum if self.cluster: # Get node information LocalNodeInfo = self.cluster.getDbNodeByName(self.host) # Get the IP address backIP = LocalNodeInfo.backIps[0] else: backIP = SharedFuncs.getIpByHostName(self.host) # Get the network card number networkCards = g_network.getAllNetworkInfo() for network in networkCards: if network.ipAddress == backIP: networkCardNum = network.NICNum networkMTU = network.MTUValue break if not networkCardNum or not networkMTU: raise Exception(ErrorCode.GAUSS_506["GAUSS_50619"]) # Check the mtu value obtained is not a number if not str(networkMTU).isdigit(): raise Exception(ErrorCode.GAUSS_506["GAUSS_50612"] % (networkCardNum + " " + "MTU")) self.result.val = str(networkMTU) # Compare the acquired MTU with the threshold if (int(networkMTU) != int(self.expectMTU1) and int(networkMTU) != int(self.expectMTU2)): self.result.rst = ResultStatus.WARNING self.result.raw = "Warning MTU value[%s]: RealValue '%s' " \ "ExpectedValue '%s' or '%s'.\n" \ % (networkCardNum, int(networkMTU), self.expectMTU1, self.expectMTU2) else: self.result.rst = ResultStatus.OK self.result.raw = "[%s]MTU: %s" \ % (networkCardNum, str(networkMTU))
def doCheck(self): if (not os.path.isfile("/sys/module/sctp/parameters/no_checksums")): self.result.rst = ResultStatus.OK self.result.val = "The SCTP service is not used and the" \ " check item is skipped" return expect = "N" if (self.cluster): LocalNodeInfo = self.cluster.getDbNodeByName(self.host) serviceIP = LocalNodeInfo.backIps[0] else: serviceIP = SharedFuncs.getIpByHostName(self.host) for network in g_network.getAllNetworkInfo(): if (network.ipAddress == serviceIP): networkCardNum = network.NICNum networkBond = network.networkBondModeInfo break if (not networkCardNum or not networkBond): raise Exception(ErrorCode.GAUSS_506["GAUSS_50619"]) (distname, version) = self.getOSversion() if ((distname in ("redhat", "centos")) and (version in ("6.4", "6.5")) and networkBond != "BondMode Null"): expect = "Y" output = \ g_file.readFile('/sys/module/sctp/parameters/no_checksums')[0] if (output.strip() == expect): self.result.rst = ResultStatus.OK self.result.val = "Nochecksum value is %s,Check items pass." \ % output.strip() else: self.result.rst = ResultStatus.NG self.result.val = "Nochecksum value(%s) is not %s," \ "Check items are not passed." \ % (output.strip(), expect)
def doCheck(self): global needRepairNetworkCardNum global networkCardNums flag = "Normal" self.result.val = "" self.result.raw = "" if self.cluster: LocalNodeInfo = self.cluster.getDbNodeByName(self.host) backIP = LocalNodeInfo.backIps[0] elif self.ipAddr: backIP = self.ipAddr else: backIP = SharedFuncs.getIpByHostName(self.host) # Get the network card number allNetworkInfo = g_network.getAllNetworkInfo() for network in allNetworkInfo: if network.ipAddress == backIP: networkNum = network.NICNum BondMode = network.networkBondModeInfo confFile = network.networkConfigFile break if not networkNum or not BondMode or not confFile: if DefaultValue.checkDockerEnv(): return raise Exception(ErrorCode.GAUSS_506["GAUSS_50619"]) if BondMode != "BondMode Null": bondFile = '/proc/net/bonding/%s' % networkNum bondInfoList = g_file.readFile(bondFile, "Slave Interface") for bondInfo in bondInfoList: networkNum = bondInfo.split(':')[-1].strip() networkCardNums.append(networkNum) else: networkCardNums.append(networkNum) for networkCardNum in networkCardNums: cmdGetSpeedStr = "/sbin/ethtool %s | grep 'Speed:'" \ % networkCardNum (status, output) = subprocess.getstatusoutput(cmdGetSpeedStr) if len(output.split('\n')) > 1: for line in output.split('\n'): if line.find("Speed:") >= 0: output = line break if output.find("Speed:") >= 0 and output.find("Mb/s") >= 0: netLevel = int(output.split(':')[1].strip()[:-4]) if netLevel >= int(netWorkLevel): cmd = "for i in `cat /proc/interrupts | grep '%s-' |" \ " awk -F ' ' '{print $1}' | " \ "awk -F ':' '{print $1}'`; " \ "do cat /proc/irq/$i/smp_affinity ; done" \ % networkCardNum (status, output) = subprocess.getstatusoutput(cmd) if status != 0: self.result.val += "Failed to obtain network card" \ " [%s] interrupt value. " \ "Commands for getting interrupt" \ " value: %s.\n" % (networkCardNum, cmd) if networkCardNum not in needRepairNetworkCardNum: needRepairNetworkCardNum.append(networkCardNum) flag = "Error" continue # cpu core number followed by 1 2 4 8,every 4 left shift 1 Mapping = {0: "1", 1: "2", 2: "4", 3: "8"} for index, eachLine in enumerate(output.split()): # Remove the ',' eachLine = eachLine.replace(",", "") # Replace 0000,00001000 to 1,Remove invalid content validValue = eachLine.replace("0", "") # Convert the row index to the expected value expandNum = Mapping[index % 4] # Convert line index to expected position expandBit = index / 4 * -1 - 1 # value and position is correct if (len(eachLine) * -1) > expandBit: self.result.val += "Network card [%s] " \ "multi-queue support is not" \ " enabled.\n" % networkCardNum flag = "Error" break if (eachLine[expandBit] == expandNum and validValue == expandNum): continue else: self.result.val += "Network card [%s] " \ "multi-queue support is " \ "not enabled.\n" \ % networkCardNum if (networkCardNum not in needRepairNetworkCardNum): needRepairNetworkCardNum.append(networkCardNum) flag = "Error" break self.result.raw += "%s: \n %s \n" \ % (networkCardNum, output) else: self.result.val += "Warning: The speed of current card" \ " \"%s\" is less than %s Mb/s.\n" \ % (networkCardNum, netWorkLevel) else: if output.find("Speed:") >= 0: if (networkCardNum not in needRepairNetworkCardNum): needRepairNetworkCardNum.append(networkCardNum) flag = "Error" self.result.val += "Failed to obtain the network card" \ " [%s] speed value. Maybe the network" \ " card is not working.\n" \ % networkCardNum else: self.result.val += "Failed to obtain the network" \ " card [%s] speed value. Commands" \ " for obtain the network card speed:" \ " %s. Error:\n%s\n" \ % (networkCardNum, cmdGetSpeedStr, output) if flag == "Normal": self.result.rst = ResultStatus.OK elif flag == "Warning": self.result.rst = ResultStatus.WARNING else: self.result.rst = ResultStatus.NG