Skip to content

Configuring for Viya 3.x

Once the SAS Enterprise Session Monitor server and agent components are installed, some additional configuration is required to integrate SAS Enterprise Session Monitor monitoring with the various Viya components.

Viya Microservices

Instances of microservices can be configured to report in to SAS Enterprise Session Monitor automatically by modifying the /opt/sas/viya/home/lib/envesntl/sas-init-functions file to include a new ESM reporting function.

Values need to be updated

The snippet below contains an incomplete path starting with ###. Please update this line for your environment.

  1. Append the following code block the end of /opt/sas/viya/home/lib/envesntl/sas-init-functions. Please update this snippet for your environment by changing the path to the esmconfig.sh file as well as the viyalogroot if required:

    # ESM CONFIG BLOCK START
    esmconfig=/opt/esm/esm-agent/conf/esmconfig.sh
    source $esmconfig
    viyalogroot=/opt/sas/viya/config/var/log
    viyaname=sas-viya
    viyapidfiles=/var/run/sas
    
    # format here is reportPid [pid] [pidfile]
    function reportViyaPid () {
        esmpidno=$1
        esmfileshort=$(basename $2)
        esmservicename=$(echo ${esmfileshort} | cut -d '.' -f 1)
    
    esmfds=$(ls -latr /proc/${esmpidno}/fd | grep ${viyalogroot} | sed 's/.*> //' | sort | uniq)
        for fd in $esmfds; do
        # if there happen to be multiple open get the latest
            lastLogfile=${fd}
    done
        esmpidowner=$(ps -o user= -p $esmpidno)
        eventString=[{\"pid\":$esmpidno\,\"owner\":\"$esmpidowner\"\,\"esmType\":\"viya\"\,\"jobName\":\"$esmservicename\"\,\"logFile\":\"$lastLogfile\"\,\"hostname\":\"$ESMNODENAME\"}]
        echo $eventString > $ESMEVENTS/new'_'$esmpidno'_'$ESMNODENAME
    }
    # ESM CONFIG BLOCK END
    

  2. Add the following code after the result=0 # is running (this will be on roughly line 117):

    # ESM CONFIG BLOCK START
    reportViyaPid ${pid} ${pidfile}
    # ESM CONFIG BLOCK END
    

  3. If your SAS Microservices are running while these changes are made you can run the following commands to add running Microservices to SAS Enterprise Session Monitor. The below script can take a few seconds to run:

    cd /var/run/sas
    source /opt/sas/viya/home/lib/envesntl/sas-init-functions
    for i in *.pid; do p=`cat $i`; reportViyaPid $p $i 2>/dev/null; done
    

SPRE Sessions

In order to associate SAS sessions to their parent server types we need to configure some environment variables for each of the different server types.

Workspace Server

  1. Navigate to the Workspace Server configuration directory:

    cd /opt/sas/viya/config/etc/workspaceserver/default
    

  2. Add the following snippet to workspaceserver_usermods.sh updating the second line for the location of your agent installation:

    # ESM CONFIG START
    export ESMBASEDIR=/opt/esm/esm-agent
    if [[ -f $ESMBASEDIR/conf/esmconfig.sh ]]; then
      . $ESMBASEDIR/conf/esmconfig.sh
      # set the active flag as 1 for active, 0 for inactive
      export ESMACTIVE=1
      # This is the name given to non-job sessions (for example)
      export ESMSESSIONNAME=SAS-Studio
      export ESMSESSIONTYPE=WS
    fi
    # ESM CONFIG END
    

  3. Add the following snippet toautoexec_usermods.sas:

    /* ESM CONFIG START */
    %if %sysfunc(envlen(ESMHOME)) > 0 %then %do;
      %let ESMHOME=%sysfunc(sysget(ESMHOME));
      %include "&ESMHOME/sasautos/esmtags.sas";
    %end;
    /* ESM CONFIG END */
    

Connect Server

  1. Navigate to the Connect Server configuration directory:

    cd /opt/sas/viya/config/etc/connectserver/default
    

  2. Add the following snippet to connectserver_usermods.sh updating the second line for the location of your agent installation:

    # ESM CONFIG START
    export ESMBASEDIR=/opt/esm/esm-agent
    if [[ -f $ESMBASEDIR/conf/esmconfig.sh ]]; then
      . $ESMBASEDIR/conf/esmconfig.sh
      # set the active flag as 1 for active, 0 for inactive
      export ESMACTIVE=1
      # This is the name given to non-job sessions (for example)
      export ESMSESSIONNAME=SAS-Connect
      export ESMSESSIONTYPE=CS
    fi
    # ESM CONFIG END
    

  3. Add the following snippet toautoexec_usermods.sas:

    /* ESM CONFIG START */
    %if %sysfunc(envlen(ESMHOME)) > 0 %then %do;
      %let ESMHOME=%sysfunc(sysget(ESMHOME));
      %include "&ESMHOME/sasautos/esmtags.sas";
    %end;
    /* ESM CONFIG END */
    

Batch Server

  1. Navigate to the Batch Server configuration directory:

    cd /opt/sas/viya/config/etc/batchserver/default
    

  2. Add the following snippet to batchserver_usermods.sh updating the second line for the location of your agent installation:

    # ESM CONFIG START
    export ESMBASEDIR=/opt/esm/esm-agent
    if [[ -f $ESMBASEDIR/conf/esmconfig.sh ]]; then
      . $ESMBASEDIR/conf/esmconfig.sh
      # set the active flag as 1 for active, 0 for inactive
      export ESMACTIVE=1
      # This is the name given to non-job sessions (for example)
      export ESMSESSIONNAME=Interactive
      export ESMSESSIONTYPE=Batch
    fi
    # ESM CONFIG END
    

  3. Add the following snippet toautoexec_usermods.sas:

    /* ESM CONFIG START */
    %if %sysfunc(envlen(ESMHOME)) > 0 %then %do;
      %let ESMHOME=%sysfunc(sysget(ESMHOME));
      %include "&ESMHOME/sasautos/esmtags.sas";
    %end;
    /* ESM CONFIG END */
    

Compute Server Sessions

The compsrv configuration does not have a shell script in the configuration directory from which it is executed. As such, we need to configure the required environment variables differently. To do this we will use the server's autoexec_usermods.sas file.

  1. Add the following lines to /opt/sas/viya/config/etc/compsrv/default/autoexec_usermods.sas modifying the ESMBASEDIR for your environment:
    /* START ESM BOOTSTRAP */
    %let ESMBASEDIR="/opt/esm/esm-agent";
    %if %sysfunc(fileexist(&ESMBASEDIR./sasautos/esmtags.sas)) %then %do;
        options set = ESMHOME &ESMBASEDIR.;
        options set = ESMACTIVE = 1;
        options set = ESMSESSIONTYPE="CMP";
        options set = ESMSESSIONNAME="compsrv_default";
        options set = LOGPATH="/opt/sas/viya/config/var/log/compsrv/default/";
        %let esmh=%sysget(ESMHOME);
        %include "&esmh./sasautos/esmtags.sas";
    %end;
    /* END ESM BOOTSTRAP */
    

JES Job Name

Minimum version requirement

The minimum version of esmtags.sas required for this is 1.27 and startjes.sas and endjes.sas v1.0. Please contact SAS support for these files if you do not have them in your environment.

If you are using the SAS Job Execution Service to execute jobs then it can be very useful to be able to search for and track the performance of those jobs. With a small inclusion in the JESBEGIN and JESEND macros from SAS, SAS Enterprise Session Monitor can track and measure JES jobs specifically while enabling extended searching and filtering in the SAS Enterprise Session Monitor user interface.

  1. Ensure that you have completed the Compute Server configuration above.
  2. After making a backup, modify jesbegin.sas in /opt/sas/spre/home/SASFoundation/sasautos putting the following lines just before the closing %mendtag:

    /* ESM CONFIG START */
    %include "%sysget(ESMHOME)/sasautos/startjes.sas";
    /* ESM CONFIG END */
    

  3. After making a backup, modify jesend.sas in /opt/sas/spre/home/SASFoundation/sasautos putting the following lines just before the options nonotes; (circa line 51)

    /* ESM CONFIG START */
    %include "%sysget(ESMHOME)/sasautos/endjes.sas";
    /* ESM CONFIG END */
    

CAS Server

Enhanced observability for the SAS CAS Server is done through the use of an additional SAS Enterprise Session Monitor module: sas-cas-mon.

For detailed instructions on how to install and configure sas-cas-mon for SAS CAS Server monitoring please see here1.


  1. This site is password protected. You will find the username and password for this site in the SAS Enterprise Session Monitor download information email. If you need further assistance, please reach out to either you SAS account representative or SAS Technical Support.