Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

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


Objective

PBS currently has a facility for logging via syslog. We are reverse engineering to the EDD. We need to have the use cases, test scenarios and test cases (both manual and PTL) reviewed by the open source community.


Use Cases

1. As an admin, I should be able to set PBS logging via syslog so that all daemons log into the same file.

2.  As an admin, I should be able to control log events level of the PBS logging.

3.  As an admin, I should be able to set the logging via syslog for all nodes in the cluster

4.  As an admin, I should be able to set the logging via syslog for all servers in a failover environment.

5. As a admin I should be able to have logging into both local daemons and Syslog enabled together

6.  As an admin/user, I should be able to run tracejob for a specific job with Syslog.
Note- This functionality is not currently given by PBS. This is added here because it is nice enhancement for future use.

7.  As an admin/user, I should be able to differentiate log messages from each daemon.

8. As an admin/user, I should be able to set logging via syslog for only a particular daemon (Server, Mom, Sched or Comm). 



Design


For adding syslog support in PTL we will have to make changes in two files-  pbs_logutils.py and pbs_testlib.py. We should make sure that the user running the tests will  have permissions to read syslog file and decompress it. For eg - in test bed machine pbsroot shoud be able to read from syslog file. 

A new class is to be added for reading the date and syslog messages file path. 



———————syslog_utils.py——————

To add the functionality on which logs to check in log_match(), syslog or local logs we will follow this table -

PBS_SYSLOG  and PBS_LOCALLOG are values from the pbs.conf file. Syslog_attribute is the attribute to be passed to the log_match() function. Return value is the return value of log_match()


PBS_SYSLOG  

PBS_LOCALLOG  

Syslog_attribute 

Which log to check in log_match() 

Retun Value

Not_set 

0 

0 

Throw error


Not_set 

0 

1 

Throw error 


Not_set 

1 

0 

Local_Log 

local_log(x,y) 

Not_set 

1 

1 

Throw error 


set 

0 

0 

Syslog 

syslog(x,y)

set 

0 

1 

Syslog 

syslog(x,y)

set 

1 

0 

Match in both logs 

local_log(x,y)

set 

1 

1 

Syslog 

syslog(x,y)







 


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





import platform

class syslog_utils(object):

    def _init_(self, sylog):        

         // This dictionary will hold the values for the sysconf files for various linux distributions

        self.syslog_conf_path = {'centos7': '/etc/rsyslog.conf', 'RHEL7': '/etc/rsyslog'}


        // Get OS version of the system 

        os = platform.dist()[0] + platform.dist()[1][0]

        path = self.syslog_conf_path[os]


    def path_to_syslog(self):

        // Read the path of the syslog messages file

        // returns the path file as a string

        return path_to_messages

    

    def time_syslog(self):

       // Getting the date format logged in the syslog file

      // returns the time_format as string

       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


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


Following changes are done to the current log_match() function


1) Adding extra attribute 'syslog' to _log_match(syslog=False)

By default this attribute should be set to false


2) Adding extra attribute 'syslog' to log_match(syslog=False)

By default this attribute should be set to false


log_match() calls the _log_match() method. 

Therefore according to the table above we should have a conditional statements in log_match()

In case both have to be read we should call the _log_match() twice.


class PBSService(PBSObject)

   def _init(self) 

   

   def log_match(syslog=0)

      if syslog=1      

          x= syslog_config.log_config_values(syslog=1)

      if x=1

         return _log_match(syslog=1)

      elif x=2

         return _log_match(syslog=0)

      elif x=3 

         // how to check here?????? Recursion??

         _log_match(syslog=1)

         _log_match(syslog=0)

      else:

         _msg= "Log file to check not set"

         PtlLogMatchError(rc=1, rv=False, msg=_msg)        



  def _log_match(syslog=0)

      if syslog=1

         Self.logutil=PBSLogUtils(syslog=1)

         self.init_logfile_path(syslog=1)

         lines = self.log_lines(syslog=1)



  def init_logfile_path(self, syslog=0)

     if syslog= 1

        self.logfile = syslog_utils.path_to_syslog()

     elif locally

        self.logfile = __local_path__

 

 

Note- 'def log_lines' returns the last n lines of the log file.

def log_lines(self, syslog=0)

  if syslog = 1

      filename = syslog_utils.path_to_syslog()

  elif locally

     filename = __local_path__




——————————In pbs_logutils.py—————————————

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


Change regular expression ‘tm_re ’ to match the date format of the syslog file.



tm_re=_date_format_


Class PBSLogUtils(object)

     syslog=0

     _init_(self, syslog=0):

         if self.syslog_value = 1

             syslog=1

             tm_re = syslog_config.time_syslog()



     def convert_date_time(fmt)

         if syslog = 1

             self.fmt=    //get format from syslog_config.time_syslog()

         t = time.strptime(datetime, fmt)


Test Scenarios

1) Test that when PBS_SYSLOG=1 is enabled in pbs.conf, PBS logs messages via syslog.

2) Test that according to the PBS_SYSLOGSEVR value in pbs.conf the messages of that severity are logged via syslog. This should include tests for each severity level- Emergency, alert , critical, error, warning, notice, informational, debug.

3) Test that in a multi-node cluster setup, logging via syslog can be enabled. 

4) Test that in a failover environment logging via syslog works on all the servers.

5) Test that both local logging and logging via syslog can be enabled simultaneously for both, single node and execution nodes in a cluster.

6) Test that tracejob works when logging via syslog is enabled 

(Note: trace job currently does not work with Syslog. Since this is a use case and would be a nice enhancement to have)

7) Test that server and sched and mom messages can be differentiated explicitly in the syslog log file.

8) Test that logging via sys logging can be set for only a particular daemon.

 


  • No labels