#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | DnxTransStats_ |
Transport Statistics. More... | |
struct | DnxChannel |
An abstraction for DnxChannel. More... | |
Defines | |
#define | DNX_MAX_URL 1023 |
The maximum length of a DNX transport URL. | |
#define | DNX_MAX_MSG 4096 |
The maximum length of a DNX message. | |
#define | DNX_MAX_ADDRESS 64 |
The maximum number of bytes in a DNX message address buffer. | |
#define | DNX_MAX_ADDRSTR 64 |
The maximum length of a DNX presentation address string. | |
#define | DNX_MODE_PASSIVE 0 |
server (listen) connection | |
#define | DNX_MODE_ACTIVE 1 |
client (send) connection | |
Typedefs | |
typedef struct DnxTransStats_ | DnxTransStats |
Transport Statistics. | |
Functions | |
int | dnxChanMapAdd (char *name, char *url) |
Add a new channel to the global channel map. | |
void | dnxChanMapDelete (char *name) |
Delete a channel map by name. | |
int | dnxConnect (char *name, int mode, DnxChannel **channel) |
Connect a specified channel. | |
void | dnxDisconnect (DnxChannel *channel) |
Disconnect and delete a specified channel. | |
int | dnxGet (DnxChannel *channel, char *buf, int *size, int timeout, char *src) |
Read data from an open channel. | |
int | dnxPut (DnxChannel *channel, char *buf, int size, int timeout, char *dst) |
Write data to an open channel. | |
void | dnxGetStats (DnxChannel *channel, DnxTransStats *tsp) |
Retrieve stats from an open channel. | |
void | dnxResetStats (DnxChannel *channel) |
Reset stats on an open channel. | |
int | dnxChanMapInit (char *fileName) |
Initialize the channel map sub-system. | |
void | dnxChanMapRelease (void) |
Clean up resources allocated by the channel map sub-system. | |
char * | dnxNtop (const void *sastr, char *buf, size_t bufsz) |
Convert a sockaddr structure to a presentable string. |
Connection targets for dnxConnect are specified as message queue names. Message queue names are specified in the configuration file, and by DNX_MSG_REGISTER messages. The configuration file specification is of the form:
[MessageQueues] MessageQueueName = URL
The currently supported URLs are:
1. dnx+tcp://hostname:port 2. dnx+udp://hostname:port (currently the only one in use) 3. dnx+msgq://message-queue-ID
Currently configured message queue names are:
1. Scheduler - Dispatchers use this to communicate with the Nagios scheduler. 2. Jobs - Workers use this to receive jobs from dispatchers and the WLM (for shutdown). 3. Results - Workers use this to post completed Jobs to the collector. 4. Collector - Local collectors use this to communicate with the master collector.
Definition in file dnxTransport.h.
#define DNX_MAX_ADDRESS 64 |
The maximum number of bytes in a DNX message address buffer.
Definition at line 65 of file dnxTransport.h.
Referenced by dnxAgentServer(), and processCommands().
#define DNX_MAX_ADDRSTR 64 |
The maximum length of a DNX presentation address string.
Definition at line 68 of file dnxTransport.h.
Referenced by dnxAgentServer(), dnxSendMgmtReply(), dnxTimer(), dnxWaitForMgmtRequest(), and processCommands().
#define DNX_MAX_MSG 4096 |
The maximum length of a DNX message.
Definition at line 62 of file dnxTransport.h.
Referenced by dnxPut(), dnxTcpRead(), dnxXmlAdd(), dnxXmlClose(), dnxXmlCmpStr(), and dnxXmlGet().
#define DNX_MAX_URL 1023 |
The maximum length of a DNX transport URL.
Definition at line 59 of file dnxTransport.h.
Referenced by dnxChanMapAdd(), and dnxChanMapUrlParse().
#define DNX_MODE_ACTIVE 1 |
client (send) connection
Definition at line 72 of file dnxTransport.h.
Referenced by dnxTcpOpen(), dnxUdpOpen(), initWorkerComm(), and main().
#define DNX_MODE_PASSIVE 0 |
server (listen) connection
Definition at line 71 of file dnxTransport.h.
Referenced by dnxCollectorCreate(), dnxDispatcherCreate(), dnxInitAgent(), and initClientComm().
typedef struct DnxTransStats_ DnxTransStats |
Transport Statistics.
int dnxChanMapAdd | ( | char * | name, | |
char * | url | |||
) |
Add a new channel to the global channel map.
[in] | name | - the name of the new channel to be added. |
[in] | url | - the URL to associate with this new channel. |
Definition at line 251 of file dnxTransport.c.
References chanMutex, DNX_ERR_MEMORY, DNX_MAX_URL, DNX_OK, DNX_PT_MUTEX_LOCK, DNX_PT_MUTEX_UNLOCK, dnxChanMapFindName(), dnxChanMapFindSlot(), dnxChanMapUrlParse(), DnxChanMap_::name, DnxChanMap_::url, xfree, and xstrdup.
Referenced by dnxCollectorCreate(), dnxDispatcherCreate(), dnxInitAgent(), initClientComm(), initWorkerComm(), and main().
void dnxChanMapDelete | ( | char * | name | ) |
Delete a channel map by name.
[in] | name | - the name of the channel map to be deleted. |
Definition at line 297 of file dnxTransport.c.
References chanMutex, DNX_OK, DNX_PT_MUTEX_LOCK, DNX_PT_MUTEX_UNLOCK, dnxChanMapFindName(), DnxChanMap_::name, DnxChanMap_::url, and xfree.
Referenced by dnxCollectorCreate(), dnxCollectorDestroy(), dnxDispatcherCreate(), dnxDispatcherDestroy(), dnxInitAgent(), dnxReleaseAgent(), initClientComm(), initWorkerComm(), main(), releaseClientComm(), and releaseWorkerComm().
int dnxChanMapInit | ( | char * | fileName | ) |
Initialize the channel map sub-system.
[in] | fileName | - a persistent storage file for the channel map. Not currently used. |
Definition at line 457 of file dnxTransport.c.
References chanMutex, DNX_OK, DNX_PT_MUTEX_DESTROY, DNX_PT_MUTEX_INIT, dnxInit, elemcount, and DnxTransport::txExit.
Referenced by dnxServerInit(), initClientComm(), and main().
void dnxChanMapRelease | ( | void | ) |
Clean up resources allocated by the channel map sub-system.
Definition at line 490 of file dnxTransport.c.
References chanMutex, DNX_MAX_CHAN_MAP, DNX_PT_MUTEX_DESTROY, DNX_PT_MUTEX_LOCK, DNX_PT_MUTEX_UNLOCK, dnxInit, elemcount, DnxTransport::txExit, and xfree.
Referenced by dnxServerDeInit(), initClientComm(), main(), and releaseClientComm().
int dnxConnect | ( | char * | name, | |
int | mode, | |||
DnxChannel ** | channel | |||
) |
Connect a specified channel.
The mode
parameter specifies either active (DNX_MODE_ACTIVE) or passive (DNX_MODE_PASSIVE) for the connection mode. An active connection is basically a client connection, or a connection on which we send data to a server. A passive connection is a server connection, or a connection on which we listen for incoming messages.
[in] | name | - the name of the channel to open. |
[in] | mode | - boolean; true (1) means this will be an active (client- side) connection to a server; false (0) means this will be a passive (server-side) listen point. |
[out] | channel | - the address of storage for the returned connected channel. |
Definition at line 336 of file dnxTransport.c.
References DNX_OK, dnxChanMapAllocChannel(), iDnxChannel_::txDelete, and iDnxChannel_::txOpen.
Referenced by dnxCollectorCreate(), dnxDispatcherCreate(), dnxInitAgent(), initClientComm(), initWorkerComm(), and main().
void dnxDisconnect | ( | DnxChannel * | channel | ) |
Disconnect and delete a specified channel.
[in] | channel | - the channel to be disconnected (and deleted). |
Definition at line 361 of file dnxTransport.c.
References DNX_OK, iDnxChannel_::txClose, and iDnxChannel_::txDelete.
Referenced by dnxCollectorCreate(), dnxCollectorDestroy(), dnxDispatcherCreate(), dnxDispatcherDestroy(), dnxInitAgent(), dnxReleaseAgent(), initWorkerComm(), main(), releaseClientComm(), and releaseWorkerComm().
int dnxGet | ( | DnxChannel * | channel, | |
char * | buf, | |||
int * | size, | |||
int | timeout, | |||
char * | src | |||
) |
Read data from an open channel.
[in] | channel | - the channel from which to read. |
[out] | buf | - the address of storage for data read from channel . |
[in,out] | size | - on entry, the maximum number of bytes that may be read into buf ; on exit, returns the number of bytes actually read. |
[in] | timeout | - the maximum number of seconds the caller is willing to wait for data on channel before returning a timeout error. |
[out] | src | - the address of storage for the remote sender's address. This parameter is optional, and may be passed as NULL. The caller must ensure that the buffer pointed to is large enough to hold the returned address. Passing the address of a struct sockaddr_storage is more than adequate for any address type available. |
Definition at line 389 of file dnxTransport.c.
References iDnxChannel_::txRead.
Referenced by dnxWaitForJob(), dnxWaitForMgmtReply(), dnxWaitForMgmtRequest(), dnxWaitForNodeRequest(), and dnxWaitForResult().
void dnxGetStats | ( | DnxChannel * | channel, | |
DnxTransStats * | tsp | |||
) |
Retrieve stats from an open channel.
[in] | channel | - the channel from which stats are to be retrieved. |
[out] | tsp | - a buffer into which stats are to be copied. |
Definition at line 426 of file dnxTransport.c.
References iDnxChannel_::txGetStats.
char* dnxNtop | ( | const void * | sastr, | |
char * | buf, | |||
size_t | bufsz | |||
) |
Convert a sockaddr structure to a presentable string.
[in] | sastr | - an optional sockaddr structure to be converted. |
[out] | buf | - the destination buffer, which must be at least DNX_MAX_ADDRSTR bytes in length to hold the longest string. |
[in] | bufsz | - the size in bytes of buf . |
buf
. Definition at line 106 of file dnxTransport.c.
Referenced by dnxAgentServer(), dnxCreateNodeAt(), dnxSendMgmtReply(), dnxTimer(), dnxWaitForMgmtRequest(), dnxWaitForNodeRequest(), and processCommands().
int dnxPut | ( | DnxChannel * | channel, | |
char * | buf, | |||
int | size, | |||
int | timeout, | |||
char * | dst | |||
) |
Write data to an open channel.
[in] | channel | - the channel to which data should be written. |
[in] | buf | - the data to be written to channel . |
[in] | size | - the number of bytes in buf to be written. |
[in] | timeout | - the maximum number of seconds the caller is willing to wait for the write operation to complete on channel before returning a timeout error. |
[in] | dst | - the address to which data should be sent. This parameter is optional and may be passed as NULL. If NULL, the channel configured address will be used. |
Definition at line 412 of file dnxTransport.c.
References DNX_MAX_MSG, and iDnxChannel_::txWrite.
Referenced by dnxSendJob(), dnxSendMgmtReply(), dnxSendMgmtRequest(), dnxSendNodeRequest(), and dnxSendResult().
void dnxResetStats | ( | DnxChannel * | channel | ) |
Reset stats on an open channel.
[in] | channel | - the channel on which stats are to be reset. |
Definition at line 440 of file dnxTransport.c.
References iDnxChannel_::txResetStats.