Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

rmClient.cpp File Reference

#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <exception>
#include <ResourceMonitor/ResourceMonitor.h>
#include "rmClient.h"
#include "rmClientError.h"
#include "rmSysInfo.h"
#include "rmConfig.h"
#include "rmControl.h"
#include "rmMonitor.h"
#include "rmEvent.h"
#include "eventLog.h"
#include "uuid/uuid.h"
#include <tcpd.h>

Go to the source code of this file.

Compounds

class  rmClient
class  subagentBase

Functions

subagentBasegSubagent (NULL)
int initRMClient ()
 initializes all the system information from ResourceMonitor Daemon. More...

void shutdownRMClient ()
int getRMVersion ()
 returns the version number of the ResourceMonitor Daemon. More...

int getInteger32 (RMEntity aEntity, RMAttribute aName, unsigned long aID, long *aValue)
 returns the integer value of a particular name in a particular entity. More...

int setInteger32 (RMEntity aEntity, RMAttribute aName, unsigned long aID, long aValue)
 sets the integer value of a particular name in a particular entity. More...

int getUnsigned (RMEntity aEntity, RMAttribute aName, unsigned long aID, unsigned long *aValue)
 returns the integer value of a particular name in a particular entity. More...

int setUnsigned (RMEntity aEntity, RMAttribute aName, unsigned long aID, unsigned long aValue)
 sets the integer value of a particular name in a particular entity. More...

int getUnsigned64 (RMEntity aEntity, RMAttribute aName, unsigned long aID, u_int64_t *aValue)
 returns the unsigned integer value of a particular name in a particular entity. More...

int setUnsigned64 (RMEntity aEntity, RMAttribute aName, unsigned long aID, u_int64_t aValue)
 sets the unsigned integer value of a particular name in a particular entity. More...

int getUUIDString (RMEntity aEntity, RMAttribute aName, unsigned long aID, char *aBuf)
 returns the UUID (in string format) of a particular name in an entity. More...

int getUUID (RMEntity aEntity, RMAttribute aName, unsigned long aID, uuid_t aUUID)
 returns the UUID of a particular name in an entity. More...

int setUUIDString (RMEntity aEntity, RMAttribute aName, unsigned long aID, char *aUUID)
 sets the UUID of a particular name in an entity. More...

int getString (RMEntity aEntity, RMAttribute aName, unsigned long aID, char **aBuf)
 gets the string of a particular named attribute in an entity. More...

int setString (RMEntity aEntity, RMAttribute aName, unsigned long aID, char *aBuf)
 gets the string of a particular named attribute in an entity. More...

int newEntry (RMEntity aEntity, unsigned long aID)
 create a new entry in an entity. More...

int deleteEntry (RMEntity aEntity, unsigned long aID)
 remove an entry in an entity. More...

unsigned long getNewId (RMEntity aEntity)
 get a valid ID for creating a new entry in an entity. More...

int findId (RMEntity aEntity, unsigned long aID)
 test if the ID represents a valid entry in an entity. More...

int getNextId (RMEntity aEntity, unsigned long aID, unsigned long *aNextID)
 find the next valid ID in an entity based on the ID supplied. More...

size_t getCount (RMEntity aEntity)
 returns the number of entries for an entity. More...

int getBinary (RMEntity aEntity, RMAttribute aName, unsigned long aID, char **aBuf, unsigned long *aLength)
 get binary data from Event Log. More...

void addEvent (posix_log_recid_t aRecid, unsigned long aId)
 add a ResourceMonitor event to the event queue. More...

void processEvents ()
 process all the ResourceMonitor events in the queue. More...


Variables

int allow_severity = LOG_INFO
int deny_severity = LOG_WARNING


Function Documentation

void addEvent posix_log_recid_t    aRecid,
unsigned long    aId
 

add a ResourceMonitor event to the event queue.

Add a ResourceMonitor event into the event queue. ResourceMonitor events including: threshold monitor notifications, thresholdCancel monitor notifications, leakyBucket monitor notifications, Subsystem changes, Resource changes

Parameters:
aRecid  The recid (in the system EventLog) of this event.
aMonid  The monitor ID of this notification. Could be 0 if it is not a monitor event.
Returns:
no return.

Definition at line 1358 of file rmClient.cpp.

References subagentBase::addEvent.

int deleteEntry RMEntity    aEntity,
unsigned long    aID
 

remove an entry in an entity.

Remove a new entry in the specified entity table using the id value.

Parameters:
aEntity  One of the entities listed in RMEntity.
aID  The ID value of the entry to be removed.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. specific error codes for other failure.

Definition at line 1239 of file rmClient.cpp.

References subagentBase::deleteEntry, and RMEntity.

int findId RMEntity    aEntity,
unsigned long    aID
 

test if the ID represents a valid entry in an entity.

Test if a particular id, aID, represents a valid entry in the entity table.

Parameters:
aEntity  One of the entities listed in RMEntity.
aID  The ID value of the entry.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. specific error codes for other failure.

Definition at line 1273 of file rmClient.cpp.

References subagentBase::findId, and RMEntity.

int getBinary RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
char **    aBuf,
unsigned long *    aLength
 

get binary data from Event Log.

Get the binary string of a particular named attribute of an entity.

Parameters:
aEntity  One of the entities listed in RMEntity.
aID  The ID value of the entry.
aBuf  Pointer to the binary string buffer.
aLength  length of the binary string buffer.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. specific error codes for other failure.
Remarks:
only EVENTLOG table implemented this function. Like getString(), memory is allocated on the heap as well. So caller has to free() afterwards.
See also:
getString().

Definition at line 1334 of file rmClient.cpp.

References subagentBase::getBinary, RMAttribute, and RMEntity.

size_t getCount RMEntity    aEntity
 

returns the number of entries for an entity.

Get the number of entries in entity table.

Parameters:
aEntity  One of the entities listed in RMEntity.
Returns:
the entity table size.

Definition at line 1309 of file rmClient.cpp.

References subagentBase::getCount, and RMEntity.

int getInteger32 RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
long *    aValue
 

returns the integer value of a particular name in a particular entity.

Get the value of a particular named attribute in a particular entity. The data type must be 'long', or a 32 bit integer in this case.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aValue  Pointer to the integer value.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.

Definition at line 888 of file rmClient.cpp.

References subagentBase::getInteger32, RMAttribute, and RMEntity.

unsigned long getNewId RMEntity    aEntity
 

get a valid ID for creating a new entry in an entity.

Get the id value of the next new entry in the entity table.

Parameters:
aEntity  One of the entities listed in RMEntity.
Returns:
positive id value.

Definition at line 1254 of file rmClient.cpp.

References subagentBase::getNewId, and RMEntity.

int getNextId RMEntity    aEntity,
unsigned long    aID,
unsigned long *    aNextID
 

find the next valid ID in an entity based on the ID supplied.

Find the next valid ID in the entity table, which means the first entry in the table whose id value is greater than the aID.

Parameters:
aEntity  One of the entities listed in RMEntity.
aID  The ID value of the entry.
aNextID  Pointer to the next valid id in the table.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. specific error codes for other failure.

Definition at line 1293 of file rmClient.cpp.

References subagentBase::getNextId, and RMEntity.

int getRMVersion  
 

returns the version number of the ResourceMonitor Daemon.

Returns the ResourceMonitor version number.

Definition at line 853 of file rmClient.cpp.

Referenced by var_RMSystemInfo.

int getString RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
char **    aBuf
 

gets the string of a particular named attribute in an entity.

Get the string value of a particular named attribute in a particular entity. The data type must be 'char *'.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aBuf  Pointer to the char buffer that holds the string.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Memory is allocated on the heap. So caller has to call free() afterwards.
See also:
setString().

Definition at line 1172 of file rmClient.cpp.

References subagentBase::getString, RMAttribute, and RMEntity.

int getUnsigned RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
unsigned long *    aValue
 

returns the integer value of a particular name in a particular entity.

Get the value of a particular named attribute in a particular entity. The data type must be 'unsigned long', or a 32 bit unsigned integer in this case.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aValue  Pointer to the unsigned integer value.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.

Definition at line 945 of file rmClient.cpp.

References subagentBase::getUnsigned, RMAttribute, and RMEntity.

int getUnsigned64 RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
u_int64_t *    aValue
 

returns the unsigned integer value of a particular name in a particular entity.

Get the value of a particular named attribute in a particular entity. The data type must be 'unsigned long long', or a 64 bit unsigned integer in this case.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aValue  Pointer to the unsigned integer value.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.

Definition at line 1003 of file rmClient.cpp.

References subagentBase::getUnsigned64, RMAttribute, and RMEntity.

int getUUID RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
uuid_t    aUUID
 

returns the UUID of a particular name in an entity.

Get the value of a particular named attribute in a particular entity. The data type must be 'uuid_t'.

rmClient library provides two ways of retreving a uuid.

  • via the native uuid data format uuid_t
  • via the string format
If the uuid_t format is desired, caller provide a pointer which point to an uuid_t variable. The value of the named attribute will then be stored in aUUID.
Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aUUID  Pointer to the uuid_t variable supplied by caller.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.
See also:
getUUIDString().

Definition at line 1114 of file rmClient.cpp.

References subagentBase::getUUID, RMAttribute, and RMEntity.

int getUUIDString RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
char *    aBuf
 

returns the UUID (in string format) of a particular name in an entity.

Get the value of a particular named attribute in a particular entity. The data type must be 'uuid_t'.

rmClient library provides two ways of retreving a uuid.

  • via the native uuid data format uuid_t
  • via the string format
If the string format is desired, caller provide a buffer which is long enough to hold UUID_STRING_LENGTH. This function will convert the named attribute from uuid_t into a c string, which will be stored in aBuf.
Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aBuf  Pointer to the char buffer that is long enough for UUID_STRING_LENGTH.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.
See also:
getUUID().

Definition at line 1074 of file rmClient.cpp.

References subagentBase::getUUIDString, RMAttribute, and RMEntity.

subagentBase* gSubagent NULL   
 

Initialized the rmclient library by creating all the data tables and filling the appriate entries.

Returns:
0 if successful. or error code returned by other init functions.
Remarks:
This function must be called before any other functions in this library.

Todo:
make this function call automatic when other functions being called.

int initRMClient  
 

initializes all the system information from ResourceMonitor Daemon.

Definition at line 826 of file rmClient.cpp.

References subagentBase::init.

Referenced by main.

int newEntry RMEntity    aEntity,
unsigned long    aID
 

create a new entry in an entity.

Create a new entry in the specified entity table using the id value.

Precondition:
To create a new entry, caller must first call getNewId() to get the id value of the next entry.
Parameters:
aEntity  One of the entities listed in RMEntity.
aID  The ID value of the new entry.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. specific error codes for other failure.
See also:
getNewId().

Definition at line 1221 of file rmClient.cpp.

References subagentBase::newEntry, and RMEntity.

void processEvents  
 

process all the ResourceMonitor events in the queue.

Process all the events in the ResourceMonitor event queue.

Returns:
no return.

Definition at line 1372 of file rmClient.cpp.

References subagentBase::processEvents.

Referenced by main.

int setInteger32 RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
long    aValue
 

sets the integer value of a particular name in a particular entity.

Set the value of a particular named attribute in a particular entity. The data type must be 'long', or a 32 bit integer in this case.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aValue  Integer value to be set.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.

Definition at line 916 of file rmClient.cpp.

References RMAttribute, RMEntity, and subagentBase::setInteger32.

int setString RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
char *    aBuf
 

gets the string of a particular named attribute in an entity.

Set the string value of a particular named attribute in a particular entity. The data type must be 'char *'.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aBuf  Pointer to the char buffer that holds the string.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
See also:
setString().

Definition at line 1197 of file rmClient.cpp.

References RMAttribute, RMEntity, and subagentBase::setString.

int setUnsigned RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
unsigned long    aValue
 

sets the integer value of a particular name in a particular entity.

Set the value of a particular named attribute in a particular entity. The data type must be 'unsigned long', or a 32 bit unsigned integer in this case.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aValue  Intended unsigned integer value.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.

Definition at line 974 of file rmClient.cpp.

References RMAttribute, RMEntity, and subagentBase::setUnsigned.

int setUnsigned64 RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
u_int64_t    aValue
 

sets the unsigned integer value of a particular name in a particular entity.

Set the value of a particular named attribute in a particular entity. The data type must be 'unsigned long long', or a 64 bit unsigned integer in this case.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aValue  Pointer to the unsigned integer value.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.

Definition at line 1032 of file rmClient.cpp.

References RMAttribute, RMEntity, and subagentBase::setUnsigned64.

int setUUIDString RMEntity    aEntity,
RMAttribute    aName,
unsigned long    aID,
char *    aUUID
 

sets the UUID of a particular name in an entity.

Set the value of a particular named attribute in a particular entity. The data type must be 'uuid_t'.

Parameters:
aEntity  One of the entities listed in RMEntity.
aName  One of the names listed in RMAttribute.
aID  One of the entries in the table for aEntity.
aUUID  Pointer to the char buffer that holds the string representation of the uuid.
Returns:
RMCLIENT_SUCCESS if successful. RMCLIENT_ERROR_NOSUCHENTITY for invalid aEntity. RMCLIENT_ERROR_NOSUCHNAME for invalid aName. specific entity error code for other failure.
Remarks:
Entities have attributes associated with them. Every attribute has its own data type. They are documented in rmClientTypes.h file. Instead of creating a function for every operation on every attributes, this function can be applied to all the attributes with the same data type.
See also:
getUUIDString().

Definition at line 1145 of file rmClient.cpp.

References RMAttribute, RMEntity, and subagentBase::setUUIDString.

void shutdownRMClient  
 

Shutdown the ResourceMonitor Client by destructing all the tables and the event queue that the client used.

Returns:
no return.

Definition at line 842 of file rmClient.cpp.

References subagentBase::shutdown.

Referenced by main.


Variable Documentation

int allow_severity = LOG_INFO
 

Definition at line 26 of file rmClient.cpp.

int deny_severity = LOG_WARNING
 

Definition at line 27 of file rmClient.cpp.


Generated on Tue Sep 10 16:46:33 2002 for ResourceMonitorSNMPSubagent by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002