Beispiel #1
0
    def getClusterNodesPackagesInstalledSummary(self):
        """
        Returns a string that contains information about the
        cluster/cluster-storage packages installed for each node.

        @return: A string that contains information about the
        cluster/cluster-storage package installed for each node.
        @rtype: String
        """
        rstring = ""
        stringUtil = StringUtil()
        for clusternode in self.getClusterNodes():
            if (len(rstring) > 0):
                rstring += "\n"
            rstring += "%s:" % (clusternode.getHostname())

            # Verify cluster packages
            # Combine the packages of cluster and storage
            packages = dict(clusternode.getClusterPackagesVersion(),
                            **clusternode.getClusterModulePackagesVersion())
            # Create a simple list of packages that are kernel modules to
            # compare with later.
            mPackages = []
            for cPackages in clusternode.getClusterModulePackagesVersion(
            ).values():
                for cPackage in cPackages:
                    mPackages.append(cPackage)
            keys = packages.keys()
            keys.sort()
            index = 0
            fsTable = []
            currentTable = []
            for key in keys:
                cPackages = packages[key]
                cPackages.sort()
                for cPackage in cPackages:
                    if (cPackage in mPackages):
                        cPackage = "*%s" % (cPackage)
                    if (index % 2 == 0):
                        if (len(currentTable) > 0):
                            fsTable.append(currentTable)
                        currentTable = []
                        currentTable.append("%s      " % (cPackage))
                    else:
                        currentTable.append(cPackage)
                    index += 1
            if (len(currentTable) > 0):
                startIndex = len(currentTable)
                for i in range(len(currentTable), 2):
                    currentTable.append(" ")
                fsTable.append(currentTable)
            if (len(fsTable) > 0):
                packageTableString = stringUtil.toTableString(fsTable)
                rstring += ("\n%s\n") % (packageTableString)
            else:
                rstring += "\nThere was no High Availability or Resilient Storage Packages Found.\n"
        # Remove an extra newline
        rstring = rstring.rstrip("\n")
        return rstring
Beispiel #2
0
    def getClusterNodesNetworkSummary(self):
        rstring = ""
        stringUtil = StringUtil()
        for clusternode in self.getClusterNodes():
            networkMaps = clusternode.getNetworkMaps()
            hbNetworkMap = clusternode.getHeartbeatNetworkMap()

            if (not len(networkMaps.getListOfNetworkMaps()) > 0):
                # Skip if there is no maps
                continue
            if (len(rstring) > 0):
                rstring += "\n"

            # Get the hb interface so we can flag interface and if
            # bonded its slave interfaces are put into a list.
            hbInterfaceBondedSlaves = []
            for slaveInterface in hbNetworkMap.getBondedSlaveInterfaces():
                hbInterfaceBondedSlaves.append(slaveInterface.getInterface())

            # Find alias if there is one and if parent alias is bond
            # then add to the list slave interfaces.
            parentAliasInterface = ""
            if (not hbNetworkMap.getParentAliasNetworkMap() == None):
                parentAliasInterface = hbNetworkMap.getParentAliasNetworkMap(
                ).getInterface()
                if (hbNetworkMap.getParentAliasNetworkMap().
                        isBondedMasterInterface()):
                    for slaveInterface in hbNetworkMap.getParentAliasNetworkMap(
                    ).getBondedSlaveInterfaces():
                        hbInterfaceBondedSlaves.append(
                            slaveInterface.getInterface())

            # Add netork informaton to string that will be returned.
            rstring += "%s:\n" % (clusternode.getHostname())
            networkInterfaceTable = []
            for networkMap in networkMaps.getListOfNetworkMaps():
                isHBInterface = ""
                if (networkMap.getInterface().strip() ==
                        hbNetworkMap.getInterface().strip()):
                    isHBInterface = "*"
                elif (
                    (networkMap.getInterface().strip() == parentAliasInterface)
                        and (parentAliasInterface > 0)):
                    isHBInterface = "***"
                elif (networkMap.getInterface().strip()
                      in hbInterfaceBondedSlaves):
                    isHBInterface = "**"
                networkInterfaceTable.append([
                    networkMap.getInterface(),
                    networkMap.getNetworkInterfaceModule(),
                    networkMap.getHardwareAddress(),
                    networkMap.getIPv4Address(), isHBInterface
                ])
            tableHeader = [
                "device", "module", "hw_addr", "ipv4_addr", "hb_interface"
            ]
            rstring += "%s\n" % (stringUtil.toTableString(
                networkInterfaceTable, tableHeader))
        return rstring.strip("\n")
Beispiel #3
0
    def report(self):
        """
        This function will write the data that was analyzed to a file.
        """
        message = "Generating report for plugin: %s" % (self.getName())
        logging.getLogger(sx.MAIN_LOGGER_NAME).status(message)

        stringUtil = StringUtil()
        if (len(self.__listOfNetworkingData) > 0):
            # Since we are going to run the plugin and create files in
            # the plugins report directory then we will first remove
            # all the existing files.
            self.clean()

        for networkingData in self.__listOfNetworkingData:
            message = "Writing the network report for: %s." % (
                networkingData.getHostname())
            logging.getLogger(sx.MAIN_LOGGER_NAME).debug(message)

            # could be a problem if they are all using localhost.
            ar = AnalysisReport(
                "networking_summary-%s" % (networkingData.getHostname()),
                "Network Summary")
            self.addAnalysisReport(ar)
            arSectionSystemSummary = ARSection("networking-system_summary",
                                               "System Summary")
            ar.add(arSectionSystemSummary)
            arSectionSystemSummary.add(
                ARSectionItem(networkingData.getHostname(),
                              networkingData.getSummary()))

            # Get all the network maps that were built.
            networkMaps = networkingData.getNetworkMaps()
            # Bonded Interface Summary
            bondedInterfaceList = networkMaps.getListOfBondedNetworkMaps()
            bondedInterfaceTable = []
            for bondedInterface in bondedInterfaceList:
                bondingNumber = bondedInterface.getBondedModeNumber()
                bondingName = bondedInterface.getBondedModeName()
                slaveInterfaces = ""
                for slaveInterface in bondedInterface.getBondedSlaveInterfaces(
                ):
                    slaveInterfaces += " %s(%s) |" % (
                        slaveInterface.getInterface(),
                        slaveInterface.getNetworkInterfaceModule())
                slaveInterfaces = slaveInterfaces.rstrip("|")
                bondedInterfaceTable.append([
                    bondedInterface.getInterface(), bondingNumber, bondingName,
                    slaveInterfaces,
                    bondedInterface.getIPv4Address()
                ])
            if (len(bondedInterfaceTable) > 0):
                tableHeader = [
                    "device", "mode_#", "mode_name", "slave_interfaces",
                    "ipv4_address"
                ]
                arSectionBondedSummary = ARSection(
                    "networking-bonding_summary", "Bonding Summary")
                ar.add(arSectionBondedSummary)
                arSectionBondedSummary.add(
                    ARSectionItem(
                        networkingData.getHostname(),
                        stringUtil.toTableString(bondedInterfaceTable,
                                                 tableHeader)))

            # Bridged Inteface Summary
            bridgedInterfaceTable = []
            for networkMap in networkMaps.getListOfBridgedNetworkMaps():
                virtualBridgeNetworkMap = networkMap.getVirtualBridgedNetworkMap(
                )
                if (not virtualBridgeNetworkMap == None):
                    bridgedInterfaceTable.append([
                        networkMap.getInterface(),
                        virtualBridgeNetworkMap.getInterface(),
                        virtualBridgeNetworkMap.getIPv4Address()
                    ])
            if (len(bridgedInterfaceTable) > 0):
                tableHeader = [
                    "bridge_device", "virtual_bridge_device", "ipv4_addr"
                ]
                arSectionBridgedInterfacesSummary = ARSection(
                    "networking-bridged_interfaces_summary",
                    "Bridged Interfaces Summary")
                ar.add(arSectionBridgedInterfacesSummary)
                arSectionBridgedInterfacesSummary.add(
                    ARSectionItem(
                        networkingData.getHostname(),
                        stringUtil.toTableString(bridgedInterfaceTable,
                                                 tableHeader)))

            # Aliases Interface Summary
            aliasesInterfaceTable = []
            networkInterfaceAliasMap = networkMaps.getNetworkInterfaceAliasMap(
            )
            for key in networkInterfaceAliasMap.keys():
                for key in networkInterfaceAliasMap.keys():
                    aliasInterfacesString = ""
                    for networkMap in networkInterfaceAliasMap[key]:
                        aliasInterfacesString += " %s |" % (
                            networkMap.getInterface())
                    aliasInterfacesString = aliasInterfacesString.rstrip("|")
                    aliasesInterfaceTable.append([key, aliasInterfacesString])

            if (len(aliasesInterfaceTable) > 0):
                tableHeader = ["device", "alias_interfaces"]
                arSectionNetworkingAliasesSummary = ARSection(
                    "networking-networking_aliases_summary",
                    "Networking Aliases Summary")
                ar.add(arSectionNetworkingAliasesSummary)
                arSectionNetworkingAliasesSummary.add(
                    ARSectionItem(
                        networkingData.getHostname(),
                        stringUtil.toTableString(aliasesInterfaceTable,
                                                 tableHeader)))

            # Network Summary
            networkInterfaceTable = []
            for networkMap in networkMaps.getListOfNetworkMaps():
                networkInterfaceTable.append([
                    networkMap.getInterface(),
                    networkMap.getNetworkInterfaceModule(),
                    networkMap.getHardwareAddress(),
                    networkMap.getIPv4Address()
                ])
            if (len(networkInterfaceTable) > 0):
                tableHeader = ["device", "module", "hw_addr", "ipv4_addr"]
                arSectionNetworkingSummary = ARSection(
                    "networking-networking_summary", "Networking Summary")
                ar.add(arSectionNetworkingSummary)
                arSectionNetworkingSummary.add(
                    ARSectionItem(
                        networkingData.getHostname(),
                        stringUtil.toTableString(networkInterfaceTable,
                                                 tableHeader)))
            # Wrtite the output to a file.
            self.write("%s.txt" % (ar.getName()), "%s\n" % (str(ar)))
Beispiel #4
0
    def __generateReport(self, cnc):
        # Name of the file that will be used to write the report.
        if (not len(cnc.getClusterNodes()) > 0):
            message = "There were no cluster nodes found for this cluster."
            logging.getLogger(sx.MAIN_LOGGER_NAME).warn(message)
        else:
            baseClusterNode = cnc.getBaseClusterNode()
            if (baseClusterNode == None):
                # Should never occur since node count should be checked first.
                return
            cca = ClusterHAConfAnalyzer(baseClusterNode.getPathToClusterConf())

            # List of clusternodes in cluster.conf that do not have
            # corresponding sosreport/sysreport.
            filename = "%s-summary.txt" % (cca.getClusterName())
            missingNodesList = cnc.listClusterNodesMissingReports()
            missingNodesMessage = ""
            if (len(missingNodesList) > 0):
                missingNodesMessage = "The following cluster nodes could not be matched to a report that was analyzed:"
                for nodeName in missingNodesList:
                    missingNodesMessage += "\n\t  %s" % (nodeName)
                logging.getLogger(
                    sx.MAIN_LOGGER_NAME).warn(missingNodesMessage)
                self.write(filename, "%s\n" % (missingNodesMessage))

            # ###################################################################
            # Summary of each node in collection
            # ###################################################################
            result = cnc.getClusterNodesSystemSummary()
            if (len(result) > 0):
                self.writeSeperator(
                    filename, "Cluster Nodes Summary (%s - %d Cluster Nodes)" %
                    (cca.getClusterName(), len(cca.getClusterNodeNames())))
                self.write(filename, result.rstrip())
                self.write(filename, "")

            # Write qdisk information if it exists.
            result = cca.getQuorumdSummary()
            if (len(result) > 0):
                self.writeSeperator(filename, "Cluster Quorum Disk Summary")
                self.write(filename, result.rstrip())
                self.write(filename, "")

            result = cnc.getClusterNodesPackagesInstalledSummary()
            if (len(result) > 0):
                self.writeSeperator(
                    filename, "Cluster/Cluster-Storage Packages Installed")
                self.write(
                    filename,
                    "The list of installed High Availability and Resilient Storage packages installed. Kernel Module \npackages will have an asterick(*) after their name.\n"
                )
                self.write(filename, result.rstrip())
                self.write(filename, "")

            result = cnc.getClusterNodesNetworkSummary()
            if (len(result) > 0):
                self.writeSeperator(filename, "Cluster Nodes Network Summary")
                self.write(
                    filename,
                    "*   = heartbeat network\n**  = bonded slave interfaces\n*** = parent of alias interface\n"
                )
                self.write(filename, result)
                self.write(filename, "")

            clusterHAStorage = ClusterHAStorage(cnc)
            result = clusterHAStorage.getSummary()
            if (len(result) > 0):
                self.write(filename, result.rstrip())
                self.write(filename, "")

            # ###################################################################
            # Check the cluster node services summary
            # ###################################################################
            listOfServicesforClusterNodes = []
            # Get the list of services
            for clusternode in cnc.getClusterNodes():
                chkConfigClusterServiceList = clusternode.getChkConfigClusterServicesStatus(
                )
                if (len(chkConfigClusterServiceList) > 0):
                    #sortedChkConfigClusterServicesList = sorted(chkConfigClusterServiceList, key=lambda k: k.getStartOrderNumber())
                    sortedChkConfigClusterServicesList = sorted(
                        chkConfigClusterServiceList, key=lambda k: k.getName())
                    currentListOfServices = list(
                        set(
                            map(lambda m: m.getName(),
                                sortedChkConfigClusterServicesList)))
                    listOfServicesforClusterNodes = list(
                        set(listOfServicesforClusterNodes)
                        | set(currentListOfServices))
            # Just sort alpha and not worry with order.
            listOfServicesforClusterNodes.sort()
            clusternodeServicesTable = []
            for clusternode in cnc.getClusterNodes():
                currentTable = [clusternode.getClusterNodeName()]
                #sortedChkConfigClusterServicesList = sorted(chkConfigClusterServiceList, key=lambda k: k.getStartOrderNumber())
                sortedChkConfigClusterServicesList = sorted(
                    chkConfigClusterServiceList, key=lambda k: k.getName())
                for serviceName in listOfServicesforClusterNodes:
                    serviceStatus = "-"
                    for chkConfigClusterService in sortedChkConfigClusterServicesList:
                        if (chkConfigClusterService.getName() == serviceName):
                            if (chkConfigClusterService.isEnabledRunlevel3(
                            ) and chkConfigClusterService.isEnabledRunlevel4()
                                    and chkConfigClusterService.
                                    isEnabledRunlevel5()):
                                serviceStatus = "E"
                            else:
                                serviceStatus = "D"
                    currentTable.append(serviceStatus)
                clusternodeServicesTable.append(currentTable)
            if (len(clusternodeServicesTable) > 0):
                stringUtil = StringUtil()
                tableHeader = ["hostame"] + listOfServicesforClusterNodes
                self.writeSeperator(filename, "Cluster Services Summary")
                header = "List of Clustered Services that are enabled for all of these runlevel 3, 4, and 5:\n"
                header += "- https://access.redhat.com/solutions/5898\n\nE = Enabled\nD = Disabled\n- = Unknown Status\n"
                self.write(filename, header)
                self.write(
                    filename, "%s\n" % (stringUtil.toTableString(
                        clusternodeServicesTable, tableHeader)))

            # Write a summary of the cluster.conf services
            #filename = "%s-services.txt" %(cca.getClusterName())
            clusteredServicesList = cca.getClusteredServices()
            clusteredServicesString = ""
            clusteredVMServicesString = ""
            regServiceCount = 0
            vmServiceCount = 0
            for clusteredService in clusteredServicesList:
                if (not clusteredService.isVirtualMachineService()):
                    sIndex = str(regServiceCount + 1)
                    if ((regServiceCount + 1) < 10):
                        sIndex = " %d" % (regServiceCount + 1)
                    # clusteredServicesString += "%s. %s\n\n" %(sIndex, str(clusteredService).rstrip())
                    regServiceCount = regServiceCount + 1
                elif (clusteredService.isVirtualMachineService()):
                    sIndex = str(vmServiceCount + 1)
                    if ((vmServiceCount + 1) < 10):
                        sIndex = " %d" % (vmServiceCount + 1)
                    # clusteredVMServicesString += "%s. %s\n\n" %(sIndex, str(clusteredService).rstrip())
                    vmServiceCount = vmServiceCount + 1
            if (regServiceCount > 0):
                self.writeSeperator(filename, "Clustered Services Summary")
                self.write(
                    filename,
                    "There was %d clustered services managed by rgmanager.\n" %
                    (regServiceCount))
                #self.write(filename, "%s\n" %(clusteredServicesString.rstrip()))

            if (vmServiceCount > 0):
                self.writeSeperator(
                    filename, "Clustered Virtual Machine Services Summary")
                self.write(
                    filename,
                    "There was %d clustered virtual machine services managed by rgmanager.\n"
                    % (vmServiceCount))
                #self.write(filename, "%s\n" %(clusteredVMServicesString.rstrip()))

            # ###################################################################
            # Verify the cluster node configuration
            # ###################################################################
            filenameCE = "%s-evaluator.txt" % (cca.getClusterName())
            clusterEvaluator = ClusterEvaluator(cnc)
            evaluatorResult = clusterEvaluator.evaluate()
            if (len(evaluatorResult) > 0):
                if (len(missingNodesList) > 0):
                    self.write(filenameCE, "%s\n\n" % (missingNodesMessage))
                self.writeSeperator(
                    filenameCE,
                    "Known Issues with Cluster (%s - %d Cluster Nodes)" %
                    (cca.getClusterName(), len(cca.getClusterNodeNames())))
                self.write(
                    filenameCE,
                    "NOTE: The known issues below may or may not be related to solving the current issue or preventing"
                )
                self.write(
                    filenameCE,
                    "      a issue. These are meant to be a guide in making sure that the cluster is happy and healthy"
                )
                self.write(
                    filenameCE,
                    "      healthy all the time. Please use report as a guide in reviewing the cluster.\n"
                )
                self.write(filenameCE, evaluatorResult.rstrip())
                self.write(filenameCE, "")

            # ###################################################################
            # Evaluate the reports as stretch cluster if that option is enabled.
            # ###################################################################
            isStretchCluster = self.getOptionValue("isStretchCluster")
            if (not isStretchCluster == "0"):
                filenameCE = "%s-stretch_evaluator.txt" % (
                    cca.getClusterName())
                clusterHAStretchEvaluator = ClusterHAStretchEvaluator(cnc)
                evaluatorResult = clusterHAStretchEvaluator.evaluate()
                if (len(evaluatorResult) > 0):
                    if (len(missingNodesList) > 0):
                        self.write(filenameCE,
                                   "%s\n\n" % (missingNodesMessage))
                    self.writeSeperator(filenameCE,
                                        "Known Issues with Stretch Cluster")
                    self.write(
                        filenameCE,
                        "NOTE: The known issues below may or may not be releated to solving"
                    )
                    self.write(
                        filenameCE,
                        "      the current issue or preventing a issue. These are meant to"
                    )
                    self.write(
                        filenameCE,
                        "      be a guide in making sure that the cluster is happy and"
                    )
                    self.write(
                        filenameCE,
                        "      healthy all the time. Please use report as a guide in"
                    )
                    self.write(filenameCE, "      reviewing the cluster.\n")
                    self.write(filenameCE, evaluatorResult.rstrip())
                    self.write(filenameCE, "")

            # ###################################################################
            # Verify the cluster node configuration
            # ###################################################################
            filenameCE = "%s-clusternode_compare.txt" % (cca.getClusterName())
            clusternodeCompare = ClusternodeCompare(cnc)
            compareResult = clusternodeCompare.compare()
            if (len(compareResult) > 0):
                if (len(missingNodesList) > 0):
                    self.write(filenameCE, "%s\n\n" % (missingNodesMessage))
                self.writeSeperator(filenameCE, "Clusternode Comparison")
                self.write(
                    filenameCE,
                    "The following section will show the difference between the reports when a value in a file is"
                )
                self.write(
                    filenameCE,
                    "compared against all the reports. The section will list the reports with similar values"
                )
                self.write(
                    filenameCE,
                    "and ones that are different then the similar values. The similar values is the highest number"
                )
                self.write(filenameCE, "of reports with the same value.\n")

                self.write(filenameCE, compareResult.rstrip())
                self.write(filenameCE, "")
Beispiel #5
0
    def report(self):
        """
        This function will write the data that was analyzed to a file.
        """
        message = "Generating report for plugin: %s" % (self.getName())
        logging.getLogger(sx.MAIN_LOGGER_NAME).status(message)

        if (len(self.__listOfStorageData) > 0):
            # Since we are going to run the plugin and create files in
            # the plugins report directory then we will first remove
            # all the existing files.
            self.clean()
        stringUtil = StringUtil()
        for storageData in self.__listOfStorageData:
            message = "Writing the storage report for: %s." % (
                storageData.getHostname())
            logging.getLogger(sx.MAIN_LOGGER_NAME).debug(message)

            # could be a problem if they are all using localhost.
            ar = AnalysisReport(
                "storage_summary-%s" % (storageData.getHostname()),
                "Storage Summary")
            self.addAnalysisReport(ar)
            arSectionSystemSummary = ARSection("storage-system_summary",
                                               "System Summary")
            ar.add(arSectionSystemSummary)
            arSectionSystemSummary.add(
                ARSectionItem(storageData.getHostname(),
                              storageData.getSummary()))

            # The block device tree has some of the information that
            # is needed to report on.
            bdt = storageData.getBlockDeviceTree()

            # Get all the mounted filesystems.
            mountedFSList = bdt.getFilesysMountList()
            if (len(mountedFSList) > 0):
                fsTable = []

                for fs in mountedFSList:
                    fsTable.append([
                        fs.getDeviceName(),
                        fs.getMountPoint(),
                        fs.getFSType(),
                        fs.getFSAttributes(),
                        fs.getMountOptions()
                    ])
                tableHeader = [
                    "device", "mount_point", "fs_type", "fs_attributes",
                    "fs_options"
                ]
                arSectionMountedFS = ARSection("storage-mounted_fs",
                                               "Mounted Filesystems")
                ar.add(arSectionMountedFS)
                arSectionMountedFS.add(
                    ARSectionItem(
                        storageData.getHostname(),
                        stringUtil.toTableString(fsTable, tableHeader)))

            # Write out any multipath data
            blockDeviceMap = bdt.generateDMBlockDeviceMap()
            multipathMap = bdt.getTargetTypeMap(blockDeviceMap, "multipath")
            if (len(multipathMap.keys()) > 0):
                multipathSummary = ""
                for key in multipathMap.keys():
                    multipathSummary += "%s\n" % (str(
                        multipathMap.get(key)).strip())
                arSectionMultipathSummary = ARSection(
                    "storage-multipath_summary", "Multipath Summary")
                ar.add(arSectionMultipathSummary)
                arSectionMultipathSummary.add(
                    ARSectionItem(storageData.getHostname(),
                                  multipathSummary.strip().rstrip()))

            # ###################################################################
            # Run the evaluator to look for know issues
            # ###################################################################
            storageEvaluator = StorageEvaluator(storageData)
            rstring = storageEvaluator.evaluate()
            if (len(rstring) > 0):
                arSectionKnownIssues = ARSection("storage-known_issues",
                                                 "Known Issues with Storage")
                ar.add(arSectionKnownIssues)
                arSectionKnownIssues.add(
                    ARSectionItem(storageData.getHostname(), rstring))

            # Wrtite the output to a file.
            self.write("%s.txt" % (ar.getName()), "%s\n" % (str(ar)))

            # ###################################################################
            # Create the blockDeviceTree file
            # ###################################################################
            blockDeviceMap = bdt.generateDMBlockDeviceMap()
            if (len(blockDeviceMap.keys())):
                # Print a summary of the devicemapper devices. Group by target type.
                arBDT = AnalysisReport(
                    "storage_block_device_tree-%s" %
                    (storageData.getHostname()), "Block Device Tree")
                self.addAnalysisReport(arBDT)
                for targetType in bdt.getValidTargetTypes():
                    currentBlockDeviceMap = bdt.getTargetTypeMap(
                        blockDeviceMap, targetType)
                    if (len(currentBlockDeviceMap) > 0):
                        arSectionBDT = ARSection(
                            "storage_block_device_tree-block_device_target_types",
                            "Block Device for Target Type: %s (%d targets)" %
                            (targetType, len(currentBlockDeviceMap)))
                        arBDT.add(arSectionBDT)
                        for key in currentBlockDeviceMap.keys():
                            currentBlockDevice = currentBlockDeviceMap[key]
                            arSectionBDT.add(
                                ARSectionItem(
                                    "%s-%s" %
                                    (storageData.getHostname(), targetType),
                                    "%s" % (str(currentBlockDevice))))
                self.write("%s.txt" % (arBDT.getName()), "%s\n" % (str(arBDT)))
Beispiel #6
0
 def __getProcessesSummary(self) :
     stringUtil = StringUtil()
     rString  = ""
     for glusterPeerNode in self.__glusterPeerNodes.getGlusterPeerNodes():
         pTable = []
         for process in glusterPeerNode.getGlusterProcesses():
             command = process.getCommand()
             if (len(command) > 70):
                 endStringIndex = len(command.split()[0]) + 50
                 command = command[0:endStringIndex]
             pTable.append([process.getPID(), process.getCPUPercentage(), process.getMemoryPercentage(), "%s ...." %(command)])
         if (len(pTable) > 0):
             rString += "%s(%d processes):\n%s\n\n" %(glusterPeerNode.getHostname(), len(pTable), stringUtil.toTableString(pTable, ["pid", "cpu%", "mem%", "command"]))
     return rString
Beispiel #7
0
 def __getPeerNodesSummary(self) :
     stringUtil = StringUtil()
     pTable = []
     rString  = ""
     for glusterPeerNode in self.__glusterPeerNodes.getGlusterPeerNodes():
         pTable = []
         for peerNodeMap in glusterPeerNode.getPeerNodes():
             pnHostname1 = ""
             if (peerNodeMap.has_key("hostname1")):
                 pnHostname1 = peerNodeMap.get("hostname1")
             pnUUID = ""
             if (peerNodeMap.has_key("uuid")):
                 pnUUID = peerNodeMap.get("uuid")
             pnState = ""
             if (peerNodeMap.has_key("state")):
                 pnState = peerNodeMap.get("state")
             pTable.append([pnHostname1, pnUUID, pnState])
         if (len(pTable) > 0):
             rString += "%s(%d peers):\n%s\n\n" %(glusterPeerNode.getHostname(), len(pTable), stringUtil.toTableString(pTable, ["hostname1", "uuid", "state"]))
     return rString
Beispiel #8
0
    def getClusterStorageSummary(self) :
        """
        Returns a string that contains information about the GFS1 and
        GFS2 filesystems found.

        @return: A string that contains information about the GFS1 and
        GFS2 filesystems found.
        @rtype: String
        """
        fsMap = {}
        for clusternode in self.__cnc.getClusterNodes():
            clusternodeName = clusternode.getClusterNodeName()
            csFilesystemList = clusternode.getClusterStorageFilesystemList()
            for fs in csFilesystemList:
                locationFound = ""
                if (fs.isEtcFstabMount()):
                    locationFound += "F"
                if (fs.isFilesysMount()):
                    locationFound += "M"
                if (fs.isClusterConfMount()):
                    locationFound += "C"
                if (not fsMap.has_key(clusternodeName)):
                    fsMap[clusternodeName] = []
                fsMap.get(clusternodeName).append([fs.getDeviceName(), fs.getMountPoint(), fs.getFSType(), locationFound])
        rString  = ""
        fsListHeader = ["device", "mount_point", "fs_type", "location_found"]
        stringUtil = StringUtil()
        for clusternodeName in self.__cnc.getClusterNodeNames():
            # In the future I should probably add a way to only print once if they are all the same .
            if (fsMap.has_key(clusternodeName)):
                listOfFileystems = fsMap.get(clusternodeName)
                if (len(listOfFileystems) > 0):
                    tableString = "%s(%d mounted GFS or GFS2 file-systems)\n%s\n\n" %(clusternodeName, len(listOfFileystems), stringUtil.toTableString(listOfFileystems, fsListHeader))
                    rString += tableString
        if (len(rString) > 0):
            description =  "All GFS or GFS2 filesystem are required to be created on a clustered lvm(clvm) device. All GFS or GFS2 filesystems "
            description += "should be verified that they meet this requirement. The following article describes this requirement:"
            urls = ["https://access.redhat.com/solutions/46637"]
            legend = "C = file-system is in /etc/cluster/cluster.conf\nF = file-system is in /etc/fstab\nM = file-system is mounted\n"
            rString = "%s\n%s\n%s" %(StringUtil.wrapParagraphURLs(description, urls), legend, rString)
        return rString.strip()