The information in this document is subject to change without notice.
Hewlett-Packard makes no warranty of any kind with regard to this
manual, including, but not limited to, the implied warranties of
merchantability and fitness for a particular purpose. Hewlett-Packard
shall not be held liable for errors contained herein or direct, indirect,
special, incidental or consequential damages in connection with the
furnishing, performance, or use of this material.
Warranty. A copy of the specific warranty terms applicable to your
Hewlett- Packard product and replacement parts can be obtained from
your local Sales and Service Office.
Restricted Rights Legend. Use, duplication or disclosure by the U.S.
Government is subject to restrictions as set forth in subparagraph (c) (1)
(ii) of the Rights in Technical Data and Computer Software clause at
DFARS 252.227-7013 for DOD agencies, and subparagraphs (c) (1) and
(c) (2) of the Commercial Computer Software Restricted Rights clause at
FAR 52.227-19 for other agencies.
HEWLETT-PACKARD COMPANY 3000 Hanover Street Palo Alto,
California 94304 U.S.A.
Use of this manual and flexible disk(s) or tape cartridge(s) supplied for
this pack is restricted to this product only. Additional copies of the
programs may be made for security and back-up purposes only. Resale of
the programs in their present form or with alterations, is expressly
prohibited.
The manual printing date and part number indicate its current edition.
The printing date will change when a new edition is printed. Minor
changes may be made at reprint without changing the printing date. The
manual part number will change when extensive changes are made.
Manual updates may be issued between editions to correct errors or
document product changes. To ensure that you receive the updated or
new editions, you should subscribe to the appropriate product support
service. See your HP sales representative for details.
First Edition: December 1999 (HP-UX Release 11.0)
7
8
1About the WebQoS API
9
About the WebQoS API
Overview
Overview
Using the WebQoS API, an application can reassign the classification
rule class of a session and the process group of a process. This allows
more fine-tuning of the assigned class(es). WebQoS must be configured to
allow these changes to be made. Refer to the Installing and ConfiguringWebQoS on HP-UX manual for more information about configuring
WebQoS.
The following figures show how the WebQoS API can be used to change
the class of a classification rule and process group. The first two figures
represent a single session.
Figure 1-1Example — Initial Service Request
WebQoS
Initial
Service
Request
medium class
classification rule
Web
Server
In Figure 1-1, “Example — Initial Service Request,” the initial service
request is made by a client (for example, a browser). WebQoS sets the
request classification rule class to medium and passes the request to the
web server. The web server passes the request to the application which
then sets the request classification rule class to high for this request.
Figure 1-2Example — Subsequent Service Requests
WebQoS
high class
Subsequent
Service
Requests
classification rule
Web
Server
In Figure 1-2, “Example — Subsequent Service Requests,” subsequent
requests during this WebQoS session use the high request classification
rule class set by the application. The application can change the request
classification rule class value one or more times during the session. This
medium class
classification rule
high class
classification rule
high class
classification rule
Plug-In
Plug-In
10Chapter1
value is effective for subsequent requests for the current session.
Figure 1-3Example — Setting the Process Group
Process Groups
About the WebQoS API
Overview
Process Groups
Process A
Process B
WebQoS
In Figure 1-3, “Example — Setting the Process Group,”two processes are
assigned different process groups by WebQoS: Process A is assigned
medium and Process B is assigned low. Process A requests that it be
moved to the high process group. The WebQoS administrator must have
configured the svccls.allow configuration file to allow a process to
change its process group.
High
Medium
Low
WebQoS API
High
Medium
Low
Chapter 111
About the WebQoS API
Overview
12Chapter1
2Using the WebQoS API
The WebQoS API is installed with the WebQoS software. For more
information about installing the WebQoS API, refer to the Installing andConfiguring HP WebQoS manual.
13
Using the WebQoS API
There is one header file that must be included in your program (contents
of this header file can be found in Appendix A , “Sample Programs,
Configuration, and Header Files,” on page 33):
• /usr/include/webqosapi.h
There are four function calls available:
• wq_get_session_cls() — gets the current classification rule class
of the current request being processed by the NSAPI plug-in
application
• wq_set_session_cls() — sets the classification rule class of the
current request being processed by the NSAPI plug-in application
• wq_get_proc_cls() — gets the process group defined for the
current process or thread
• wq_set_proc_cls() — sets the process group of the current process
When compiling your applications, you must link to one or two libraries:
• libqosapi_rq.sl — If you use wq_get_session_cls() or
wq_set_session_cls(), use -lqosapi_rq to link to this library.
• libqosapi_pr.sl and libprmext.sl — If you use
wq_get_proc_cls() or wq_set_proc_cls(), use -lqosapi_pr
-L/opt/prm/lib -lprmext to link to these libraries.
14Chapter2
Using the WebQoS API
wq_get_session_cls()
wq_get_session_cls()
Gets the current request classification rule class of the current request
being processed by the NSAPI plug-in application.
To use this function, WebQoS must be enabled and either
• SSL is not used and cookies are enabled, OR
• client connections must be persistent.
If SSL is used and/or cookies are disabled and client connections are not
persistent, the value returned corresponds to the policy configured in
WebQoS for this request.
The request classification rule class value returned may have been set by
a plug-in application (using wq_set_session_cls()) or may have been
configured using the WebQoS management user interface.
This function is thread safe.
Synopsis
#include <webqosapi.h>
int wq_get_session_cls(int socketid, int *errorcode)
Link using -lqosapi_rq
Arguments
socketidThe socket file descriptor corresponding to the remote
client connecting to the web server.
errorcodeThe error code returned when the return value is -1.
Refer to “Errors” in this section for a list of error codes.
Chapter 215
Using the WebQoS API
wq_get_session_cls()
Return Value
wq_get_session_cls() returns a non-negative value representing the
request classification rule class or -1 if an error occurred.
When an error occurs, errorcode is set to one of the following:
Table 2-2wq_get_session_cls() Error Codes
Error CodeDescription
WQERR_INVALD_SOCKIDA bad socketid value was passed to
wq_get_session_cls().
WQERR_USRCLAS_OTHERAn internal request classification rule class
error occurred.
WQERR_WQOS_DISABLEDWebQoS is disabled and cannot provide the
request classification rule information.
Example
See Appendix A , “Sample Programs, Configuration, and Header Files,”
on page 33 for an example.
16Chapter2
Using the WebQoS API
wq_set_session_cls()
wq_set_session_cls()
Sets the request classification rule class of the current request being
processed by the NSAPI plug-in application.
To successfully use this function, The WebQoS Administrator must
configure WebQoS to allow the application to modify the request
classification rule class (refer to the Installing and Configuring HPWebQoS manual for more information), WebQoS must be enabled, and
either
• SSL is not used and cookies are enabled, OR
• client connections must be persistent.
If SSL is used and/or cookies are disabled and client connections are not
persistent, the request classification rule class set using this function is
effective for the current request only (it will not be effective for
subsequent requests).
This function is thread safe.
Synopsis
#include <webqosapi.h>
int wq_set_service_cls(int socketid, uint32_t cls, int *errorcode)
Link using -lqosapi_rq
Arguments
socketidThe socket file descriptor corresponding to the remote
client connecting to the web server.
clsThe request classification rule class to which the
application sets the request. This request classification
rule class is set for the next and subsequent client
requests. Refer to “cls Values” for a list of request
classification rule class values.
errorcodeThe error code returned when the return value is -1.
Refer to “Errors” in this section for a list of error codes.
Chapter 217
Using the WebQoS API
wq_set_session_cls()
cls Values
Use the following values to set the request classification rule class cls:
wq_set_session_cls() returns 0 if it is successful or -1 if an error
occurred.
Errors
When an error occurs, errorcode is set to one of the following:
Table 2-4wq_set_session_cls() Error Codes
Error CodeDescription
WQERR_INVAL_USER_CLSThe value provided for cls is not a defined request
classification rule class.
WQERR_INVALD_SOCKIDA bad socketid value was passed to
wq_set_session_cls().
WQERR_PLCY_DISALLOWThe WebQoS administrator has not configured a
policy allowing applications to modify its request
classification rule class.
WQERR_USRCLAS_OTHERAn internal request classification rule class error
occurred.
WQERR_WQOS_DISABLEDWebQoS is disabled and cannot set the request
classification rule class.
18Chapter2
Using the WebQoS API
wq_set_session_cls()
Example
See Appendix A , “Sample Programs, Configuration, and Header Files.”
Chapter 219
Using the WebQoS API
wq_get_proc_cls()
wq_get_proc_cls()
Gets the process group defined for the current process or thread.
This function is intended for processes that are separate from http
daemons, such as cgi-bin. Plug-In applications that are expected to run
as http daemon threads (such as NSAPI plug-ins) should not link to
libqosapi_pr.sl.
Synopsis
#include <webqosapi.h>
int wq_get_proc_cls(int *errorcode)
Link using -lqosapi_pr -L/opt/prm/lib -lprmext
Arguments
errorcodeThe error code set when the return value is -1. Refer to
“Errors” in this section for a list of error codes.
Return Value
wq_get_proc_cls() returns a non-negative value representing the
process group or -1 if an error occurred.
Table 2-5wq_get_proc_cls() Return Values
wq_get_proc_cls()
Return Value
-1Error
WQ_SVCCLS_LOWLow
WQ_SVCCLS_MEDMedium
WQ_SVCCLS_HIGHHigh
WQ_SVCCLS_OTHEROther
WQ_SVCCLS_ROOTPRM_SYS class; accessible by root only
20Chapter2
Condition or Process Group
Errors
If error logging to syslog is enabled, certain errors are logged to a file (you
can specify the file in /etc/syslog.conf). Refer to the syslog(3C) and
syslogd(1M) man pages for information about enabling logging.
When an error occurs, errorcode is set to one of the following:
Table 2-6wq_get_proc_cls() Error Codes
Error CodeDescription
WQERR_NOTREADYPRM is not installed or not configured on the system.
WQERR_OTHERIf error logging to syslog is enabled (“error” levelfor
all facilities), the error is logged to a file.
Multithreaded Applications
For HP-UX 10.20 (supports user-level threads only), all user-level
threads within one process are in the same process group.
wq_get_proc_cls() returns the same value when called from any of
the threads of a process.
Using the WebQoS API
wq_get_proc_cls()
For HP-UX 11.0 (supports 1x1 kernel threads), a thread in user space
corresponds to a kernel thread (also known as a Light Weight Process,
LWP). LWPs may belong to different process groups.
wq_get_proc_cls() may return different values within the same
process. Currently, WebQoS cannot move a thread from one process
group to another. Therefore, all threads in a process are in the same
process group.
This function is thread safe.
Example
See Appendix A , “Sample Programs, Configuration, and Header Files,”
on page 33 for an example.
Chapter 221
Using the WebQoS API
wq_set_proc_cls()
wq_set_proc_cls()
Sets the process group of the current process. For a multithreaded
process, all threads are set to the same specified process group.
A process is only allowed to change its process group to the value(s)
specified in the file /etc/opt/webqos/svccls.allow. By default, a
process cannot change its process group. Refer to the svccls.allow file
for an explanation of how to configure this file. A copy of this file can be
found in Appendix A , “Sample Programs, Configuration, and Header
Files,” on page 33.
Synopsis
#include <webqosapi.h>
int wq_set_proc_cls(uint32_t class, uint32_t scope, int *errorcode)
Link using -lqosapi_pr -L/opt/prm/lib -lprmext
Arguments
classThe process group to which the application sets the
process to be in. Refer to “class Values” for a list of
process group values.
scopeSpecifies scope of the function, which can be the entire
process or a thread. Currently, only the entire process
can be set (using WQ_SCOPE_PROCESS). For more
information about multithreaded applications, refer to
“Multithreaded Applications” in this section.
errorcodeThe error code set when the return value is -1. Refer to
“Errors” in this section for a list of error codes.
22Chapter2
class Values
wq_set_proc_cls() can pass the following values:
Table 2-7wq_set_proc_cls() class Values
Process Groupclass Value
LowWQ_SVCCLS_LOW
MediumWQ_SVCCLS_MED
HighWQ_SVCCLS_HIGH
OtherWQ_SVCCLS_OTHER
PRM_SYS class; accessible by root onlyWQ_SVCCLS_ROOT
Return Value
wq_set_proc_cls() returns 0 if it is successful or -1 if an error
occurred.
Using the WebQoS API
wq_set_proc_cls()
Errors
If error logging to syslog is enabled, certain errors are logged to a file (you
can specify the file in /etc/syslog.conf). Refer to the syslog(3C) and
syslogd(1M) man pages for information about enabling logging.
When an error occurs, errorcode is set to one of the following:
Table 2-8wq_set_proc_cls() Error Codes
Error CodeDescription
WQERR_BADSCOPEThe value provided for scope is not defined.
Currently, WQ_SCOPE_PROCESS is the only
defined value.
WQERR_BADSVCCLASSThe value provided for class is not a defined
process group.
WQERR_CONNECTProblems connecting to the SCA process. If error
logging to syslog is enabled, the errors are logged
to a file.
Chapter 223
Using the WebQoS API
wq_set_proc_cls()
Table 2-8wq_set_proc_cls() Error Codes
Error CodeDescription
WQERR_NOTROOTThe process attempted to set the process group to
a value that can only be accessed by root.
WQERR_NOTREADYPRM is not installed or not configured on the
system.
WQERR_OTHERIf error logging to syslog is enabled (“error” level
for all facilities), the error is logged to a file.
WQERR_PERMISSIONThe process does not have permission to change
to the specified process group. Make sure that the
/etc/opt/webqos/svccls.allow file is
configured and is not corrupt.
Multithreaded Applications
For HP-UX 10.20 (supports user-level threads only), all user-level
threads within one process are in the same process group.
wq_set_proc_cls() ignores scope and moves the entire process to the
specified process group.
For HP-UX 11.0 (supports 1x1 kernel threads), a thread in user space
corresponds to a kernel thread (also known as a Light Weight Process,
LWP). LWPs may belong to different process groups. Currently, WebQoS
cannot move a thread from one process group to another. Therefore, all
threads in a process are in the same process group. Set scope to
WQ_SCOPE_PROCESS to move all threads in a process to the specified
process group.
This function is NOT thread safe. Although it can be called from a
multithreaded process, the application must ensure that the function is
not called by more than one thread at a time.
Example
See Appendix A , “Sample Programs, Configuration, and Header Files,”
on page 33 for an example.
24Chapter2
3Troubleshooting
25
Troubleshooting
Checklist
Checklist
Run through the following steps to isolate your problem.
Step 1. Check the errorcode returned by the function. A description of the
errorcode and actions to take are listed in this chapter.
Step 2. Verify the parameters, values, and declarations by running the sample
programs provided in Appendix A , “Sample Programs, Configuration,
and Header Files,” on page 33.
Step 3. For request classification rule class errors, check the
/var/opt/webqos/logs/qoslog and the
/var/opt/webqos/logs/acclog file.
For process group errors, check the /var/adm/syslog/syslog.log file.
Step 4. Verify that WebQoS is enabled. From the WebQoS management user
interface:
1. Select the system on which WebQoS should be running.
2. Choose File from the menu bar.
3. Confirm that Enable WebQoS on a System is selected.
Step 5. Verify that the WebQoS administrator has allowed the application to set
the request classification rule class.
Toverify that the application can set the request classification rule class,
from the WebQoS management user interface:
1. Select the site whose configuration you want to verify.
2. Select Edit.
3. Select the Classification Rules tab.
4. Check that the policy includes Application sets the request
priority. This must be included.
Step 6. Verify that the WebQoS administrator has allowed the application to set
the process group.
To verify that the application can set the process group, check that the
/etc/opt/webqos/svccls.allow file has been changed to allow the
user to modify the process group.
26Chapter3
Request Classification Rule Class Error Codes
Request Classification Rule Class Error Codes
wq_get_session_cls()
Error CodeWQERR_INVALD_SOCKID
DescriptionA bad socketid value was passed.
ActionCheck that the socketid you received from the function is valid.
Error CodeWQERR_USRCLAS_OTHER
DescriptionAn internal request classification rule class error occurred.
ActionContact your HP Support Representative.
Error CodeWQERR_WQOS_DISABLED
Troubleshooting
DescriptionWebQoS is disabled and cannot get or set the request classification rule class information.
ActionEnable WebQoS. WebQoS must be enabled before the functions will run. Refer to the
Installing and Configuring WebQoS manual for more information about enabling
WebQoS.
wq_set_session_cls()
Error CodeWQERR_INVAL_USER_CLS
DescriptionThe value provided for cls is not a defined request classification rule class.
ActionUse one of the pre-defined request classification rules defined in
/usr/include/webqosapi.h. Currently, WebQoS does not support the customization
of request classification rule class definitions.
Error CodeWQERR_INVALD_SOCKID
DescriptionA bad socketid value was passed.
ActionCheck that the socketid you are passing is valid.
Chapter 327
Troubleshooting
Request Classification Rule Class Error Codes
Error CodeWQERR_PLCY_DISALLOW
DescriptionThe WebQoS administrator has not configured a policy allowing applications to modify
its request classification rule class.
ActionContact the WebQoS administrator to configure a policy to allow applications to modify
the request classification rule class. Refer to the Configuring HP WebQoS manual for
more information about configuring the policy.
Error CodeWQERR_USRCLAS_OTHER
DescriptionAn internal request classification rule class error occurred.
ActionContact your HP Support Representative.
Error CodeWQERR_WQOS_DISABLED
DescriptionWebQoS is disabled and cannot get or set the request classification rule class information.
ActionEnable WebQoS. WebQoS must be enabled before the functions will run. Refer to the
Installing and Configuring WebQoS manual for more information about enabling
WebQoS.
28Chapter3
Troubleshooting
Process Group Error Codes
Process Group Error Codes
wq_get_proc_cls()
Error CodeWQERR_NOTREADY
DescriptionPRM is not installed or not configured on the system.
ActionInstall and configure PRM on the system.
Error CodeWQERR_OTHER
DescriptionIf error logging to syslog is enabled (“error” level for all facilities), the error is logged to
the /var/adm/syslog/syslog.log log file.
ActionCheck the /var/adm/syslog/syslog.log log file for more information. If error
logging is not enabled, enable it and try running your application again to generate error
messages.
wq_set_proc_cls()
Error CodeWQERR_BADSCOPE
DescriptionThe value provided for scope is not defined. WQ_SCOPE_PROCESS is the only defined
value that can be used.
Actionscope can only be set to WQ_SCOPE_PROCESS.
Error CodeWQERR_BADSVCCLASS
DescriptionThe value provided for class is not a defined process group.
ActionUse one of the pre-defined process group values defined in
/usr/include/webqosapi.h. Currently, WebQoS does not support the customization
of process group definitions.
Chapter 329
Troubleshooting
Process Group Error Codes
Error CodeWQERR_CONNECT
DescriptionProblems connecting to the SCA process. If error logging to syslog is enabled, the errors
are logged to the /var/adm/syslog/syslog.log log file.
ActionCheck the /var/adm/syslog/syslog.log log file for more information. If error
logging is not enabled, enable it and try running your application again to generate error
messages.
Possible errors in syslog.log include:
•cannot find entry “hp-sca” in /etc/services.
Action: Add the entry hp-sca 19411/tcp to the /etc/services file.
•connect to SCA fails. The sca process is not running or is not responding.
Action: Run the following commands:
•Other
Action: Contact your HP Support Representative.
Error CodeWQERR_NOTROOT
DescriptionThe process attempted to set the process group to a value that can only be accessed by
root.
ActionSet the process group to another value; or make sure the process setting the process group
is a root process.
Error CodeWQERR_NOTREADY
DescriptionPRM is not installed or not configured on the system.
ActionRun the following command:
prmconfig -ie -f /etc/opt/webqos/QP_prmconf
30Chapter3
Troubleshooting
Process Group Error Codes
Error CodeWQERR_OTHER
DescriptionIf error logging to syslog is enabled (“error” level for all facilities), the error is logged to
the /var/adm/syslog/syslog.log log file.
Action1. Check the /var/adm/syslog/syslog.log log file for more information. If
error logging is not enabled, enable it and try running your application again to
generate error messages.
2. Check that /etc/opt/webqos/svccls.allow exists and is readable by the
process that is failing.
3. Make sure /etc/opt/webqos/svccls.allow does not contain a line longer
than 1024 bytes and is not corrupted.
4. Contact your HP Support Representative for any other problems.
Error CodeWQERR_PERMISSION
DescriptionThe process does not have permission to change to the specified process group.
ActionMake sure that the /etc/opt/webqos/svccls.allow file is configured and is not
corrupt. Also, verify the effective user ID of the process.
Chapter 331
Troubleshooting
Process Group Error Codes
32Chapter3
ASample Programs,
Configuration, and Header Files
The provided sample programs can be used to verify
33
Sample Programs, Configuration, and Header Files
Sample Session Class Program
Sample Session Class Program
#include <webqosapi.h>
NSAPI_PUBLIC int WQClassExample(pblock *pb, Session *sn, Request *rq)
{
int retval = 0;
int socketid;
int errorcode = 0;
uint32_t userClass;
/* test if class has indeed been set as requested */
newcls = wq_get_proc_cls(&err);
TR printf(“class is now %d\n”, newcls);
if (cls != newcls) {
printf(“FAILURE: wq_set_proc_cls succeeded, but class is not changed!\n”);
TR system(“ps -efP|grep test_sc|grep -v grep”);
}
exit(newcls);
}
36AppendixA
Sample Programs, Configuration, and Header Files
svccls.allow Configuration File
svccls.allow Configuration File
The following is the contents of the /etc/opt/webqos/svccls.allow
configuration file.
#
# Service classes that a process is allowed to move to
#
# Line syntax:
#user_name:class [class [... [class]]]
#
# Valid class values are:
#OTHER, low, medium, high
#
# Class values are case-sensitive with one exception: “other” can
# be used in place of OTHER.
#
# Wild cards:
# user_name can be replaced by *, thus allowing any user to move
# to the listed service classes
#
# class can be replaced by *, thus allowing a given process
# to be moved to any class defined by WebQoS
#
# Comments must start with a # in the first column.
#
# By default, no processes are allowed to be moved. For
# security reasons, the WebQoS administrator has to list the
# allowed users in this file, explicitly.
#
# Examples:
#
# www:high medium low
# www2:medium low
# *:OTHER
Appendix A37
Sample Programs, Configuration, and Header Files
webqosapi.h Header File
webqosapi.h Header File
The following is the contents of the /usr/include/webqosapi.h header
file.
/* Service (AKA Processing) class errors codes */
#define WQERR_OTHER(-1)/* generic error - see log file */
#define WQERR_NOTREADY(-2)/* not installed, not config’d, etc */
#define WQERR_CONNECT(-3)/* connection problem - see log file */
#define WQERR_PERMISSION(-4)/* permission denied in svccls.allow */
#define WQERR_BADSVCCLASS(-5)/* invalid service class argument */
#define WQERR_BADSCOPE(-6)/* invalid scope argument */
#define WQERR_NOTROOT(-7)/* only root can move to this class */
/* User (AKA Session) class error codes */
#define WQERR_WQOS_DISABLED (-20) /* WebQoS is disabled */
38AppendixA
Sample Programs, Configuration, and Header Files
webqosapi.h Header File
#define WQERR_INVALD_SOCKID (-21) /* bad socket id parameter */
#define WQERR_USRCLAS_OTHER (-22) /* other user class error */
#define WQERR_PLCY_DISALLOW(-23) /* admin disallow app usr cls modifcn*/
#define WQERR_INVAL_USR_CLS (-24) /* app provided invalid usr cls param*/
/* scope argument value for wq_set_proc_cls() */
#define WQ_SCOPE_PROCESS1