summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-10 20:12:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-10 20:12:12 +0000
commit1b5b13047cfe151692fd3ece47bd1e01d25773e6 (patch)
tree847f1dd98d02de98b7e4bbd0ca8042a1c3e44408 /src
parentReleasing debian version 1.47.0-1. (diff)
downloadnetdata-1b5b13047cfe151692fd3ece47bd1e01d25773e6.tar.xz
netdata-1b5b13047cfe151692fd3ece47bd1e01d25773e6.zip
Merging upstream version 1.47.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src')
-rw-r--r--src/daemon/commands.c28
-rw-r--r--src/database/sqlite/sqlite_aclk.c30
-rw-r--r--src/database/sqlite/sqlite_aclk_alert.c17
-rw-r--r--src/database/sqlite/sqlite_health.c4
-rw-r--r--src/go/plugin/go.d/agent/vnodes/vnodes.go30
-rw-r--r--src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go4
-rw-r--r--src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go10
-rw-r--r--src/go/plugin/go.d/modules/storcli/collect_drives.go24
-rw-r--r--src/libnetdata/gorilla/gorilla.cc7
-rw-r--r--src/streaming/receiver.c26
10 files changed, 113 insertions, 67 deletions
diff --git a/src/daemon/commands.c b/src/daemon/commands.c
index 230e8527e..f0637ad31 100644
--- a/src/daemon/commands.c
+++ b/src/daemon/commands.c
@@ -112,32 +112,32 @@ static cmd_status_t cmd_help_execute(char *args, char **message)
*message = mallocz(MAX_COMMAND_LENGTH);
strncpyz(*message,
- "\nThe commands are (arguments are in brackets):\n"
+ "\nThe commands are:\n\n"
"help\n"
- " Show this help menu.\n"
+ " Show this help menu.\n\n"
"reload-health\n"
- " Reload health configuration.\n"
+ " Reload health configuration.\n\n"
"reload-labels\n"
- " Reload all labels.\n"
+ " Reload all labels.\n\n"
"save-database\n"
- " Save internal DB to disk for memory mode save.\n"
+ " Save internal DB to disk for memory mode save.\n\n"
"reopen-logs\n"
- " Close and reopen log files.\n"
+ " Close and reopen log files.\n\n"
"shutdown-agent\n"
- " Cleanup and exit the netdata agent.\n"
+ " Cleanup and exit the netdata agent.\n\n"
"fatal-agent\n"
- " Log the state and halt the netdata agent.\n"
+ " Log the state and halt the netdata agent.\n\n"
"reload-claiming-state\n"
- " Reload agent claiming state from disk.\n"
+ " Reload agent claiming state from disk.\n\n"
"ping\n"
- " Return with 'pong' if agent is alive.\n"
+ " Return with 'pong' if agent is alive.\n\n"
"aclk-state [json]\n"
- " Returns current state of ACLK and Cloud connection. (optionally in json).\n"
+ " Returns current state of ACLK and Cloud connection. (optionally in json).\n\n"
"dumpconfig\n"
- " Returns the current netdata.conf on stdout.\n"
+ " Returns the current netdata.conf on stdout.\n\n"
#ifdef ENABLE_ACLK
- "remove-stale-node node_id|machine_guid|hostname|ALL_NODES\n"
- " Unregisters and removes a node from the cloud.\n"
+ "remove-stale-node <node_id | machine_guid | hostname | ALL_NODES>\n"
+ " Unregisters and removes a node from the cloud.\n\n"
#endif
"version\n"
" Returns the netdata version.\n",
diff --git a/src/database/sqlite/sqlite_aclk.c b/src/database/sqlite/sqlite_aclk.c
index 027ee8f93..adbe4d9d3 100644
--- a/src/database/sqlite/sqlite_aclk.c
+++ b/src/database/sqlite/sqlite_aclk.c
@@ -199,6 +199,34 @@ fail:
buffer_free(sql);
}
+#define SQL_INVALIDATE_HOST_LAST_CONNECTED "UPDATE host SET last_connected = 1 WHERE host_id = @host_id"
+
+static void invalidate_host_last_connected(nd_uuid_t *host_uuid)
+{
+ sqlite3_stmt *res = NULL;
+ if (!host_uuid)
+ return;
+
+ if (!PREPARE_STATEMENT(db_meta, SQL_INVALIDATE_HOST_LAST_CONNECTED, &res))
+ return;
+
+ int param = 0;
+ SQLITE_BIND_FAIL(bind_fail, sqlite3_bind_blob(res, ++param, host_uuid, sizeof(*host_uuid), SQLITE_STATIC));
+
+ param = 0;
+ int rc = sqlite3_step_monitored(res);
+ if (unlikely(rc != SQLITE_DONE)) {
+ char wstr[UUID_STR_LEN];
+ uuid_unparse_lower(*host_uuid, wstr);
+ error_report("Failed invalidate last_connected time for host with GUID %s, rc = %d", wstr, rc);
+ }
+
+bind_fail:
+ REPORT_BIND_FAIL(res, param);
+ SQLITE_FINALIZE(res);
+}
+
+
// OPCODE: ACLK_DATABASE_NODE_UNREGISTER
static void sql_unregister_node(char *machine_guid)
{
@@ -226,6 +254,7 @@ static void sql_unregister_node(char *machine_guid)
error_report("Failed to execute command to remove host node id");
} else {
// node: machine guid will be freed after processing
+ invalidate_host_last_connected(&host_uuid);
metadata_delete_host_chart_labels(machine_guid);
machine_guid = NULL;
}
@@ -329,7 +358,6 @@ static void aclk_synchronization(void *arg)
break;
case ACLK_DATABASE_NODE_UNREGISTER:
sql_unregister_node(cmd.param[0]);
-
break;
// ALERTS
case ACLK_DATABASE_PUSH_ALERT_CONFIG:
diff --git a/src/database/sqlite/sqlite_aclk_alert.c b/src/database/sqlite/sqlite_aclk_alert.c
index 3e7076169..dbe5a5045 100644
--- a/src/database/sqlite/sqlite_aclk_alert.c
+++ b/src/database/sqlite/sqlite_aclk_alert.c
@@ -488,10 +488,9 @@ done:
freez(claim_id);
}
-#define SQL_DELETE_PROCESSED_ROWS \
- "DELETE FROM alert_queue WHERE host_id = @host_id AND rowid between @row1 AND @row2"
+#define SQL_DELETE_PROCESSED_ROWS "DELETE FROM alert_queue WHERE host_id = @host_id AND rowid = @row"
-static void delete_alert_from_pending_queue(RRDHOST *host, int64_t row1, int64_t row2)
+static void delete_alert_from_pending_queue(RRDHOST *host, int64_t row)
{
static __thread sqlite3_stmt *res = NULL;
@@ -500,8 +499,7 @@ static void delete_alert_from_pending_queue(RRDHOST *host, int64_t row1, int64_t
int param = 0;
SQLITE_BIND_FAIL(done, sqlite3_bind_blob(res, ++param, &host->host_uuid, sizeof(host->host_uuid), SQLITE_STATIC));
- SQLITE_BIND_FAIL(done, sqlite3_bind_int64(res, ++param, row1));
- SQLITE_BIND_FAIL(done, sqlite3_bind_int64(res, ++param, row2));
+ SQLITE_BIND_FAIL(done, sqlite3_bind_int64(res, ++param, row));
param = 0;
int rc = sqlite3_step_monitored(res);
@@ -571,8 +569,6 @@ bool process_alert_pending_queue(RRDHOST *host)
SQLITE_BIND_FAIL(done, sqlite3_bind_blob(res, ++param, &host->host_uuid, sizeof(host->host_uuid), SQLITE_STATIC));
param = 0;
- int64_t start_row = 0;
- int64_t end_row = 0;
while (sqlite3_step_monitored(res) == SQLITE_ROW) {
int64_t health_log_id = sqlite3_column_int64(res, 0);
@@ -586,16 +582,11 @@ bool process_alert_pending_queue(RRDHOST *host)
added++;
}
- if (!start_row)
- start_row = row;
- end_row = row;
+ delete_alert_from_pending_queue(host, row);
count++;
}
- if (start_row)
- delete_alert_from_pending_queue(host, start_row, end_row);
-
if(count)
nd_log(NDLS_ACCESS, NDLP_NOTICE, "ACLK STA [%s (N/A)]: Processed %d entries, queued %d", rrdhost_hostname(host), count, added);
done:
diff --git a/src/database/sqlite/sqlite_health.c b/src/database/sqlite/sqlite_health.c
index a632fd494..9304c8c73 100644
--- a/src/database/sqlite/sqlite_health.c
+++ b/src/database/sqlite/sqlite_health.c
@@ -437,12 +437,10 @@ static void sql_inject_removed_status(
int64_t health_log_id = sqlite3_column_int64(res, 0);
RRDCALC_STATUS old_status = (RRDCALC_STATUS)sqlite3_column_double(res, 1);
insert_alert_queue(
- host, health_log_id, (int64_t)unique_id, (int64_t)alarm_id, old_status, RRDCALC_STATUS_REMOVED);
+ host, health_log_id, (int64_t)max_unique_id, (int64_t)alarm_id, old_status, RRDCALC_STATUS_REMOVED);
}
#endif
}
- //else
- // error_report("HEALTH [N/A]: Failed to execute SQL_INJECT_REMOVED, rc = %d", rc);
done:
REPORT_BIND_FAIL(res, param);
diff --git a/src/go/plugin/go.d/agent/vnodes/vnodes.go b/src/go/plugin/go.d/agent/vnodes/vnodes.go
index 9272f1514..3d332c261 100644
--- a/src/go/plugin/go.d/agent/vnodes/vnodes.go
+++ b/src/go/plugin/go.d/agent/vnodes/vnodes.go
@@ -61,11 +61,39 @@ func (vn *Vnodes) readConfDir() {
return nil
}
- if !d.Type().IsRegular() || !isConfigFile(path) {
+ if d.Type()&os.ModeSymlink != 0 {
+ dst, err := os.Readlink(path)
+ if err != nil {
+ vn.Warningf("failed to resolve symlink '%s': %v", path, err)
+ return nil
+ }
+
+ if !filepath.IsAbs(dst) {
+ dst = filepath.Join(filepath.Dir(path), filepath.Clean(dst))
+ }
+
+ fi, err := os.Stat(dst)
+ if err != nil {
+ vn.Warningf("failed to stat resolved path '%s': %v", dst, err)
+ return nil
+ }
+ if !fi.Mode().IsRegular() {
+ vn.Debugf("'%s' is not a regular file, skipping it", dst)
+ return nil
+ }
+ path = dst
+ } else if !d.Type().IsRegular() {
+ vn.Debugf("'%s' is not a regular file, skipping it", path)
+ return nil
+ }
+
+ if !isConfigFile(path) {
+ vn.Debugf("'%s' is not a config file (wrong extension), skipping it", path)
return nil
}
var cfg []VirtualNode
+
if err := loadConfigFile(&cfg, path); err != nil {
vn.Warning(err)
return nil
diff --git a/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go b/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go
index 16e0f17d0..a5774ae4a 100644
--- a/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go
+++ b/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go
@@ -193,6 +193,10 @@ func TestDnsmasqDHCP_parseDHCPRangeValue(t *testing.T) {
wantFail: true,
input: "1234::,ra-stateless",
},
+ "invalid": {
+ wantFail: true,
+ input: "192.168.0.0",
+ },
}
for name, test := range tests {
diff --git a/src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go b/src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go
index 558ce7c65..5ef29f28e 100644
--- a/src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go
+++ b/src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go
@@ -108,14 +108,12 @@ func parseDHCPRangeValue(s string) (r string) {
var start, end net.IP
parts := strings.Split(s, ",")
- for i, v := range parts {
- if start = net.ParseIP(strings.TrimSpace(v)); start == nil {
+ for _, v := range parts {
+ if start == nil {
+ start = net.ParseIP(v)
continue
}
- if len(parts) < i+1 {
- return ""
- }
- if end = net.ParseIP(parts[i+1]); end == nil || iprange.New(start, end) == nil {
+ if end = net.ParseIP(v); end == nil || iprange.New(start, end) == nil {
return ""
}
return fmt.Sprintf("%s-%s", start, end)
diff --git a/src/go/plugin/go.d/modules/storcli/collect_drives.go b/src/go/plugin/go.d/modules/storcli/collect_drives.go
index 5c2ecb387..95965d572 100644
--- a/src/go/plugin/go.d/modules/storcli/collect_drives.go
+++ b/src/go/plugin/go.d/modules/storcli/collect_drives.go
@@ -23,18 +23,18 @@ type drivesInfoResponse struct {
type (
driveInfo struct {
EIDSlt string `json:"EID:Slt"`
- DID int `json:"DID"`
- State string `json:"State"`
- DG int `json:"DG"`
- Size string `json:"Size"`
- Intf string `json:"Intf"`
- Med string `json:"Med"`
- SED string `json:"SED"`
- PI string `json:"PI"`
- SeSz string `json:"SeSz"`
- Model string `json:"Model"`
- Sp string `json:"Sp"`
- Type string `json:"Type"`
+ //DID int `json:"DID"`
+ //State string `json:"State"`
+ //DG int `json:"DG"` // FIX: can be integer or "-"
+ //Size string `json:"Size"`
+ //Intf string `json:"Intf"`
+ Med string `json:"Med"`
+ //SED string `json:"SED"`
+ //PI string `json:"PI"`
+ //SeSz string `json:"SeSz"`
+ //Model string `json:"Model"`
+ //Sp string `json:"Sp"`
+ //Type string `json:"Type"`
}
driveState struct {
MediaErrorCount storNumber `json:"Media Error Count"`
diff --git a/src/libnetdata/gorilla/gorilla.cc b/src/libnetdata/gorilla/gorilla.cc
index c76018365..e3d612418 100644
--- a/src/libnetdata/gorilla/gorilla.cc
+++ b/src/libnetdata/gorilla/gorilla.cc
@@ -162,10 +162,11 @@ bool gorilla_writer_write(gorilla_writer_t *gw, uint32_t number)
__atomic_fetch_add(&hdr->nbits, 1, __ATOMIC_RELAXED);
if (!is_xor_lzc_same) {
- if (hdr->nbits + 1 >= gw->capacity)
+ size_t bits_needed = (bit_size<uint32_t>() == 32) ? 5 : 6;
+ if ((hdr->nbits + bits_needed) >= gw->capacity)
return false;
- bit_buffer_write(data, hdr->nbits, xor_lzc, (bit_size<uint32_t>() == 32) ? 5 : 6);
- __atomic_fetch_add(&hdr->nbits, (bit_size<uint32_t>() == 32) ? 5 : 6, __ATOMIC_RELAXED);
+ bit_buffer_write(data, hdr->nbits, xor_lzc, bits_needed);
+ __atomic_fetch_add(&hdr->nbits, bits_needed, __ATOMIC_RELAXED);
}
// write the bits of the XOR'd value without the LZC prefix
diff --git a/src/streaming/receiver.c b/src/streaming/receiver.c
index 50da031a7..0c0da2121 100644
--- a/src/streaming/receiver.c
+++ b/src/streaming/receiver.c
@@ -6,19 +6,6 @@
extern struct config stream_config;
void receiver_state_free(struct receiver_state *rpt) {
-
- freez(rpt->key);
- freez(rpt->hostname);
- freez(rpt->registry_hostname);
- freez(rpt->machine_guid);
- freez(rpt->os);
- freez(rpt->timezone);
- freez(rpt->abbrev_timezone);
- freez(rpt->client_ip);
- freez(rpt->client_port);
- freez(rpt->program_name);
- freez(rpt->program_version);
-
#ifdef ENABLE_HTTPS
netdata_ssl_close(&rpt->ssl);
#endif
@@ -31,10 +18,21 @@ void receiver_state_free(struct receiver_state *rpt) {
rrdpush_decompressor_destroy(&rpt->decompressor);
if(rpt->system_info)
- rrdhost_system_info_free(rpt->system_info);
+ rrdhost_system_info_free(rpt->system_info);
__atomic_sub_fetch(&netdata_buffers_statistics.rrdhost_receivers, sizeof(*rpt), __ATOMIC_RELAXED);
+ freez(rpt->key);
+ freez(rpt->hostname);
+ freez(rpt->registry_hostname);
+ freez(rpt->machine_guid);
+ freez(rpt->os);
+ freez(rpt->timezone);
+ freez(rpt->abbrev_timezone);
+ freez(rpt->client_ip);
+ freez(rpt->client_port);
+ freez(rpt->program_name);
+ freez(rpt->program_version);
freez(rpt);
}