HP WebQoS Administration Guide
External Measurement API
Sample Program
Appendix B 141
char measValue[MAX_TOKEN]; // Measurement Value as a char array
char hostname[MAX_TOKEN]; // SCI System Name
char str_timestamp[MAX_TOKEN]; // timestamp as a char array
wqStatus status = 0; // status code
wqSocket socket; //socket Descriptor
char flag = ‘y’;
double timestamp;
long l_timestamp;
// get the SCI system name
printf(“Enter the host name:\n”);
gets(hostname);
// connect to the SCI
status = wqCreateConnection(hostname, &socket);
if (status == WQ_STATUS_OK)
{
// calculate the timestamp, once the connection is set up
timestamp = (double)time(NULL); /* convert seconds to milliseconds */
l_timestamp = ceil(timestamp);
// convert the timestamp into char*
ltoa(l_timestamp, str_timestamp,10);
// see the Schema file or the DTD to create an xml string.
// create the xml string with the appropriate values and tags.
strcpy(xmlString,”<timeStamp>”);
strcat(xmlString, str_timestamp);
strcat(xmlString, “</timeStamp>”);
while(flag == ‘y’)
{
fflush(stdin);
strcat(xmlString, “<measPair><measName>”);
printf(“Enter the Measurement Name :\n”);
gets(measName);
printf(“Enter the Value:\n”);
gets(measValue);
strcat(xmlString,measName);
strcat(xmlString,”</measName><measIntegerValue>”);
strcat(xmlString,measValue);
strcat(xmlString,”</measIntegerValue></measPair>”);
printf(“Do you want to Continue :(y-yes)\n”);
scanf(“%c”, &flag);
}
// send the xml string to the SCI
status = wqSendMeasurement(socket, xmlString);