mirror of
https://github.com/emqx/neuron.git
synced 2026-10-25 19:31:41 +08:00
revert: "feat: update manager to fullfill NEU_REQRESP_METRICS message"
This reverts commit ecd608fa5d.
This commit is contained in:
@@ -16,9 +16,7 @@
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**/
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <nng/nng.h>
|
||||
@@ -42,7 +40,6 @@
|
||||
|
||||
#include "manager.h"
|
||||
#include "manager_internal.h"
|
||||
#include "utils/time.h"
|
||||
|
||||
// definition for adapter names
|
||||
#define DEFAULT_DASHBOARD_ADAPTER_NAME DEFAULT_DASHBOARD_PLUGIN_NAME
|
||||
@@ -56,7 +53,6 @@ inline static void forward_msg_dup(neu_manager_t *manager, nng_msg *msg,
|
||||
nng_pipe pipe);
|
||||
inline static void forward_msg(neu_manager_t *manager, nng_msg *msg,
|
||||
const char *ndoe);
|
||||
static bool has_core_dumps();
|
||||
static void start_static_adapter(neu_manager_t *manager, const char *name);
|
||||
static int report_nodes_state(void *usr_data);
|
||||
static void start_single_adapter(neu_manager_t *manager, const char *name,
|
||||
@@ -76,7 +72,6 @@ neu_manager_t *neu_manager_create()
|
||||
.cb = report_nodes_state,
|
||||
};
|
||||
|
||||
manager->start_ts = neu_time_ms();
|
||||
manager->events = neu_event_new();
|
||||
manager->plugin_manager = neu_plugin_manager_create();
|
||||
manager->node_manager = neu_node_manager_create();
|
||||
@@ -208,24 +203,6 @@ static int manager_loop(enum neu_event_io_type type, int fd, void *usr_data)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NEU_REQRESP_METRICS: {
|
||||
neu_reqresp_metrics_t *cmd = (neu_reqresp_metrics_t *) &header[1];
|
||||
if (NULL == cmd->metrics ||
|
||||
0 !=
|
||||
neu_node_manager_get_metrics(manager->node_manager,
|
||||
cmd->metrics)) {
|
||||
break;
|
||||
}
|
||||
cmd->metrics->core_dumped = has_core_dumps();
|
||||
cmd->metrics->uptime_seconds =
|
||||
(neu_time_ms() - manager->start_ts) / 1000;
|
||||
|
||||
header->type = NEU_REQRESP_METRICS;
|
||||
strcpy(header->receiver, header->sender);
|
||||
reply(manager, header, cmd);
|
||||
|
||||
break;
|
||||
}
|
||||
case NEU_REQ_UPDATE_LICENSE: {
|
||||
UT_array *pipes = neu_node_manager_get_pipes(manager->node_manager,
|
||||
NEU_NA_TYPE_DRIVER);
|
||||
@@ -622,25 +599,6 @@ inline static void forward_msg(neu_manager_t *manager, nng_msg *msg,
|
||||
}
|
||||
}
|
||||
|
||||
static bool has_core_dumps()
|
||||
{
|
||||
DIR *dp = opendir("core");
|
||||
if (NULL == dp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (struct dirent *de = NULL; NULL != (de = readdir(dp));) {
|
||||
if (0 == strncmp("core", de->d_name, 4)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
return found;
|
||||
}
|
||||
|
||||
static void start_static_adapter(neu_manager_t *manager, const char *name)
|
||||
{
|
||||
neu_adapter_t * adapter = NULL;
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "subscribe.h"
|
||||
|
||||
typedef struct neu_manager {
|
||||
uint64_t start_ts;
|
||||
nng_socket socket;
|
||||
neu_events_t * events;
|
||||
neu_event_io_t * loop;
|
||||
|
||||
@@ -316,46 +316,3 @@ UT_array *neu_node_manager_get_state(neu_node_manager_t *mgr)
|
||||
|
||||
return states;
|
||||
}
|
||||
|
||||
int neu_node_manager_get_metrics(neu_node_manager_t *mgr,
|
||||
neu_metrics_t * metrics_p)
|
||||
{
|
||||
node_entity_t *el = NULL, *tmp = NULL;
|
||||
|
||||
metrics_p->north_nodes = 0;
|
||||
metrics_p->north_running_nodes = 0;
|
||||
metrics_p->north_disconnected_nodes = 0;
|
||||
metrics_p->south_nodes = 0;
|
||||
metrics_p->south_running_nodes = 0;
|
||||
metrics_p->south_disconnected_nodes = 0;
|
||||
|
||||
HASH_ITER(hh, mgr->nodes, el, tmp)
|
||||
{
|
||||
if (el->is_static || !el->display) {
|
||||
continue;
|
||||
}
|
||||
|
||||
neu_plugin_common_t *common =
|
||||
neu_plugin_to_plugin_common(el->adapter->plugin);
|
||||
|
||||
if (NEU_NA_TYPE_DRIVER == el->adapter->module->type) {
|
||||
++metrics_p->south_nodes;
|
||||
if (NEU_NODE_RUNNING_STATE_RUNNING == el->adapter->state) {
|
||||
++metrics_p->south_running_nodes;
|
||||
}
|
||||
if (NEU_NODE_LINK_STATE_DISCONNECTED == common->link_state) {
|
||||
++metrics_p->south_disconnected_nodes;
|
||||
}
|
||||
} else if (NEU_NA_TYPE_APP == el->adapter->module->type) {
|
||||
++metrics_p->north_nodes;
|
||||
if (NEU_NODE_RUNNING_STATE_RUNNING == el->adapter->state) {
|
||||
++metrics_p->north_running_nodes;
|
||||
}
|
||||
if (NEU_NODE_LINK_STATE_DISCONNECTED == common->link_state) {
|
||||
++metrics_p->north_disconnected_nodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,4 @@ nng_pipe neu_node_manager_get_pipe(neu_node_manager_t *mgr, const char *name);
|
||||
// neu_nodes_state_t array
|
||||
UT_array *neu_node_manager_get_state(neu_node_manager_t *mgr);
|
||||
|
||||
int neu_node_manager_get_metrics(neu_node_manager_t *mgr,
|
||||
neu_metrics_t * metrics_p);
|
||||
#endif
|
||||
Reference in New Issue
Block a user