def collect_crm_config(): workdir = constants.WORKDIR if os.path.isfile(os.path.join(workdir, constants.CIB_F)): cmd = r"CIB_file=%s/%s crm configure show" % (workdir, constants.CIB_F) crmutils.str2file( utillib.get_command_info(cmd)[1], os.path.join(workdir, constants.CIB_TXT_F))
def collect_perms_state(): out_string = "" for check_dir in [ constants.PCMK_LIB, constants.PE_STATE_DIR, constants.CIB_DIR ]: flag = 0 out_string += "##### Check perms for %s: " % check_dir stat_info = os.stat(check_dir) if not stat.S_ISDIR(stat_info.st_mode): flag = 1 out_string += "\n%s wrong type or doesn't exist\n" % check_dir continue if stat_info.st_uid != pwd.getpwnam('hacluster')[2] or\ stat_info.st_gid != pwd.getpwnam('hacluster')[3] or\ "%04o" % (stat_info.st_mode & 0o7777) != "0750": flag = 1 out_string += "\nwrong permissions or ownership for %s: " % check_dir out_string += utillib.get_command_info( "ls -ld %s" % check_dir)[1] + '\n' if flag == 0: out_string += "OK\n" perms_f = os.path.join(constants.WORKDIR, constants.PERMISSIONS_F) crmutils.str2file(out_string, perms_f)
def collect_dlm_info(): """ get dlm info """ if utillib.which("dlm_tool"): out_string = "##### NOTICE - Lockspace overview:\n" out_string += utillib.get_command_info("dlm_tool ls")[1] + '\n' for item in utillib.grep("^name", incmd="dlm_tool ls"): lock_name = item.split()[1] out_string += "## NOTICE - Lockspace {}\n".format(lock_name) out_string += utillib.get_command_info( "dlm_tool lockdebug {}".format(lock_name))[1] + '\n' out_string += "##### NOTICE - Lockspace history:\n" out_string += utillib.get_command_info("dlm_tool dump")[1] + '\n' dlm_f = os.path.join(constants.WORKDIR, constants.DLM_DUMP_F) crmutils.str2file(out_string, dlm_f)
def collect_time_status(): out_string = "Time: " out_string += datetime.datetime.now().strftime('%c') + '\n' out_string += "ntpdc: " out_string += utillib.get_command_info("ntpdc -pn")[1] + '\n' time_f = os.path.join(constants.WORKDIR, constants.TIME_F) crmutils.str2file(out_string, time_f)
def collect_corosync_blackbox(): fdata_list = [] for f in utillib.find_files("/var/lib/corosync", constants.FROM_TIME, constants.TO_TIME): if re.search("fdata", f): fdata_list.append(f) if fdata_list: blackbox_f = os.path.join(constants.WORKDIR, constants.COROSYNC_RECORDER_F) crmutils.str2file( utillib.get_command_info("corosync-blackbox")[1], blackbox_f)
def collect_sys_stats(): out_string = "" cmd_list = [ "hostname", "uptime", "ps axf", "ps auxw", "top -b -n 1", "ip addr", "ip -s link", "ip n show", "lsscsi", "lspci", "mount", "cat /proc/cpuinfo", "df" ] for cmd in cmd_list: out_string += "##### run \"%s\" on %s\n" % (cmd, constants.WE) if cmd != "df": out_string += utillib.get_command_info(cmd)[1] + '\n' else: out_string += utillib.get_command_info_timeout(cmd) + '\n' sys_stats_f = os.path.join(constants.WORKDIR, constants.SYSSTATS_F) crmutils.str2file(out_string, sys_stats_f)
def collect_config(): workdir = constants.WORKDIR if os.path.isfile(constants.CONF): shutil.copy2(constants.CONF, workdir) if crmutils.is_process("pacemaker-controld") or crmutils.is_process( "crmd"): utillib.dump_state(workdir) open(os.path.join(workdir, "RUNNING"), 'w') else: shutil.copy2(os.path.join(constants.CIB_DIR, constants.CIB_F), workdir) open(os.path.join(workdir, "STOPPED"), 'w') if os.path.isfile(os.path.join(workdir, constants.CIB_F)): cmd = "crm_verify -V -x %s" % os.path.join(workdir, constants.CIB_F) crmutils.str2file( utillib.get_command_info(cmd)[1], os.path.join(workdir, constants.CRM_VERIFY_F))