Developing Performance Monitoring Applications - Taking Actions

Tools
Tools covers the tools and utilities you use to work with Teradata and its supporting ecosystem. You'll find information on everything from the Teradata Eclipse plug-in to load/extract tools.
Teradata Employee

Developing Performance Monitoring Applications - Taking Actions

This is the fourth in a series of articles.

       View the first article.

       View the series index.

This artice describes the functions that are available to programatically control the sessions and workloads on your system

Aborting Sessions

If your analysis of the session information indicates that a session needs to be aborted you may abort it by calling the AbortSession method of the specific Session object.

This method accepts an optional boolean parameter. Specify True if you wish to Abort all sessions for this user. The default value of False will abort only this specific session.

Alternatively, if you do not have a Session object, you may call the AbortSession method of the Monitor class. This method requires 2 input parameters. The first specifies the HostId. The second is defined as a variant and can specify either a SessionNumber or a UserName.

If you specify a UserName then all sessions belonging to this user will be aborted.

In either case, the session(s) will be logged off from the Teradata System.

In VB:    Dim HostId As Integer

              Dim SessionNum As Long

              ' Assign the values here

              gMon.AbortSession HostId, SessionNum

In C#:    short HostId; 

              object SessionOrUser;

              /* Assign the values here */

              gMon.AbortSession(HostId, SessionOrUser);

In C++:  VARIANT SessionOrUser;

              SessionOrUser.vt = VT_I4;

              SessionOrUser.lval = ProblemSessionNum;

              HRESULT hr = pMon->AbortSession(HostId, SessionOrUser);

Modifying the Session Account (Priority)

If you need to change the priority at which a session is executing you may do so by calling the ModifyAccount method of either the Session itself or the Monitor class.

These methods require an input parameter to specify the new Account String.

The Monitor level method also requires parameters to specify the HostId and SessionNumber.

You may optionally provide an additional parameter to specify that the change applies only to the active request. Otherwise the change will apply to the current request and all future requests issued by the session. To apply the change only to the current request pass a value of True.

In VB:     Dim NewAcct As String

              NewAcct = '$H-Faster'

              gMon.ModifyAccount HostId, SessionNum, NewAcct

In C#:    String NewAcct = '$H-Faster';

              gMon.ModifyAccount(HostId, SessionNum, NewAcct);

In C++:  BSTR NewAcct = '$H-Faster';

              HRESULT hr = pMon->ModifyAccount(HostId, SessionNum, NewAcct,

                                                                             VARIANT_FALSE);

Note that these methods will have no effect on the session priority if you are using full Workload Management rather than the more basic Priority Schedular option.

Modifying the Session Workload

If your system is using Teradata Workload Management you may transfer a session to a different workload by calling the ModifyWorkload method of either the Session itself or the Monitor class.

These methods require an input parameter to specify the new WorkloadId.

The Monitor level method also requires parameters to specify the HostId, SessionNumber and RunVproc (PE).

You may optionally provide an additional parameter to specify that the change applies only to the active request. Otherwise the change will apply to the current request and all future requests issued by the session. To apply the change only to the current request pass a value of True.

In VB:    Dim NewWorkId As Long

              NewWorkId = 3

              gMon.ModifyWorkload HostId, SessionNum, RunVproc, NewWorkId

In C#:    int NewWorkId = 3;

              gMon.ModifyWorkload(HostId, SessionNum, RunVproc, NewWorkId);

In C++:  int NewWorkId = 3;

              HRESULT hr = pMon->ModifyWorkload(HostId, SessionNum, RunVproc,

                                                                                NewWorkId, VARIANT_FALSE);

Unless your system always defines the same set of workloads you may need to call the GetWorkloads method to obtain a list of workload names/Ids that are currently enabled on your system.

Releasing a Session from the Delay Queue

If your system is using Teradata Workload Management you may release a session from the Delay Queue by calling the ReleaseSession method of either the Session itself or the Monitor class.

The Monitor level method requires parameters to specify the HostId, SessionNumber, RequestId, and WorkloadId.

In VB:     gMon.ReleaseSession HostId, SessionNum, RequestId, WorkloadId

In C#:    gMon.ReleaseSession(HostId, SessionNum, RequestId, WorkloadId);

In C++:  HRESULT hr = pMon->ReleaseSession(HostId, SessionNum,

                                                                               RequestId, WorkloadId);

Setting the Collection or Logging rates

The Teradata Database accumulates performance data for a user defined 'collection interval'. The data buffers used by the Monitor Object are refreshed at this interval.

The interval can be set using the SetMonitorRate and SetSessionRate methods. The first applies to collection of Node, AMP and PE data, while the second applies to Session data only.

Performance data may also be periodically written to the Resusage tables. This period can be set using the SetLoggingRate method.

These methods all require a parameter to specify the new rate. This value should be a 16 bit integer. 

The SetSessionRate method also accepts an optional boolean parameter. Specify a value of True if you wish the change to apply only within your current Monitor session.

Please refer to the Reference Guide for detailed information on the Object Model.