Transcript Slide 1

Audit Workspace Server Log Files
Piyush Patel
SAS Consultant
©2008 Revenue Solutions, Inc.
Agenda
 SAS Enterprise Guide and Workspace Server
 Default Workspace server logging is disabled
 How to enable Workspace server logging
 How to Customize Log file names
 How to Parse Log files for reporting
 Pros and Cons Workspace server logging
©2008 Revenue Solutions, Inc.
2
SAS Enterprise Guide and Workspace
Server

SAS EG - The most used and important application in SAS EBI
–
–
–

SAS EG – Centralized location of accessing data from various data sources
–
–
–
–

SAS Programmers
Business Analysts
Report Developer
Needs constant monitoring of all data access
Saved all activities in logs
This project is just a simple example of auditing
Shows example of log files
SAS Workspace Server
–
–
–
–
Execute SAS Code, EG tasks, and queries
Access resources such as tables, views, databases
Move and copy library members and files between SAS workspace Servers
Save SAS EG log files
©2008 Revenue Solutions, Inc.
3
Default Workspace server logging is
disabled
 Locate SAS Workspace server
©2008 Revenue Solutions, Inc.
4
How to enable Workspace server logging
Couple of ways to enable logging
Use SAS Management Console to Enable SAS Workspace server Logging
1. In SAS Management Console, expand the Server Manager node,
the application server node (for example, SASMain), and the logical
workspace server (for example, SASMain - Logical Workspace
Server).
2. Right-click the workspace server object (for example, SAS Main –
Workspace Server), and select Properties.
3. On the Options tab, under Launch Commands, add the appropriate
LOG and LOGPARM options to the end of the Command line. The
following options are recommended:
-log "D:\SAS\WorkspaceServer\logs\c#d#b#y#v.log"
-logparm "rollover=session open=replaceold write=immediate”
4. To capture SAS codes or any activity done in EG
Specify Applevel=2 in Object server parameter command in
Management Console. Applevel=0,1,2,3
Traces application logic. The default level is 1. Higher levels produce
may more verbose log entries.
5. Click OK.
6.Restart the object spawner.
©2008 Revenue Solutions, Inc.
5
How to enable Workspace server logging
Create a Configuration File to Enable SAS Workspace server Logging
1 Use a text editor to create a file similar to the following. As you create the file,
substitute the appropriate path names for your installation.
-config "D:\SAS\EntBIServer\Lev1\SASMain\sasv9.cfg"
-nosplash
-noterminal
-log "D:\SAS\WorkspaceServer\logs\c#d#b#y#v.log"
-logparm "rollover=session open=replaceold write=immediate“
-pagesize max
-linesize max
-rsasuser
2. Name the file sasv9_WorkspaceServer.cfg, and save it in the path <SAS-config-dir>\Lev1\SASMain.
3. In SAS Management Console, expand the Server Manager node, the application server node (for example,
SASMain), and the logical workspace server (for example, SASMain - Logical Workspace Server).
4. Right-click the workspace server object (for example, SAS Main - Workspace
Server) and select Properties.
5. On the Options tab, under Launch Commands, update the Command box so that it
points to the new configuration file, as follows:
sas -config "<SAS-config-dir>\Lev1\SASMain\sasv9_WorkspaceServer.cfg".
6. Click OK.
7. Restart the object spawner.
©2008 Revenue Solutions, Inc.
6
How to Customize Log file names
 Log and Logparm options
–
–
-log "D:\SAS\EntBIServer\Lev1\SASMain\WorkspaceServer\logs\c#d#b#y#v.log“
-logparm “rollover=session open=replaceold write=immediate”
 Examples
–
–
-log "test%H%M.log" -logparm "rollover=auto"
 test0944.log
c#d#b#y#v.log
 c23Feb095892v1.log
©2008 Revenue Solutions, Inc.
7
Log and Logparm options
Directive
Description
Range
%a or #a
Locale's
abbreviated day of
week
Sun-Sat
%b or #b
Local's abbreviated
month
Jan-Dec
%C or #C
Century number
00-99
%d or #d
Day of the month
01-31
%j or #j
Julian day
001-366
%l or #l *
User name
alphanumeric string that is the
name of the user that started SAS
%m or #m
Month number
01-12
%p or #p *
Process ID
alphanumeric string that is the SAS
session process ID
%u or #u
Day of week
1= Monday-7=Sunday
%v or #v *
Unique identifier
alphanumeric string that creates a
log filename that does not currently
exist
%w or #w
Day of week
0=Sunday-6=Saturday
%y or #y
Year without century
00-99
%Y or #Y
Full year
1970-9999
LOGPARM= "<OPEN= APPEND | REPLACE | REPLACEOLD>
<ROLLOVER= AUTO | NONE | SESSION | n | nK | nM | nG>
<WRITE= BUFFERED | IMMEDIATE>"
OPEN=APPEND | REPLACE | REPLACEOLD
when a log file already exists, specifies how the contents of
the existing file are treated.
ROLLOVER=AUTO|NONE|SESSION | n | nG | nM | nG
specifies when or if the SAS log "rolls over," that is, when the
current log is closed and a new one is opened.
WRITE=BUFFERED | IMMEDIATE
specifies when content is written to the SAS log.
©2008 Revenue Solutions, Inc.
8
How to Parse Log files for reporting
 Parse Log files for reporting
– Read log directory
 Use pipe to get all file names under log directory
–
filename in1 pipe 'dir "D:\SAS\EntBIServer\Lev1\SASMain\WorkspaceServer\logs" /b';



–
Use location variable to read log files

–
INFILE in1 TRUNCOVER DSD LRECL=100;
Input @1 file $100.;
Location = 'D:\SAS\EntBIServer\Lev1\SASMain\WorkspaceServer\logs\' || file;
Infile dummy filevar = location end = last truncover LRECL=400 DSD;
Use do loop to read one file at a time


do while(not last);
Input @1 One_rec $400.;
– Capture username
 Use index and substr function to capture user name for this log file
– Capture library or from table name or Where clause
 Use prxparse, prxmatch, prxposn to get Library name and user name
– Create a report
– Show our SAS program
©2008 Revenue Solutions, Inc.
9
Pros and Cons Workspace server logging
 Sample Report
 Pros
–
–
–
–
Monitor table access
Information Security Audit
Recover SAS codes
Troubleshoot and Debug
 Cons
– Disk space
©2008 Revenue Solutions, Inc.
10
References

SAS® 9.1.3 Intelligence Platform System Administration Guide
–
–

Appendix 3, Default Log Locations
Appendix 4, Configuration Files
Links
–
–
–
–
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a002303556.htm
http://support.sas.com/rnd/itech/doc9/dev_guide/stprocess/debug.html
https://support.sas.com/rnd/itech/doc9/admin_oma/sasserver/startserv/sp_objserv.html
http://statcompute.spaces.live.com/

SAS-L

SAS Conference paper
©2008 Revenue Solutions, Inc.
11
 Question?
 Thanks
– [email protected][email protected]
©2008 Revenue Solutions, Inc.
12
SAS Code
filename in1 pipe 'dir "D:\SAS_DATA\LOG_FILES" /b';
options obs=Max compress=yes;
DATA Server_logs ;
format path $100.;
/* Get file name from Workspce Server Directory */
INFILE in1 TRUNCOVER DSD LRECL=100;
Input @1 file $100.;
Path = 'D:\SAS_DATA\LOG_FILES\' || file;
/* use above file name to read the log file one by one */
Infile dummy filevar = path end = done truncover LRECL=400 DSD;
Do while(not done);
Input @1 One_rec $400.;
id1 = 1;
id2 = 1;
Start_Pos = 0;
ttl_len = 0;
Rec_ind = 0;
Number_of_Hits = 0;
Retain UserID;
/* Pick up User ID from the file */
If (index(One_rec, 'SERVERNAME\') > 0) then do;
id1 = index(One_rec, 'SERVERNAME\') ;
id2 = index(One_rec, '. ') ;
Start_Pos = id1 + 11;
ttl_len = id2 - Start_Pos;
UserID = substr(One_rec,start_pos,ttl_len) ;
Rec_Ind = 1;
End;
©2008 Revenue Solutions, Inc.
13