TipcMonServerCpuPoll


Name

TipcMonServerCpuPoll — poll for the percentage of CPU time used by an RTserver

Synopsis

T_BOOL TipcMonServerCpuPoll(server_name) 
T_STR server_name; 

Arguments

server_name — name of RTserver to get CPU usage for (wildcard names allowed, or use T_IPC_MON_ALL to indicate a poll of all RTservers matching the value of Monitor_Scope)

Return Values

TRUE if the poll for the number of subjects was successfully initiated, FALSE otherwise.

Diagnostics

If TipcMonServerCpuPoll fails, it returns FALSE and sets the global SmartSockets error number to:

Description

TipcMonServerCpuPoll polls for the percentage of CPU time used by an RTserver by sending a MON_SERVER_CPU_POLL_CALL message to the server_name RTserver. The server_name argument can be the unique subject name of a single RTserver, a wildcarded subject name to match many RTservers, or T_IPC_MON_ALL to poll all RTservers that match the value of the Monitor_Scope option. The polled RTservers respond by sending back a MON_SERVER_CPU_POLL_RESULT message.

Each MON_SERVER_CPU_POLL_RESULT contains two fields:

There are multiple responses only if server_name is a wildcard or T_IPC_MON_ALL.

If the RTserver cannot query the operating system, the value reported in the CPU percentage used field is a negative number.

Caution

There is no response message if the RTserver named server_name does not exist; the poll is silently dropped.

TipcMonServerCpuPoll sends a MON_SERVER_CPU_POLL_CALL message to RTserver, but does not explicitly flush the message. See TipcSrvGetAutoFlushSize for more information on message buffering.

RTserver CPU usage information can only be polled, not watched.

See Also

TipcMonClientCpuPoll

Examples

This example uses TipcMonServerCpuPoll to poll for information in all RTservers, creates a callback to process the incoming MON_SERVER_CPU_POLL_RESULT messages, and waits up to 10 seconds for the poll results.:

/* =============================================================== */ 
/*..process_mon_server_cpu_poll_result – process a 
MON_SERVER_CPU_POLL_RESULT message */ 
 
void process_mon_server_cpu_poll_result(conn, data, arg) 
T_IPC_CONN conn; 
T_IPC_CONN_PROCESS_CB_DATA data; 
T_CB_ARG arg; 
{ 
  T_STR server_name; 
  T_REAL4 cpu_utilization; 
 
  /* must set current field first */ 
  if (!TipcMsgSetCurrent(data->msg, 0)) { 
    return; /* error */ 
  } 
 
  /* get the fields from the message */ 
  if (!TipcMsgRead(data->msg, 
                   T_IPC_FT_STR, &server_name, 
                   T_IPC_FT_REAL4, &cpu_utilization, 
                   NULL)) { 
    return; /* error */ 
  } 
 
  TutOut("Got SERVER_CPU poll result.\n"); 
  TutOut("RTserver name = %s\n", server_name); 
  TutOut("CPU utilization percentage = %f\n", cpu_utilization); 
}  /* process_mon_server_cpu_poll_result */ 
 
/* =============================================================== */ 
/*...code from calling function is below */ 
 
T_IPC_MT mt; 
 
/* send the poll request out to RTserver */ 
if (!TipcMonServerCpuPoll("/...")) { 
  return; /* error */ 
} 
 
mt = TipcMtLookupByNum(T_MT_MON_SERVER_CPU_POLL_RESULT); 
if (mt == NULL) { 
  return; /* error */ 
} 
 
if (TipcSrvProcessCbCreate(mt, process_mon_server_cpu_poll_result, 
                           NULL) == NULL) { 
  return; /* error */ 
} 
 
/* read and process all poll results (as well as any other incoming messages) that arrive within the 
next 10 seconds */ 
 
if (!TipcSrvMainLoop(10.0)) { 
  return; /* error */ 
} 

TIBCO SmartSockets™ Application Programming Interface
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com