예제 #1
0
def getReport():
    # Capture data about stoped instances
    # Return a Report (i.e: list of ( sectionName,  text ) tuple )
    # Lets determine the list of instances
    report = []

    def addSection(name, text):
        report.append((name, text))

    instancesOK = []
    instancesKO = []
    for instdir in DirSrv().list(all=True):
        inst = DirSrv()
        inst.allocate(instdir)
        if inst.status():
            instancesOK.append(inst)
        else:
            instancesKO.append(inst)
    text = ""
    # Lets generate the report
    addSection("Running instances",
               loglist([i.getServerId() for i in instancesOK]))
    addSection("Stopped instances",
               loglist([i.getServerId() for i in instancesKO]))

    # Get core file informations
    addSection("Core files", logcorefiles())

    # Get asan file informations
    report.extend(logasanfiles())

    # Get error log informations on stopped servers
    # By default we only log an extract of error log:
    #   Critical, Emergency and standard errors
    #   and the final "server stopped" info line (that denotes a clean stop)
    for inst in instancesKO:
        # Log extract of error log
        path = inst.ds_paths.error_log.format(instance_name=inst.getServerId())
        addSection(f"Extract of instance {inst.getServerId()} error log",
                   logErrors(path))
        # And dbscan -L output
        addSection(f"Database info for instance {inst.getServerId()}",
                   logDbscan(inst))

    return report