示例#1
0
    def mainloop(self):
        if (self.inf_stats):
            s_nstats = "infinite"
        else:
            s_nstats = str(self.num_stats)

        qa_common.log("Collecting %s stats on %i second intervals" %
                      (s_nstats, self.interval))

        i = 0
        start_time = time.time()
        while True:
            qa_common.log("Trying to create an SSH client")
            try:
                with self.create_client() as client:
                    for m in self.__measurement_loop(client, start_time):
                        yield m

                        if (not self.inf_stats):
                            i += 1
                            if (i == self.num_stats):
                                return

            except paramiko.ssh_exception.NoValidConnectionsError:
                qa_common.error("No connection!")
                time.sleep(failed_connection_cooldown)
示例#2
0
    def parse_dump_files(core_list, result_list, core_path_prefix):

        # Catch binary name from file output, we're not interested in
        # anything else
        pattern = ".*ELF.+core file.+from '([^ ]+).*'"
        re_prog = re.compile(pattern)
        binary_match_id = 1

        # Last atom is apparently always a blank line
        for dump in core_list:
            if (dump == ""):
                continue

            dump = dump.replace(" ", "\ ")

            file_cmd = ["file", dump]
            output = qa_common.remote_cmd(target_ip, user, passwd, file_cmd)
            re_match = re_prog.match(output)

            # Notify user if there is for example an empty file, but keep
            # going anyway
            if (re_match == None):
                qa_common.error("Non-matching core file " + dump)
                continue

            # If the dumps are on some other than current partition,
            # prefix the binary names with path to partition root
            binary = re_match.group(binary_match_id)
            binary = core_path_prefix + binary
            this_dump = {"binary": binary, "corefile": dump}
            result_list.append(this_dump)
示例#3
0
def main():
    pidfile_path = os.path.join(qa_common.PLOTFASTER_PID_FILE_DIR,
                                qa_common.PLOTFASTER_PID_FILE_NAME)
    tests = {}
    pids = get_pids(pidfile_path)

    for pid in pids:
        try:
            test_name = get_test_name(pid)
            tests[test_name] = pid

        except NoTestNameError as e:
            qa_common.log(
                "Warning: No pid %i running, removing from pid list" % pid)
            unlist_pid(pidfile_path, pid)

    if (pids == []):
        qa_common.error(errmsg_no_pids)
        return 1

    try:
        pid = ask_which_test(tests)
        os.kill(pid, signal.SIGTERM)
        print("Ended test execution")
        return 0
    except EOFError:
        return 0

    except Exception as e:
        qa_common.error(errmsg_kill_fail % (pid, e))
        return 1
示例#4
0
def main(argv):
    args = qa_common.parse_args(argv, cmdline_args)
    try:
        with open(args.infile, "rb") as f:
            report_zlib = f.read()
    except FileNotFoundError as e:
        qa_common.error(e)

    os.makedirs(args.graph_path, exist_ok=True)
    export(report_zlib, args.graph_path, args.conffile)
示例#5
0
def main():
    parse_args()
    if (not qa_common.test_connection(target_ip, user, passwd)):
        qa_common.error("Couldn't connect to %s" % target_ip)
        sys.exit(1)
    qa_common.log("Injecting credentials from file %s" % cred_file_local)
    inject_credentials(cred_file_local, cred_file_path, cred_file_name)

    dumps = get_coredumps(partition_roots, core_dir)
    packages = get_all_packages(dumps)
    if (len(packages) > 0):
        install_packages(packages)
    else:
        qa_common.log("No packages to be installed!")
示例#6
0
def main(argv):
    args = qa_common.parse_args(argv, cmdline_args)
    setup_sigterm_handler()
    detach_from_stdin()
    report = None

    # Apparently you cannot reconnect a failed client object, so let
    # reporter create its own clients whenever old one breaks down
    create_client = lambda: qa_common.create_ssh_client(
        args.target_ip, args.username, args.password)
    ofnames = generate_outfile_names(args.target_ip, args.report_path_format,
                                     args.outfile, args.log_to_stdout)

    report_file, qa_common.log_target, report_path, test_name = ofnames
    os.makedirs(report_path, exist_ok=True)
    try:
        stress_clients = exec_stress(create_client, args.stress_procs)

        qa_common.log("Switching to reporter, writing report to %s" %
                      report_file)

        try:
            my_reporter = reporter.Reporter(args.interval, create_client,
                                            args.num_stats, args.rss_threshold)

        except reporter.Reporter.NoConnectionError:
            qa_common.error("No connection to %s" % args.target_ip)
            return 1

        comp = BackupZlibCompressor(report_file)
        for measurement in my_reporter.mainloop():
            bdata = json.dumps(measurement).encode("utf-8") + b"\n"
            report = comp.add_data(bdata)

    # Exit gracefully without puking up a stack trace
    except (KeyboardInterrupt, SystemExit):
        pass

    finally:
        kill_clients(stress_clients)
        if (report is not None):
            qa_common.log("Exporting from %s to path %s" %
                          (report_file, report_path))

            exporter.export(report, report_path)

    return 0