Versions Compared

Key

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

Community discussion is present here: http://community.pbspro.org/t/pp-838-support-for-logging-via-syslog-in-pbs/591

...

  facility = //PBS_SYSLOG from pbs.conf

  severity = //  PBS_SYSLOGSEVR from pbs.conf (by default NONE)

Methods:

    def _get_log_type()

       Summary: logic for which messages to read (local logs / syslog)

       Input

      syslog - by default None

      Description: 

      1) read from PBS.conf  - PBS_SYSLOG & PBS_LOCALLOG.       a) Check if the  PBS_SYSLOG & PBS_LOCALLOG are set in the pbs.conf file

       b) If PBS_SYSLOG is not set, we will locally in code set variable PBS_SYSLOG=0

       c) If  PBS_LOCALLOG is not set, we will locally in code set variable PBS_LOCALLOG=1

   

      2) Logic for whether to read local logs/ syslog we will follow this table -

...

     


local(x,y)syslog(x,y)

PBS_SYSLOG  

PBS_LOCALLOG  

Which log to check in log_match() 

Return Value for the log_match()

0 

Throw error

1

Local_log

_log

set

0

Syslog 

 

set

1 

 Match in both logs 

unsetunsetlocalLocal_log(x,y)



















 


       Note: In row 4 where we have to match in both syslog and local log, we would have to call _log_match() twice. 

       Note: In case of row 4 the return value for log_match() will return lines from local_logs only.

       Note: Currently we are only supporting for the current syslog file and not for previous days file. That would be covered in PP-969 

      Note:  The error thrown will be PtlLogMatchError

     

       Return:      

      self.file_to_check (/ / file_to_check =1 for syslog, file_to_check=2 for local logs  and file_to_check=3 for both)

    

    def _get_syslog_lines(hostname, n, logval):

...

  1.  get type of syslog utility (rsyslog/syslog-ng) running on host and syslog conf file. Currently we are only supporting rsyslog and not syslog-ng
  2. get PBS_SYSLOGSEVR from pbs.conf. If it is not set throw error PBSConfigError that set PBS_SYSLOGSEVR
  3. According to utility get list_of_priorites[] (severity + facility) -  _get_rsyslog_priorites()
  4. With the priorities get list_of_syslog_files[]  (if there is no list of files returned, throw PTL error)  _get_rsyslog_files()
  5. Get lines from each of the files in list_of_syslog_files[] . This will consider the n and logval arguments. Only the specified logval messages will be considered
    If no lines are returned throw PTLerror
  6. Combine and Sort lines by datetime

...

      return: Sorted +  combined_lines (This list of lines will be used by the match_msg() for log_match

    

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

...

        return list_of_priorities[]

    

    def _get_rsyslog_files(self, list_of_priorities[])

...

        1) PBSSyslogUtils._get_log_type() to check if local logs/ syslog is to be checked

          x= PBSSyslogUtils._get_log_type(syslog=syslog)

       2) if x =1 or 3 -  read _log_match(syslog=true)

...

           lines = self.PBSSyslogUtils._get_syslog_lines(hostname=self.hostname, n=n, logval=logval)

...