Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

    # PBS supported severity and facilities
    p_severity = ['info', 'debug']
    p_facility = ['*', 'local7', ....]    

    

    

    def log_syslogconfig_linesvalues(selfsyslog=0):

          // This function returns the syslog messages for logmatch        # get syslog utility running and conf filelogic for which file to read will come from the above table

      // returns a integer value which is interpreted as which file to check

        self.cmd_sys = "ps -e | grep syslog | awk '{print $NF}'" file_to_check=0

        self.utility = self.du.run_cmd(hosts=hostname, cmd=self.cmd_sys, as_script=True, sudo=True,                                level=logging.DEBUG2)['out']// read from PBS.conf  PBS_SYSLOG & PBS_LOCALLOG

      // Logic of which file to read log messages from- syslog / local

      // file_to_check =1 for syslog, file_to_check=2 for local, file_to_check=3 for both

      return file_to_check

    

    def log_syslog_lines(self):

        //This function returns the syslog messages for logmatch

        # get syslog utility running and conf file

        self.cmd_sys = "ps -e | grep syslog | awk '{print $NF}'"

        self.syslog_conf_file utility = self.du.run_cmd(hosts=hostname, cmd=self.syslogcmd_conf_path.get(self.utility[0])sys, as_script=True, sudo=True,

          #get syslog log files to be read. Currently only sys         list_of_priority = []         if self.utility[0] == "rsyslogd":      level=logging.DEBUG2)['out']

            list_of_priorities self.syslog_conf_file = self.getsyslog_rsyslogconf_priorites(path.get(self.utility[0])


            self.#get syslog log files to be read.

        list_of_syslog_files = self.get_rsyslog_files()priority = []

        elif if self.utility[0] == "rsyslogd":

            list_of_priorities = self.get_syslogngrsyslog_priorites()

            self.list_of_syslog_files = self.get_syslogngrsyslog_files()

...

list_of_priorities)

        lines = []elif self.utility[0] == "syslog-ng":

        combined_lines = []        for x in self.list_of_syslog_files:    list_of_priorities = self.get_syslogng_priorites()

            l_sys   self.list_of_syslog_files = self.get_syslogsyslogng_lines(hostname=hostname, n=n, filename=x, logval=logvalfiles(list_of_priorities)

        else:    #print("l_sys is:")

            // throw error

            #print(l_sys)    // PtlLogMatchError(rc=1, rv=False, msg=_msg)   


     

...

 # Get lines from each of the files from list_of_syslog_files[]

       

...

lines = []

        combined_lines = [item for sublist in lines for item in sublist]]

          

        # Sort lines by datetime

for x in self.list_of_syslog_files:

            combinedl_sys = self.get_syslog_lines.sort(key=lambda x: datetime.datetime.strptime(x[:15], "%b %d %H:%M:%S"))

        return combined_lines

    

    def get_rsyslog_priorites(self, severity=None, facility=None)

        # Returns the priorities. Since the syslog messages can be stored in multiple files, a list is returned

        # If facility and severity mentioned return the file for that combination from rsyslog.conf

        # If severity and facility is NONE read into rsyslog.conf file and return all files that contain the severity set in syslog-ng.conf

        return list_of_priorities[]

   

    

    def get_syslogng_priorites(self, severity=None, facility=None)

        # Returns the priorities. Since the syslog messages can be stored in multiple files, a list is returned

        # If facility and severity mentioned return the file for that combination from rsyslog.conf

        # If severity and facility is NONE read into rsyslog.conf file and return all files that contain the severity set in syslog-ng.conf

        return list_of_priorities[]

    

    def get_rsyslog_files(self)

        # Returns the files to be read. Since the syslog messages can be stored in multiple files, a list is returned

        # If facility and severity mentioned return the file for that combination from rsyslog.conf

        # If severity and facility is NONE read into rsyslog.conf file and return all files that contain the severity set in syslog-ng.conf

        return list_of_files[]

    def get_syslog_ng_files(self)

         # Returns the files to be read(hostname=hostname, n=n, filename=x, logval=logval)

            lines.append(l_sys)


        # combine lines from each file

        combined_lines = [item for sublist in lines for item in sublist]

        

        # Sort lines by datetime

        combined_lines.sort(key=lambda x: datetime.datetime.strptime(x[:15], "%b %d %H:%M:%S"))

        return combined_lines

    

    def get_rsyslog_priorites(self, severity=None, facility=None)

        # Returns the priorities. Since the syslog messages can be stored in multiple files, a list is returned

           # If facility and severity mentioned return the file for that combination from syslog-ngrsyslog.conf

        # If severity and facility is NONE read into rsyslog.conf file and return all files that contain the severity set in syslog-ng.conf

        return list_of_filespriorities[]

   

    

    def get_syslogsyslogng_linespriorites(self, hostnameseverity=None, n=50, filename=None, logval=None):facility=None)

        # Returns the priorities. Since the syslog messages can be stored in multiple files, a list is returned

        # Return sthe last block of lines from the syslog files for that particular daemonIf facility and severity mentioned return the file for that combination from rsyslog.conf

        # n= number of lines requested by user        #hostname = host from which to read syslog fileIf severity and facility is NONE read into rsyslog.conf file and return all files that contain the severity set in syslog-ng.conf

        # file name is the file to read        return list_of_priorities[]

    

    def get_rsyslog_files(self, list_of_priorities)

        # is user says all lines, default to 100Returns the files to be read. Since the syslog messages can be stored in multiple files, a list is returned

        if n == "ALL":# If facility and severity mentioned return the file for that combination from rsyslog.conf

            n=100

        # if hostname is None, default to machine on which ptl is running

        if hostname is None:

            hostname = socket.gethostname()

        if logval is 'sched_logs':

            daemon_str = 'pbs_sched'

        elif logval is 'server_logs':

            daemon_str = 'Server@'

        elif logval is 'mom_logs':

            daemon_str = 'pbs_mom'

        elif logval is 'comm_logs'# If severity and facility is NONE read into rsyslog.conf file and return all files that contain the severity set in rsyslogd.conf

        return list_of_files[]


    def get_syslog_ng_files(self, list_of_priorities)

         # Returns the files to be read. Since the syslog messages can be stored in multiple files, a list is returned

        # If facility and severity mentioned return the file for that combination from syslog-ng.conf

        # If severity and facility is NONE read into rsyslog.conf file and return all files that contain the severity set in syslog-ng.conf

        return list_of_files[]


    def get_syslog_lines(self, hostname=None, n=50, filename=None, logval=None):

        # Return sthe last block of lines from the syslog files for that particular daemon

        # n= number of lines requested by user

        #hostname = host from which to read syslog file

        # file name is the file to read

        

        # is user says all lines, default to 100

        if n == "ALL":

            daemon_str = 'pbs_comm'n=100

        else: # if hostname is None, default to machine on which ptl is running

            daemon_str = Noneif hostname is None:

   

...

       

...

hostname = socket.gethostname()


        cmd = ['/usr/bin/tail']if logval is 'sched_logs':

            cmd += [str(n), filename]        lines = self.du.run_cmd(hosts=hostname, cmd=cmd, sudo=True,daemon_str = 'pbs_sched'

        elif logval is 'server_logs':

            daemon_str = 'Server@'

        elif logval is 'mom_logs':

            level=logging.DEBUG2)['out']daemon_str = 'pbs_mom'

        if not(daemon_str is None)elif logval is 'comm_logs':

            lines = [l for l in lines if daemon_str in l]= 'pbs_comm'

       

...

else:

        return lines

...

 

...

    def time_syslog(self):  // PtlLogMatchError(rc=1, rv=False, msg=_msg)  

       

       

...

# use tail command to get last block of lines from file

      // returns the time_format as string    cmd = ['/usr/bin/tail']

       return time_format

    def log_config_values(syslog=0)

       // logic for which file to read will come from the above table

      // returns a integer value which is interpreted as which file to check

       file_to_check=0

       // read from PBS.conf  PBS_SYSLOG & PBS_LOCALLOG

      // Logic of which file to read log messages from- syslog / local

      // file_to_check =1 for syslog, file_to_check=2 for local, file_to_check=3 for both

      return file_to_check  cmd += [str(n), filename]

        lines = self.du.run_cmd(hosts=hostname, cmd=cmd, sudo=True,

                                level=logging.DEBUG2)['out']


        lines = [l for l in lines if daemon_str in l]

        return lines




————pbs_testlib.py——————————

...

   def log_match(syslog=False)

       // Additions: Get the value of whether to read syslog or locallog files

      if syslog:      

          x= syslog_config.log_config_values(syslog=true)

...