Skip to content

Commit

Permalink
Resolving Issue #92
Browse files Browse the repository at this point in the history
Add Data Source ID to "Empty result' error messages
  • Loading branch information
cigamit committed May 24, 2019
1 parent d2e7a19 commit 5821b81
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The Cacti Group | spine

1.2.4
-issue#92: Add Data Source ID to "Empty result' error messages
-issue#94: Increase default 'results_buffer' size to 2048 and MySQL max buffer to 131072 bytes

1.2.3
Expand Down
17 changes: 11 additions & 6 deletions poller.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ void poll_host(int host_id, int host_thread, int last_host_thread, int host_data

break;
case POLLER_ACTION_SCRIPT: /* script (popen) */
poll_result = trim(exec_poll(host, reindex->arg1));
poll_result = trim(exec_poll(host, reindex->arg1, reindex->data_query_id, "DQ"));
if (is_debug_device(host->id)) {
SPINE_LOG(("Device[%i] HT[%i] DQ[%i] RECACHE CMD: %s, output: %s", host->id, host_thread, reindex->data_query_id, reindex->arg1, poll_result));
} else {
Expand Down Expand Up @@ -792,7 +792,7 @@ void poll_host(int host_id, int host_thread, int last_host_thread, int host_data
}
poll_result[0] = '\0';

snprintf(poll_result, BUFSIZE, "%d", char_count(exec_poll(host, reindex->arg1), '\n'));
snprintf(poll_result, BUFSIZE, "%d", char_count(exec_poll(host, reindex->arg1, reindex->data_query_id, "DQ"), '\n'));
if (is_debug_device(host->id)) {
SPINE_LOG(("Device[%i] HT[%i] DQ[%i] RECACHE CMD COUNT: %s, output: %s", host->id, host_thread, reindex->data_query_id, reindex->arg1, poll_result));
} else {
Expand Down Expand Up @@ -1333,7 +1333,7 @@ void poll_host(int host_id, int host_thread, int last_host_thread, int host_data

break;
case POLLER_ACTION_SCRIPT: /* execute script file */
poll_result = exec_poll(host, poller_items[i].arg1);
poll_result = exec_poll(host, poller_items[i].arg1, poller_items[i].local_data_id, "DS");

/* process the result */
if (IS_UNDEFINED(poll_result)) {
Expand Down Expand Up @@ -1853,18 +1853,19 @@ int validate_result(char *result) {
return FALSE;
}

/*! \fn char *exec_poll(host_t *current_host, char *command)
/*! \fn char *exec_poll(host_t *current_host, char *command, int id, char *type)
* \brief polls a host using a script
* \param current_host a pointer to the current host structure
* \param command the command to be executed
* \param id either the local_data_id or the data_query_id
*
* This function will poll a specific host using the script pointed to by
* the command variable.
*
* \return a pointer to a character buffer containing the result.
*
*/
char *exec_poll(host_t *current_host, char *command) {
char *exec_poll(host_t *current_host, char *command, int id, char *type) {
extern sem_t active_scripts;
int cmd_fd;
int pid;
Expand Down Expand Up @@ -1993,7 +1994,11 @@ char *exec_poll(host_t *current_host, char *command) {
if (bytes_read > 0) {
result_string[bytes_read] = '\0';
} else {
SPINE_LOG(("Device[%i] ERROR: Empty result [%s]: '%s'", current_host->id, current_host->hostname, command));
if (type == "DS") {
SPINE_LOG(("Device[%i] DS[%i] ERROR: Empty result [%s]: '%s'", current_host->id, id, current_host->hostname, command));
} else {
SPINE_LOG(("Device[%i] DQ[%i] ERROR: Empty result [%s]: '%s'", current_host->id, id, current_host->hostname, command));
}
SET_UNDEFINED(result_string);
}
}
Expand Down
2 changes: 1 addition & 1 deletion poller.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

extern void *child(void *arg);
extern void poll_host(int host_id, int host_thread, int last_host_thread, int host_data_ids, char *host_time, int *host_errors, double host_time_double);
extern char *exec_poll(host_t *current_host, char *command);
extern char *exec_poll(host_t *current_host, char *command, int id, char *type);
extern void get_system_information(host_t *host, MYSQL *mysql, int system);
extern int is_multipart_output(char *result);
extern int validate_result(char *result);

0 comments on commit 5821b81

Please sign in to comment.