Starting SPD Server Performance Server

Overview of Starting the Performance Server

You can start SPD Server Performance Server in two ways. You can invoke the Performance Server on the command line, or you can launch it by calling the rc.perf script that is configured for your location's SPD Server installation.
By default, the SPD Server Performance Server process displays the captured performance data on the user's screen. To disable the user screen display, redirect stdout and stderr to /dev/null. If you redirect the screen output, it is easier to run spdsperf in the background, or as an orphan.

Start Performance Server from the Command Line

You can start the SPD Server Performance Server from a UNIX command line. SPD Server and the SAS Management Console applications must be running before you start the Performance Server. If you need to restart SPD Server, you must also shut down and restart the SPD Server Performance Server after SPD Server is restarted. The Performance Server utility is not compatible with SPD Server releases earlier than SPD Server 4.4.
Use the following command to start Performance Server:
spdsperf -g SMID -n NSP -s SNP -p PLP -l LOG [-i SEC] [-c CNT]
SMID
SMID is the shared memory ID that is passed to the spdsbase user proxy when it is started by SPD Server. SMID contains information that spdsperf requires. You can find the shared memory ID by issuing a UNIX process status report command for all processes and then grep for ‘spdsbase’, using a form similar to ps —eo args | grep spdsbase. The shared memory ID should be the first parameter (after the process name) that is passed to the process.
NSP
the process-ID number of the SPD Server name server whose family of spawned processes you want to monitor.
SNP
the process-ID number of the SPD Server SNET Server.
PLP
the listening port number that the SAS Management Console uses to contact the Performance Server.
LOG
the path to which you want to write the profile log.
SEC
an optional property that specifies the number of seconds that transpire between instances of performance monitoring data captures. Valid values are integers that are greater than or equal to 1 and less than or equal to the SPD Server MAXINT value.
CNT
an optional property that specifies the number of performance monitoring data captures that you want the Performance Server to take. Valid values are integers that are greater than or equal to 0 and less than or equal to the SPD Server MAXINT value. The value 0 specifies an infinite number of data captures.

Start Performance Server by Using the rc.perf Script

You can also start SPD Server Performance Server by calling the rc.perf script during start-up. See Sample rc.perf Script for a sample rc.perf script that you can cut and paste into an editor of your choice, and customize for your use. SPD Server 5.1 is also shipped with a sample rc.perf script that you can modify. The sample rc.perf script is in your SPD Server installation folders at .../samples/perfmon/rc.perf. You can use either example file to create a custom rc.perf script.
Make the following changes when you customize your version of the rc.perf script:
  1. If your SPD Server installation uses a custom SPD Server installation path, modify the INSTDIR path setting to specify your installation path.
  2. Modify the UNIX environment setting for DISPLAY. This environmental variable tells the X server where to display the window for the Performance Server program.
  3. If your SPD Server installation uses custom NSPORT and SNPORT assignments, modify the NSPORT and SNPORT settings in the sample script to specify the port addresses that your SPD Server installation uses.
  4. The script uses the -PARGS setting to specify how many times the Performance Server should capture performance information snapshots before shutting down. The sample rc.spds script specifies 0, which indicates an infinite number of performance information captures. If you do not change the default number of information captures from 0 (infinity), consider modifying your rc.killspds script to shut down the rc.perf process when you shut down SPD Server.

Sample rc.perf Script

The following sample code is a typical rc.perf script that you can modify for use at your own site. Follow the instructions in Start Performance Server by Using the rc.perf Script to customize the script for your SPD Server installation. Copy and paste the example code into a text editor. Make your changes, and then save the file to your SPD Server installation in a location where the script can be called for execution.
#!/bin/ksh
#--------------------------------------------------------------------------
#
# PURPOSE:    Start the SPD Performance Profiler for the specified servers.
#
# PARAMETERS: version - Version of SPDS to build and run (e.g., dev, 403).
#
# NOTES:      Common optional parameters:
#               -nsport    overrides NSPORT for server.
#               -snport    overrides SNPORT for server.
#               -debug     use alternate port numbers for development.
#
#             The default repetition count for spdsperf is 3. This script
#             over-rides the default to run indefinitely. Supplying a -c
#             option to this script will over-ride this new default.
#
# HISTORY:    12Sep06 mjm Optimized for customer use.
#             02Aug06 mjm Created.
#
#--------------------------------------------------------------------------


#
# enable XPG4 versions of ps command on some platforms
#
export UNIX95=1


#
# initialize variables
#
NSPORT=6100
SNPORT=6101
DEBUG=
PARGS="-c 0"

#
# parse parameters
#
while [ $1 ]; do
    #echo "Parsing Option $1 of length ${#1}"
    case "$1" in
        -nsport) if [ $# -lt 2 ]; then
                     echo "$1 parameter value not specified"
                     exit 1
                     fi
                 NSPORT=$2
                 shift;;
        -snport) if [ $# -lt 2 ]; then
                     echo "$1 parameter value not specified"
                     exit 2
                     fi
                 SNPORT=$2
                 shift;;
        -debug)  DEBUG="YES";;
        -trace)  echo "********\n* Script: $0\n* Args: $*\n********"
                 set -x
                 trace="-trace"
                 echo "Script tracing turned on";;
        *)       echo "Found unknown arg, passing on to profiler."
                                 PARGS="$PARGS $1";;
        esac
    shift
    done

echo "NSPORT=$NSPORT"
echo "SNPORT=$SNPORT"
echo "DEBUG=$DEBUG"
echo "PARGS=$PARGS"


#
# Check for debug option
#
if [ -n "$DEBUG" ]; then
        NSPORT=9876
        SNPORT=9877
        echo "Using Debug Ports: NS=$NSPORT   SN=$SNPORT"
    fi


SSRVPID=$(ps -eo pid,ppid,args | grep spdsserv | grep 6100
  | tr -s "      " " " | sed -e "s/^ *//" | cut -d " " -f1)

SNETPID=$(ps -eo pid,ppid,args | grep spdssnet | grep 6101
  | tr -s "      " " " | sed -e "s/^ *//" | cut -d " " -f1)

SHMATID=$(ps -eo pid,ppid,args | grep spdsbase | grep $SSRVPID
  | tr -s "\t" " " | sed -ne "1s/^ *//p" | cut -d " " -f4)

echo "SPDSNSRV Pid: $SSRVPID"
echo "SPDSSNET Pid: $SNETPID"
echo "SHMATID:      $SHMATID"

INSTDIR=/usr/local/spds
PATH=$INSTDIR/bin
export PATH
LD_LIBRARY_PATH=$INSTDIR/bin
export LD_LIBRARY_PATH
LIBPATH=$INSTDIR/bin
export LIBPATH

# substitute user's display machine name below.
export DISPLAY=machine:0.0

#sleep 4
spdsperf -g $SHMATID -n $SSRVPID -s $SNETPID $PARGS