Skip to content

Viya 3 on Linux

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 Viya 3 installation.

Viya Microservices

  1. Append the following code block the end of /opt/sas/viya/home/lib/envesntl/sas-init-functions updating the values of ESMHOME variable to the location of your SAS Enterprise Monitor agent, and the viyalogroot (if required):
    # ESM CONFIG BLOCK START
    ESMHOME=/opt/esm/esm-agent
    source $ESMHOME/conf/esmconfig.sh
    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 line (roughtly, this will be on 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
    

Workload Execution Servers

The steps documented below show how to modify each of the different SAS execution server types in a Viya 3 deployment. If you are running a multi-tenant environment, the below steps should be replicated across each tenant in your deployment.

Compute Server

  1. Add the following lines to /opt/sas/viya/config/etc/compsrv/<tenant>/autoexec_usermods.sas modifying the following:
    1. <tenant> in the path above to the appropriate folder
    2. ESMBASEDIR to the location of your esm-agent folder
    3. ESMNODENAME to the name of the server as specified in $ESMBASEDIR/conf/esmconfig.sh
    4. ESMVIYATENANT to the name of the tenant if configuring a multi-tenant environment
    5. ESMLOGPATH to the directory where logs for the compute server are stored. You must keep the trailing slash on this path
      /* START ESM BOOTSTRAP */
      %let ESMBASEDIR="/opt/sas/esm/esm-agent";
      %let ESMNODENAME="&SYSHOSTNAME.";
      %let ESMVIYATENANT=default;
      %let ESMLOGPATH="/opt/sas/viya/config/var/log/compsrv/&ESMVIYATENANT./";
      %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 = ESMNODENAME=&ESMNODENAME.;
          options set = LSB_QUEUE=&ESMVIYATENANT;
          options set = LOGPATH=&ESMLOGPATH.;
          %let esmh=%sysget(ESMHOME);
          %include "&esmh./sasautos/esmtags.sas";
      %end;
      /* END ESM BOOTSTRAP */
      

Job Execution Service Job Name

  1. Complete 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

Download the latest version of the sas-cas-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 CAS Server in your environment which has an Agent deployed to it.

  1. Unzip the downloaded sas-cas-mon.zip file into the modules folder of your Agent installation.
  2. Update the vars.yml file changing the following items1:
    1. logDirectories - The path(s) in which the module should look for CAS logs.
    2. offsetFilesLocation - The full path to the folder that is use to store the offset files for read log files. You should just need to update the path to your ESM agent folder.
  3. Create the sas-cas-mon service:
    1. Update line 6 of the sas-cas-mon.service file updating the values of ESMHOME, ESMEVENTS, ESMNODENAME for your environment including replacing <HOSTNAME> with the name configured during the installation of the agent.
    2. Update line 9 for the path to your modules folder
    3. As root or using sudo, copy the updated sas-cas-mon.service file to /etc/systemd/system
    4. As root or using sudo, run systemctl daemon-reload
  4. Start the Module service by executing (as root): systemctl start sas-cas-mon

The sas-cas-mon uses CAS Action SAS logging to collect data. CAS logging will need to be enabled in order for the module to work correctly.

For complete information about the module, please review the reference guide.

Workspace Server

  1. Add the following lines to /opt/sas/viya/config/etc/workspaceserver/<tenant>/workspaceserver_usermods.sh modifying the following:
    1. <tenant> in the path above to the appropriate folder
    2. ESMBASEDIR to the location of your esm-agent folder
      # 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
      
  2. Add the following snippet to/opt/sas/viya/config/etc/workspaceserver/<tenant>/autoexec_usermods.sas modifying <tenant> in the path to the appropriate folder:
    /* 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. Add the following lines to /opt/sas/viya/config/etc/connectserver/<tenant>/connectserver_usermods.sh modifying the following:
    1. <tenant> in the path above to the appropriate folder
    2. ESMBASEDIR to the location of your esm-agent folder
      # 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
      
  2. Add the following snippet to/opt/sas/viya/config/etc/connectserver/<tenant>/autoexec_usermods.sas modifying <tenant> in the path to the appropriate folder:
    /* 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. Add the following lines to /opt/sas/viya/config/etc/batchserver/<tenant>/batchserver_usermods.sh modifying the following:
    1. <tenant> in the path above to the appropriate folder
    2. ESMBASEDIR to the location of your esm-agent folder
      # 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
      
  2. Add the following snippet to/opt/sas/viya/config/etc/batchserver/<tenant>/autoexec_usermods.sas modifying <tenant> in the path to the appropriate folder:
    /* ESM CONFIG START */
    %if %sysfunc(envlen(ESMHOME)) > 0 %then %do;
      %let ESMHOME=%sysfunc(sysget(ESMHOME));
      %include "&ESMHOME/sasautos/esmtags.sas";
    %end;
    /* ESM CONFIG END */
    

  1. For information about all of the configuration options available for the sas-proc-mon module, please see the module's reference guide


Last update: May 15, 2023
Created: April 24, 2023