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 7 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

To add the functionality on which log to check, syslog or local logs we will follow this table -


PBS_SYSLOG  

PBS_LOCALLOG  

Syslog_attribute 

Which log to check in log_match() 

Not_set 

0 

0 

N/A 

Not_set 

0 

1 

Throw error 

Not_set 

1 

0 

Local_Log 

Not_set 

1 

1 

Throw error 

set 

0 

0 

Syslog 

set 

0 

1 

Syslog 

set 

1 

0 

Match in both logs 

set 

1 

1 

Syslog 








 


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

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. 

 

Changes in pbs_logutils.py


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

By default this attribute should be set to false


2) Adding extra attribute 'readSyslog' to log_match(readSyslog=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.




Changes in this file are related to the format of the recorded datetime and getting the path to the syslog file. Syslog records the datetime in a different format than local logs. According to the format we will have to do changes to reading the datetime.

Some syslog files are compressed. Even if we can derectly read a compressed file (eg .bz file) from python, but I would prefer if we decompress it so that rest of the code in PTL for reading files will work without any changes. 



1) Read file from Syslog config file

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

 

2) Date format. 

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

if PBS_SYSLOG=1 (in PBS.conf)

     tm_re = "(?P<datetime>\w{3}\s\d\d\s\d\d:\d\d:\d\d)"

 

def convert_date_time()

    if PBS_SYSLOG=1 (in PBS.conf)

         Fmt of date = "%b %d %H:%M:%S"

     t = time.strptime(datetime, fmt)

 

 

Changes in pbs_testlib.py

1) Change log_file path from local logs to syslog. The local log file are in 4 locations- server, mom, sched, comm. For syslog since there is only one file, we only have to point it to that file. Path to the log file can be set through a environment variable before starting the PTL tests or through the test script. If the path is not set the default path "/var/log/messages" will be taken

sys_log_file_path= sys_log_path

 

def init_logfile_path

   if PBS_SYSLOG=1 and Local_log =0

     path_log_file = _sys_log_path_

   elif locally

     path_log_file= __local_path__

 

 

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

def log_lines

   if PBS_SYSLOG=1 

      path_log_file = _sys_log_path_

  elif locally

     path_log_file= __local_path__



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