SAS 9 on Unix
Having successfully installed the SAS Enterprise Monitor Server component and Agent component, SAS configuration changes are now required to enable SAS Enterprise Monitor to monitor the various components of your SAS installation.
Important Note
If your environment uses the -autoexec
system option this will override the behaviour documented below. A small modification can be made to your launching scripts to change -autoexec
to -insert autoexec
and then the below integration method will work.
For more information, please see the official SAS documentation on this option.
Basic Configuration¶
-
Copy and paste the below code block into the
sasenv_local
file of your SAS installation (!SASROOT/bin/sasenv_local
) updating the value of theESMHOME
variable to the location of your SAS Enterprise Monitor agent.# ESM CONFIG START export ESMACTIVE=1 export ESMHOME=/path/to/esm-agent if [ -f $ESMHOME/bin/esm-bootstrap.sh ]; then . $ESMHOME/bin/esm-bootstrap.sh fi # ESM CONFIG END
-
Update line 9 of
/path/to/esm-agent/bin/esm-bootstrap.sh
by adding a semi-colon separated list of any additional SAS application server contexts that exist in your deployment.
Additional Configuration¶
Collect Job Flow and Exit Status Information¶
In order to be able to report on the FLOW and job completion status of programs submitted using the SAS DATA Step Batch Server, some changes must be made to the sasbatch.sh
script. If you use the SAS DATA Step Batch server to submit workload, you should implement this step. You will need perform the below steps for every SAS DATA Step Batch server that is configured in your environment.
- In
sasbatch.sh
replace the line startingexec "$SAS_COMMAND" ....
with the following code block updating line two (2) of the block below whith the path to youresm-agent
folder.
Pre-modified sasbatch.sh files
If you have already made changes to the "$SAS_COMMAND" line in your sasbatch.sh
script, please ensure that you replace the "$SAS_COMMAND"...
line in the code block below with your pre-existing SAS command but without the exec
at the start of the line.
# ESM CONFIG START
export ESMHOME=/path/to/esm/esm-agent
source $ESMHOME/conf/esmconfig.sh
if [[ -z $ESMJOBNAME ]]; then
ESMFULLPATHFILE=`/bin/bash $ESMHOME/getSysIn.sh "$@"`
ESMJOBNAME=`basename $ESMFULLPATHFILE | sed 's/"//g' | sed "s/'//g"`
if [[ -z $ESMJOBNAME ]]; then
ESMJOBNAME=interactive
fi
export ESMJOBNAME
fi
"$SAS_COMMAND" -noxcmd -lrecl 32767 "$@" "${USERMODS_OPTIONS[@]}"
rc=$?
$ESMHOME/reportOut.sh $ESMGUID $ESMJOBNAME $rc "$LSB_JOBNAME"
# ESM CONFIG END
Identify Stored Process Executions¶
In SAS Management Console under: Environment Management -> Server Manager -> SASApp* -> Logical Stored Process Server -> Properties -> Options ->Set Server Properties->Request
Set the Initialization Program value to be /path/to/esm-agent/sasautos/startstp.sas
, updating the path to the correct one for your environment.
Monitor SAS Infrastructure Services¶
In a SAS 9 deployment there are a number of key processes that need to be running in order for users to be able to connect to the environment (Metadata Server, Object Spawner, Web Application Server(s), etc.). In the context of SAS Enterprise Session Monitor we refer to these processes as SAS Infrastructure Services.
To configure an Agent to track the SAS Infrastructure Services, we will configure Active Process Discovery and use a filterSpec configuration that is provided by default.
From within the Agent's bin
folder:
- Modify
config.properties
by uncommenting lines 2 and 5. - Copy
filterSpec-sas9-inf-unix.yaml
to a file calledfilterSpec.yaml
- Restart the Agent
Track Session UTILLOC size¶
Unlike the SAS WORK location which is a directory created at session startup that is unique to each individual SAS session, SAS UTIL directories are created on-the-fly by SAS procedures as they are required. The Agent can be configured to automatically watch one or more directories for these on-the-fly created folders to enable visibility of per-session UTILLOC consumption.
- In your Agent's bin directory, create a new file called
tempDirectories.yaml
- Copy the below contents into the newly created file, updating the path to the SAS WORK directory:
tempDirectories: warningDuration: 2000 scanInterval: 2000 directories: - /tmp settings: - directoryPattern: .*SAS_util\w{4}(?<dirPid>\w{8})_(?<hostname>[^_]+)_ directoryPidIsHex: true directoryType: util
- Restart your Agent
For more information about the tempDirectories.yaml
file and options for configuring pre-process UTILLOC and WORK tracking, see the reference guide.
Capture Procedures and Datasets¶
Proceed with Caution
These steps require changes to be made to SAS server logging. Modifications, if not completed correctly, may cause issues on your system.
It is highly recommended that you familiarise yourself with the documentation for the SAS Logging Facility for your version of SAS, and ensure that you take a backup of any SAS configuration file before making changes.
Download the latest version of the sas-proc-mon module. The credentials for the downloads site can be found in the email with the SAS Enterprise Session Monitor license key.
The following steps should be completed for each Agent within your environment unless your Agent is deployed to a shared filesystem. If your Agent is deployed to a shared filesystem, the steps should be completed just once paying particular attention to step 2c.
-
Unzip the downloaded sas-proc-mon_
<platform>
.zip file into themodules
folder of your Agent installation. -
Update the
vars.yaml
file changing the following items1:- The value of
sasType
tov9
. - Update the value of
sas9ConfigRoot
to the location of yourLevX
folder. - If you are running your ESM agent from a shared directory, set the value of
checkLogHasProcess
totrue
.
- The value of
-
Create the sas-proc-mon service:
- RHEL7+
- Update line 6 of the
sas-proc-mon.service
file updating the values ofESMHOME
,ESMEVENTS
,ESMNODENAME
for your environment including replacing<HOSTNAME>
with the name configured during the installation of the agent. - Update line 9 for the path to your modules folder
- As root or using sudo, copy the updated
sas-proc-mon.service
file to/etc/systemd/system
- As root or using sudo, run
systemctl daemon-reload
- Update line 6 of the
- RHEL6.x
- Update lines 5 and 6 of the
sas-proc-mon.conf
file updating the values ofESMHOME
andESMNODENAME
for your environment replacing the value of<HOSTANME>
with the name configured during the installation of the agent. - As root or using sudo, cope the updated
sas-proc-mon.conf
file to/etc/init
- As root or using sudo, run
initctl --verbose reload-configuration
- Update lines 5 and 6 of the
- RHEL7+
-
Start the Module service by executing (as root):
- RHEL 7+:
systemctl start sas-proc-mon
- RHEL6.x:
start sas-proc-mon
- RHEL 7+:
The module uses SAS logging to collect data. Some modifications need to be made to the default SAS Server logging settings to enable the functionality of the sas-proc-mon module.
Configure Workspace Server Logging¶
By default, SAS workspace server logging is disabled. Follow the instructions in the SAS Help Center to enable SAS Workspace Server logging for each Workspace Server in your environment.
Add the data access logger¶
To collect data access metrics, we must enable dataset access audit logging. Add the following logger just above the root
logger towards the end of the file:
<!-- START ESM Logger -->
<logger name="esm" additivity="false">
<appender-ref ref="TimeBasedRollingFile"/>
<level value="Debug"/>
</logger>
<logger name="Audit.Data.Dataset" additivity="false">
<appender-ref ref="TimeBasedRollingFile"/>
<level value="Trace"/>
</logger>
<!-- END ESM Logger -->
Workspace Server Log Management¶
With a high number of Workspace sessions the number and size of the log repositories can quickly grow. By default, SAS creates Workspace Server logs in a Logs folder within the Workspace Server folder of your SAS configuration. If filling up this storage location with logfiles poses an issue, consider implementing one or more of the following:
- Redirection of log files to another disk. This is most easily accomplished by creating a symbolic link for the Logs directory to an alternate location. Redirecting the files in this way requires fewer SAS configuration file changes.
- Regularly delete old logs. For example, schedule a simple script to perform a housekeeping task on your system which deletes files older than a certain age. The following delete files older than 14 days:
find /opt/sas/config/Lev1/SASApp/WorkspaceServer/Logs -type f -mtime +14 -exec rm -f {} \;
Configure Batch Server Logging¶
By default the SAS Data Step Batch Server uses the -log
logging option. Follow these steps to enable SAS Data Step Batch Server logging using a logconfigloc
option.
In addition to the above instructions, the following changes are needed in the default Batch Server logconfig.xml
:
Modify appender for immediate flush¶
In order to be able to get near real time procedure and dataset access events for a job we want to enable immediate flushing of logging data to the file. Within the BatchFileAppender
starting at roughly line 17, add the following line after the Unique
param:
<param name="ImmediateFlush" value="true"/>
Update the conversion pattern¶
Within the BatchFileAppender
starting at roughly line 17, add within the layout
tags, update the ConversionPattern
value to:
<param name="ConversionPattern" value="%d - %m"/>
Add the data access logger¶
To collect data access metrics, we must enable dataset access audit logging. Add the following logger just above the root
logger towards the end of the file:
<!-- START ESM Logger -->
<logger name="esm" additivity="false">
<appender-ref ref="BatchFileAppender"/>
<level value="Debug"/>
</logger>
<logger name="Audit.Data.Dataset" additivity="false">
<appender-ref ref="BatchFileAppender"/>
<level value="Trace"/>
</logger>
<!-- END ESM Logger -->
Update esm-bootstrap.sh¶
The ESMLOGCONFIG
environment variable tells the Agent that we are using the logconfig.xml
method for creating a log file for jobs. This setting makes the Agent use a different technique to find the log file for the session.
ESMLOGCONFIG=1
Configure Stored Process Server Logging¶
By default the SAS Stored Process Server log only captures high level information about the stored process that is being executed. In order to collect PROC and DATA level metrics, we need a more detailed Stored Process Server log. A detailed SAS Stored Process Server log can be created by default by following this SAS Note.
In addition to the changes contained within the SAS Note, we need to make the following SAS Stored Process Server logconfig.xml
changes:
Add the data access logger¶
To collect data access metrics, we want to enable dataset access audit logging. Add the following logger just above the root
logger towards the end of the file:
<!-- START ESM Logger -->
<logger name="esm" additivity="false">
<appender-ref ref="TimeBasedRollingFile"/>
<level value="Debug"/>
</logger>
<logger name="Audit.Data.Dataset" additivity="false">
<appender-ref ref="TimeBasedRollingFile"/>
<level value="Trace"/>
</logger>
<!-- END ESM Logger -->
Configure Connect Server Logging¶
By default, SAS Connect Sever logging is disabled. Follow the instructions in the SAS Help Center to enable SAS Connect Server logging for each Connect Server in your environment.
Add the data access logger¶
To collect data access metrics, we must enable dataset access audit logging. Add the following logger just above the root
logger towards the end of the file:
<!-- START ESM Logger -->
<logger name="esm" additivity="false">
<appender-ref ref="TimeBasedRollingFile"/>
<level value="Debug"/>
</logger>
<logger name="Audit.Data.Dataset" additivity="false">
<appender-ref ref="TimeBasedRollingFile"/>
<level value="Trace"/>
</logger>
<!-- END ESM Logger -->
Connect Server Log Management¶
With a high number of Connect sessions the number and size of the log repositories can quickly grow. By default, SAS creates Connect Server logs in a Logs folder within the Connect Server folder of your SAS configuration. If filling up this storage location with logfiles poses an issue, consider implementing one or more of the following:
- Redirection of log files to another disk. This is most easily accomplished by creating a symbolic link for the Logs directory to an alternate location. Redirecting the files in this way requires fewer SAS configuration file changes.
- Regularly delete old logs. For example, schedule a simple script to perform a housekeeping task on your system which deletes files older than a certain age. The following delete files older than 14 days:
find /opt/sas/config/Lev1/SASApp/ConnectServer/Logs -type f -mtime +14 -exec rm -f {} \;
Validate Configuration¶
The configuration changes that have been made can be validated by starting a session from each server type and ensuring that the session is discovered, and viewable in the UI.
Note
When SAS Management Console is used to validate a server, the session that it spawns is terminated immediately following validation. It is therefore normal for the session to be greyed out as soon as it appears in the Live View.
Workspace Server Validation¶
To do this via SAS Management Console, navigate to the Server Manager plugin, expand an application server context (e.g. SASApp), and locate the Logical Workspace Server definition. Right click, and select the "Validate" option.
The following two things should happen as a result:
- You should see a "Validation Successful!" message in SAS Management Console
- You should see the session appear in the "List Portlet" of the Live View. It should have the following properties:
- User: Should match the user that you authenticated with
- Name: Should be something similar to Lev1_SASApp depending on your configuration
- Type: Should be WS
Connect Server Validation¶
To do this via SAS Management Console, navigate to the Server Manager plugin, expand an application server context (e.g. SASApp), and locate the Logical Connect Server definition. Expand the Logical definition, showing the actual server definition. Right click, and select the "Validate" option.
The following two things should happen as a result:
- You should see a "Validation Successful!" message in SAS Management Console
- You should see a new session appear in the "List Portlet" of the Live View. It should have the following properties:
- User: Should match the user that you authenticated with
- Name: Should be something similar to Lev1_SASApp depending on your configuration
- Type: Should be CS
SAS OLAP Server Validation¶
To do this via SAS Management Console, navigate to the Server Manager plugin, expand an application server context (e.g. SASApp), and locate the Logical OLAP Server definition. Right click, and select the "Validate" option.
The following two things should happen as a result:
- You should see a "Validation Successful!" message in SAS Management Console
- You should see the session appear in the List Portlet of the Live View. It should have the following properties:
- User: Should match the user that you authenticated with
- Name: Should be something similar to Lev1_SASApp depending on your configuration
- Type: Should be OLAP
SAS Stored Process Server Validation¶
To validate the Stored Process Server, navigate to the Stored Process Web Application. From the home screen select "Sampe: Hello World" and in the new tab that opens, select "Say Hello".
The following two things should happen as a result:
- The stored process completes succssfully, showing "Hello World" in large black text in the browser.
- You should see the session appear in the List Portlet of the Live View. It should have the following properties:
- User: Should be the service account that is configured to run your Stored Process Server
- Name: Should be something similar to Lev1_SASApp p8611 depending on your configuration
- Type: Should be STP
SAS Data Step Batch Server Validation¶
To help validate the extended functionality for monitoring SAS Batch Jobs, SAS Enterprise Monitor ships with a test Job which is to be used when validating the configuration of the SAS Batch Server. To trigger the batch job, navigate to a directory where you have write permissions, and invoke the sasbatch.bat
script, passing it the SAS Enterprise Monitor Validation Job as input:
/sas/Config/Lev1/SASApp/BatchServer/sasbatch.sh -sysin /esm/esm-agent/sasautos/validateBatchUnix.sas
The following things should happen as a result:
-
You should see the session appear in the "List Portlet" of the Live View. It should have the following properties:
-
User: Should match the user that you executed the job with
-
Name: Should be validateBatchUnix.sas
-
Type: Should be Batch
-
When completed, should have the following in the Process Portlet:
-
The job should be roughly bound by a light blue background.
-
The background area should be titled with the name of the job across the top.
-
A white tag titled 'User Tag' should be showing halfway through the job.
-
SAS Pooled Workspace Server Validation¶
To do this via SAS Management Console, navigate to the Server Manager plugin, expand an application server context (e.g. SASApp), and locate the Logical Pooled Workspace Server definition. Right click, and select the "Validate" option.
The following two things should happen as a result:
- You should see a "Validation Successful!" message in SAS Management Console
- A few seconds later you should see the session appear in the "List Portlet" of the Live View
-
For information about all of the configuration options available for the sas-proc-mon module, please see the module's reference guide. ↩
Created: April 24, 2023