#include "dnxAgent.h"
#include "dnxNebMain.h"
#include "dnxTransport.h"
#include "dnxProtocol.h"
#include "dnxCfgParser.h"
#include "dnxError.h"
#include "dnxDebug.h"
#include "dnxLogging.h"
#include "dnxStats.h"
#include <unistd.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
Go to the source code of this file.
Data Structures | |
| struct | MgmtNodeStatsData |
Defines | |
| #define | elemcount(x) (sizeof(x)/sizeof(*(x))) |
Functions | |
| static char * | buildHelpReply (void) |
| Build an allocated response buffer for the HELP request. | |
| static int | appendString (char **spp, char *fmt,...) |
| Append text to a string by reallocating the string buffer. | |
| static int | dnxCountNodes (DnxNodeData *node, void *data) |
| Count the number of active nodes in the node table. | |
| static char * | buildMgmtStatsReply (char *req) |
| Build an allocated response buffer for requested stats values. | |
| static int | dnxBuildNodeStatsReply (DnxNodeData *node, void *data) |
| Return an allocated stats buffer for a given active node. | |
| static char * | buildMgmtNodeStatsReply (char *req) |
| Build an allocated response buffer for requested stats values. | |
| static int | dnxResetNodeStats (DnxNodeData *node, void *data) |
| Reset (zero) the stats of this node. | |
| static int | dnxNodeListBuilder (DnxNodeData *node, void *data) |
| Append the active node address string to a list of node address strings. | |
| static char * | buildMgmtNodeListReply (void) |
| Build and return a response for a list of nodes. | |
| static char * | buildMgmtCfgReply (void) |
| Build an allocated response buffer for the current configuration. | |
| static void * | dnxAgentServer (void *data) |
| The agent thread control procedure. | |
| int | dnxInitAgent (char *agentUrl, DnxCfgParser *parser) |
| Initializes the server management agent. | |
| void | dnxReleaseAgent (void) |
| Cleans up server management agent. | |
Variables | |
| static char * | s_agentName = "Agent" |
| The agent channel name. | |
| static DnxChannel * | s_agent |
| The agent comm channel. | |
| static pthread_t | s_agentTid |
| The agent thread id. | |
| static DnxCfgParser * | s_parser |
| The system configuration parser. | |
| static int | s_shutdown |
| The agent shutdown flag. | |
Definition in file dnxAgent.c.
| #define elemcount | ( | x | ) | (sizeof(x)/sizeof(*(x))) |
Definition at line 48 of file dnxAgent.c.
| static int appendString | ( | char ** | spp, | |
| char * | fmt, | |||
| ... | ||||
| ) | [static] |
Append text to a string by reallocating the string buffer.
This is a var-args function. Additional parameters following the fmt parameter are based on the content of the fmt string.
| [in] | spp | - the address of a dynamically allocated buffer pointer. |
| [in] | fmt | - a printf-like format specifier string. |
Definition at line 110 of file dnxAgent.c.
References DNX_ERR_MEMORY, and xrealloc.
| static char* buildHelpReply | ( | void | ) | [static] |
Build an allocated response buffer for the HELP request.
Definition at line 65 of file dnxAgent.c.
References xstrdup.
| static char* buildMgmtCfgReply | ( | void | ) | [static] |
Build an allocated response buffer for the current configuration.
Definition at line 412 of file dnxAgent.c.
References dnxCfgParserGetCfg(), xfree, and xmalloc.
| static char* buildMgmtNodeListReply | ( | void | ) | [static] |
Build and return a response for a list of nodes.
Definition at line 391 of file dnxAgent.c.
References dnxNodeListBuilder(), dnxStatsForEachNode(), and xstrdup.
| static char* buildMgmtNodeStatsReply | ( | char * | req | ) | [static] |
Build an allocated response buffer for requested stats values.
| [in] | req | - The ip address followed by the requested stats in a comma-separated string format. |
Definition at line 330 of file dnxAgent.c.
References dnxBuildNodeStatsReply(), dnxStatsForNodeByAddrStr(), MgmtNodeStatsData::rsp, MgmtNodeStatsData::stats, and xstrdup.
| static char* buildMgmtStatsReply | ( | char * | req | ) | [static] |
Build an allocated response buffer for requested stats values.
| [in] | req | - The requested stats in comma-separated string format. |
Definition at line 161 of file dnxAgent.c.
References appendString(), DISPATCHES_FAILED, DISPATCHES_OK, dnxCountNodes(), dnxStatsForEachNode(), dnxStatsGetServerStats(), elemcount, JOBS_HANDLED, JOBS_REJECTED_NO_NODES, JOBS_REJECTED_NO_SLOTS, POST_RESULTS_FAILED, POST_RESULTS_OK, REQUESTS_EXPIRED, REQUESTS_RECEIVED, RESULTS_FAILED, RESULTS_OK, RESULTS_TIMED_OUT, STATS_COUNT, and xfree.
| static void* dnxAgentServer | ( | void * | data | ) | [static] |
The agent thread control procedure.
| [in] | data | - thread data; not used. |
Definition at line 437 of file dnxAgent.c.
References DnxMgmtRequest::action, DnxMgmtRequest::address, buildHelpReply(), buildMgmtCfgReply(), buildMgmtNodeListReply(), buildMgmtNodeStatsReply(), buildMgmtStatsReply(), DNX_ERR_TIMEOUT, DNX_MAX_ADDRESS, DNX_MAX_ADDRSTR, DNX_OK, DNX_REQ_ACK, DNX_REQ_NAK, dnxDebug(), dnxErrorString(), dnxLog(), dnxNtop(), dnxResetNodeStats(), dnxSendMgmtReply(), dnxStatsForEachNode(), dnxStatsResetServerStats(), dnxWaitForMgmtRequest(), DnxMgmtReply::reply, s_shutdown, DnxMgmtReply::status, versionText(), xfree, DnxMgmtRequest::xid, DnxMgmtReply::xid, and xstrdup.
| static int dnxBuildNodeStatsReply | ( | DnxNodeData * | node, | |
| void * | data | |||
| ) | [static] |
Return an allocated stats buffer for a given active node.
The results are built in data->rsp;
| [in] | node | - the node in this iteration. |
| [in] | data | - the MgmtNodeStatsData structure. |
Definition at line 254 of file dnxAgent.c.
References appendString(), DISPATCHES_FAILED, DISPATCHES_OK, DNX_ERR_MEMORY, DNX_OK, elemcount, REQUESTS_EXPIRED, REQUESTS_RECEIVED, RESULTS_FAILED, RESULTS_OK, RESULTS_TIMED_OUT, MgmtNodeStatsData::rsp, DnxNodeData::stats, MgmtNodeStatsData::stats, and xfree.
| static int dnxCountNodes | ( | DnxNodeData * | node, | |
| void * | data | |||
| ) | [static] |
Count the number of active nodes in the node table.
| [in] | node | - the node in this iteration. |
| [in] | data | - the address of an integer counter. |
Definition at line 145 of file dnxAgent.c.
References REQUESTS_RECEIVED, and DnxNodeData::stats.
| int dnxInitAgent | ( | char * | agentUrl, | |
| DnxCfgParser * | parser | |||
| ) |
Initializes the server management agent.
| [in] | agentUrl | - the listen url of the agent. |
| [in] | parser | - the global configuration parser. |
Definition at line 522 of file dnxAgent.c.
References DNX_ERR_THREAD, DNX_MODE_PASSIVE, DNX_OK, dnxAgentServer(), dnxChanMapAdd(), dnxChanMapDelete(), dnxConnect(), dnxDisconnect(), dnxErrorString(), dnxLog(), s_agentName, s_agentTid, and s_shutdown.
| static int dnxNodeListBuilder | ( | DnxNodeData * | node, | |
| void * | data | |||
| ) | [static] |
Append the active node address string to a list of node address strings.
| [in] | node | - the node in this iteration. |
| [in] | data | - the address of a character pointer containing the list. |
Definition at line 378 of file dnxAgent.c.
References DnxNodeData::addrstr, appendString(), REQUESTS_RECEIVED, and DnxNodeData::stats.
| void dnxReleaseAgent | ( | void | ) |
Cleans up server management agent.
Definition at line 549 of file dnxAgent.c.
References dnxChanMapDelete(), dnxDisconnect(), s_agentName, s_agentTid, and s_shutdown.
| static int dnxResetNodeStats | ( | DnxNodeData * | node, | |
| void * | data | |||
| ) | [static] |
Reset (zero) the stats of this node.
| [in] | node | - the node in this iteration. |
| [in] | data | - the address of a character pointer containing the list. |
Definition at line 362 of file dnxAgent.c.
References DnxNodeData::stats.
DnxChannel* s_agent [static] |
char* s_agentName = "Agent" [static] |
pthread_t s_agentTid [static] |
DnxCfgParser* s_parser [static] |
int s_shutdown [static] |
1.5.6