コード例 #1
0
    def dlm_dump(self):
        output = os.path.join(self.WORKDIR, envir.DLM_DUMP_F)
        if not utillib.do_which('dlm_tool'):
            return
        dlm_file_info = 'NOTICE - Lockspace overview:\n'
        dlm_file_info = dlm_file_info + utillib.do_command(['dlm_tool', 'ls'])

        dlm_pro = subprocess.Popen(['dlm_tool', 'ls'],
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.STDOUT)
        grep_pro = subprocess.Popen(['grep', 'name'],
                                    stdin=dlm_pro.stdout,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT)

        dlm_list = grep_pro.communicate()[0].split('\n')

        for d in dlm_list:
            strd = d.split()
            for X, N in strd:
                dlm_file_info = dlm_file_info + '\n' + 'NOTICE - Lockspace ' + N
                dlm_file_info = dlm_file_info + utillib.do_command(
                    ['dlm_tool', 'lock_dump', N])

        dlm_file_info = dlm_file_info + '\nNOTICE - Lockspace histoty:\n'
        dlm_file_info = dlm_file_info + utillib.do_command(
            ['dlm_tool', 'dump'])

        utillib.writefile(output, dlm_file_info)
コード例 #2
0
    def sys_info(self, filename):
        '''
		create file WORKDIR/sysinfo.txt
		'''
        msg = ''
        f = open(filename, 'w')
        support = __import__(self.import_support())
        cluster_version = support.cluster_info()
        msg = cluster_version

        msg = msg + utillib.do_command(
            [envir.HA_NOARCHBIN + '/hb_report', '-V'])
        msg = msg + 'resource-agents: ' + utillib.do_grep_file(
            '/usr/lib/ocf/lib/heartbeat/ocf-shellfuncs', 'Build version:')
        msg = msg + utillib.crm_info()
        msg = msg + utillib.do_command(['booth', '--version'])
        msg = msg + utillib.pkg_version()

        if envir.SKIP_LVL >= 1:
            msg = msg + utillib.verify_packages()

        msg = msg + 'Platform: ' + platform.system() + '\n'
        msg = msg + 'Kernel release: ' + platform.release() + '\n'
        msg = msg + 'Architecture: ' + platform.machine() + '\n'

        if platform.system() == 'Linux':
            dist_name = utillib.distro() + '\n'
            msg = msg + dist_name
        f.write(msg)
        f.close()
コード例 #3
0
ファイル: node.py プロジェクト: wenshizhang/hb_report
    def find_logseg(self, logf, from_time, to_time):
        logseg_path = os.path.join(envir.HA_NOARCHBIN, 'print_logseg')
        if os.access(logseg_path, os.F_OK) and os.access(logsef_path, os.X_OK):
            utillib.do_command([logseg_path, logf, from_time, to_time])

        cat = self.find_decompressor(logf).split()
        cat.append(logf)
        srcstr = utillib.do_command(cat)
        srcf = tempfile.mkstemp()[1]
        self.RM_FILES.append(srcf)
        srcfd = open(srcf, 'w')
        srcfd.write(srcstr)
        srcfd.close()

        if from_time == 0:
            FROM_LINE = 1
        else:
            FROM_LINE = utillib.findln_by_time(self, srcf, from_time)
        if not FROM_LINE:
            warning("couldn't find line for time " + from_time +
                    '; corrupt log file?')
            return ''

        TO_LINE = 0

        if to_time != 0:
            TO_LINE = utillib.findln_by_time(self, srcf, to_time)
            if not TO_LINE:
                utillib.warning("couldn't find for time " + to_time +
                                '; corrupt log file?')
                return ''

        utillib.debug('including log segment[' + str(FROM_LINE) + '-' +
                      str(TO_LINE) + '] from' + logf)
        return '\n'.join(srcstr.split('\n')[FROM_LINE:TO_LINE])
コード例 #4
0
ファイル: node.py プロジェクト: wenshizhang/hb_report
    def is_our_log(self, logf, from_time, to_time):
        '''
		check if log contains a piece of our segment
		'''
        cat = self.find_decompressor(logf).split()
        cat.append(logf)

        head_msg = utillib.do_command(['head', '-10'], utillib.do_command(cat))
        first_time = self.find_first_ts(head_msg)

        tail_msg = utillib.do_command(['tail', '-10'], utillib.do_command(cat))
        tail_msg = utillib.do_command(['tac'], tail_msg)
        last_time = self.find_first_ts(tail_msg)

        if from_time > last_time:
            #we're pass good logs; exit
            return 2

        elif from_time >= first_time:
            #this is last good log
            return 3
        elif to_time == 0 or to_time >= first_time:
            #have to go further back
            #include this log
            return 1
        else:
            #donot include this log
            return 0
コード例 #5
0
    def corosync_blackbox(self):
        outf = os.path.join(self.WORKDIR, envir.COROSYNC_RECORDER_F)
        from_time = envir.FROM_TIME
        to_time = envir.TO_TIME

        inpf = utillib.find_files(self, ['/var/lib/corosync'])

        if os.path.isfile(' '.join(inpf)):
            blkbox_info = utillib.do_command(['corosync-blackbox'])
            utillib.writefile(outf, blkbox_info)
            utillib.do_command(['touch', '-r', inpf, outf])
コード例 #6
0
    def return_result(self):
        '''
		Return logs to master through scp
		create tarfile in WORKDIR
		'''
        tarname = self.WE + '.tar'
        tarpath = os.path.join(self.WORKDIR, tarname)
        start = time.time()
        tar = tarfile.open(tarpath, 'w')

        curr_dir = os.getcwd()
        os.chdir(os.path.dirname(self.WORKDIR))
        tar.add(os.path.basename(self.WORKDIR))
        tar.close()

        os.chdir(curr_dir)

        command = [
            'scp', tarpath, 'root@' + envir.MASTER + ':' + envir.MASTER_WORKDIR
        ]
        print command

        msg = utillib.do_command(command)
        print msg

        self.RM_FILES.append(self.WORKDIR)
        self.RM_FILES.append(tarpath)
コード例 #7
0
 def getbacktraces(self):
     flist = []
     bt_files = utillib.find_files(self, envir.CORES_DIRS)
     for f in bt_files:
         bf = os.path.basename(f)
         bf_num = utillib.do_command(['expr', 'match', bf, 'core'])
         if bf_num > 0:
             flist.append(f)
     if len(flist):
         utillib.getbt(flist, os.path.join(self.WORKDIR, envir.BT_F))
         utillib.debug('found basktraces: ' + ' '.join(flist))
コード例 #8
0
    def pe2dot(self, path):
        pef = os.path.basename(path)
        if pef.endswith('.bz2'):
            dotf = pef[0:len(pef) - 4]

        if not len(envir.PTEST):
            return False
        try:
            msg = utillib.do_command([envir.PTEST, '-D', 'dotf', '-x', pef])
        except:
            utillib.debug(envir.PTEST + ' faild! ')
            return
コード例 #9
0
ファイル: master.py プロジェクト: wenshizhang/hb_report
    def diffcheck(self, file1, file2, outfd):
        '''
		if file1 not as same as file2, return True
		else return False
		'''
        dir1 = os.path.dirname(file1)
        dir2 = os.path.dirname(file2)

        outf = os.path.join(self.WORKDIR, envir.ANALYSIS_F)
        if not os.path.isfile(file1):
            utillib.writefile(outf, file1 + ' does not exist')
            return False

        if not os.path.isfile(file2):
            utillib.writefile(outf, file1 + ' does not exist')
            return False

        base = os.path.basename(file1)

        if base == envir.CIB_F:
            if (os.path.isfile(os.path.join(dir1, 'RUNNING'))
                    and os.path.isfile(os.path.join(dir2, 'RUNNING'))) or (
                        os.path.isfile(os.path.join(dir1, 'STOPPED'))
                        and os.path.isfile(os.path.join(dir2, 'STOPPED'))):
                msg = utillib.do_command(
                    ['crm_diff', '-c', '-n', file1, '-o', file2])
                outfd.write(msg)
            else:
                outfd.write(
                    'cannot compare cibs from running and stop systems')

        #confdiff
        #elif base == envir.B_CONF:

        else:
            msg = utillib.do_command(['diff', '-bBu', file1, file2])
            outfd.write(msg)

        return len(msg)
コード例 #10
0
    def sys_stats(self):

        msg = ''

        f = open(os.path.join(self.WORKDIR, envir.SYSSTATS_F), 'w')

        msg = msg + self.WE + '\n'
        msg = msg + utillib.do_command(['uptime'])
        #		msg = msg + utillib.do_command(['ps','axf'])
        msg = msg + utillib.do_command(['ps', 'auxw'])
        msg = msg + utillib.do_command(['top', '-b', '-n', '1'])
        msg = msg + utillib.do_command(['ip', 'addr'])
        msg = msg + utillib.do_command(['netstat', '-i'])
        msg = msg + utillib.do_command(['arp', '-an'])

        if os.path.isdir('/proc'):
            cpu_f = open('/proc/cpuinfo', 'r')
            cpu_info = cpu_f.readline()
            while len(cpu_info):
                msg = msg + cpu_info
                cpu_info = cpu_f.readline()

        msg = msg + utillib.do_command(['lsscsi'])
        msg = msg + utillib.do_command(['lspci'])
        msg = msg + utillib.do_command(['mount'])

        #df can block, run in background, allow for 5 seconds
        df_pro = subprocess.Popen(['df'],
                                  stderr=subprocess.STDOUT,
                                  stdout=subprocess.PIPE)
        timer = threading.Timer(5.0, df_pro.kill)
        timer.start()
        df_info = df_pro.communicate()[0]
        if timer.is_alive():
            #df exited naturally, cancel timer
            timer.cancel()
        msg = msg + '\n' + df_info

        f.write(msg)
        f.close()
コード例 #11
0
    def time_status(self):
        output = os.path.join(self.WORKDIR, envir.TIME_F)

        time_info = utillib.do_command(['date'])
        time_info = time_info + utillib.do_command(['ntpdc', '-pn'])
        utillib.writefile(output, time_info)
コード例 #12
0
 def touch_DC_if_dc(self):
     dc = utillib.do_command(['crmadmin', '-D'])
     dc = dc.split()[len(dc.split()) - 1]
     if self.WE == dc:
         utillib.writefile(os.path.join(self.WORKDIR, 'DC'), '')