Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from netdata:master #378

Merged
merged 4 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ if(ENABLE_LIBUNWIND)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(amd64)")
target_link_libraries(libnetdata PUBLIC PkgConfig::LIBUNWIND -lunwind-x86_64)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?.86")
target_link_libraries(libnetdata PUBLIC PkgCOnfig::LIBUNWIND -lunwind-x86)
target_link_libraries(libnetdata PUBLIC PkgConfig::LIBUNWIND -lunwind-x86)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(aarch64)")
target_link_libraries(libnetdata PUBLIC PkgConfig::LIBUNWIND -lunwind-aarch64)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
Expand Down
4 changes: 3 additions & 1 deletion netdata.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(liblz4)
BuildRequires: pkgconfig(yaml-0.1)
BuildRequires: pkgconfig(json-c)
BuildRequires: pkgconfig(libunwind)
%if %{_have_log2journal}
BuildRequires: pkgconfig(libpcre2-8)
%endif
Expand Down Expand Up @@ -406,7 +407,8 @@ happened, on your systems and applications.
-DENABLE_PLUGIN_SYSTEMD_JOURNAL=On \
-DENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE=On \
-DENABLE_BUNDLED_JSONC=Off \
-DENABLE_BUNDLED_YAML=Off
-DENABLE_BUNDLED_YAML=Off \
-DENABLE_LBIUNWIND=On

# Build step
%{cmake_build}
Expand Down
6 changes: 6 additions & 0 deletions packaging/build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ add_cmake_option ENABLE_BUNDLED_PROTOBUF Off
add_cmake_option ENABLE_BUNDLED_JSONC Off
add_cmake_option ENABLE_BUNDLED_YAML Off

add_cmake_option ENABLE_LIBUNWIND On

add_cmake_option BUILD_FOR_PACKAGING On

case "${PKG_TYPE}" in
Expand All @@ -64,6 +66,10 @@ case "${PKG_TYPE}" in
add_cmake_option ENABLE_PLUGIN_XENSTAT On
add_cmake_option ENABLE_PLUGIN_EBPF Off
;;
armhf)
add_cmake_option ENABLE_PLUGIN_XENSTAT Off
add_cmake_option ENABLE_PLUGIN_EBPF Off
;;
*)
add_cmake_option ENABLE_PLUGIN_XENSTAT Off
add_cmake_option ENABLE_PLUGIN_EBPF Off
Expand Down
1 change: 1 addition & 0 deletions packaging/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ WORKDIR /opt/netdata.git
RUN chmod +x netdata-installer.sh && \
cp -rp /deps/* /usr/local/ && \
/bin/echo -e "INSTALL_TYPE='oci'\nPREBUILT_ARCH='$(uname -m)'" > ./system/.install-type && \
NETDATA_CMAKE_OPTIONS="-DENABLE_LIBUNWIND=On" \
CFLAGS="$(packaging/docker/gen-cflags.sh)" LDFLAGS="-Wl,--gc-sections" ./netdata-installer.sh --dont-wait --dont-start-it --use-system-protobuf \
${EXTRA_INSTALL_OPTS} --disable-ebpf --install-no-prefix / "$([ "$RELEASE_CHANNEL" = stable ] && echo --stable-channel)"

Expand Down
13 changes: 7 additions & 6 deletions src/database/rrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,25 @@ int rrd_init(const char *hostname, struct rrdhost_system_info *system_info, bool
}
}

if(!unittest)
if(!unittest) {
metadata_sync_init();
health_load_config_defaults();
}

localhost = rrdhost_create(
hostname
, registry_get_this_machine_hostname()
, registry_get_this_machine_guid()
, os_type
, registry_get_this_machine_guid()
, os_type
, netdata_configured_timezone
, netdata_configured_abbrev_timezone
, netdata_configured_utc_offset
, program_name
, NETDATA_VERSION
,
nd_profile.update_every, default_rrd_history_entries
, nd_profile.update_every, default_rrd_history_entries
, default_rrd_memory_mode
, health_plugin_enabled()
, stream_send.enabled
, stream_send.enabled
, stream_send.parents.destination
, stream_send.api_key
, stream_send.send_charts_matching
Expand Down
6 changes: 3 additions & 3 deletions src/database/rrdhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ RRDHOST *rrdhost_create(
const char *prog_version,
int update_every,
long entries,
RRD_DB_MODE memory_mode,
RRD_DB_MODE memory_mode,
bool health,
bool stream,
STRING *parents,
Expand Down Expand Up @@ -349,8 +349,8 @@ RRDHOST *rrdhost_create(

rrdhost_init_hostname(host, hostname, false);

host->rrd_history_entries = align_entries_to_pagesize(memory_mode, entries);
host->health.enabled = ((memory_mode == RRD_DB_MODE_NONE)) ? 0 : health;
host->rrd_history_entries = align_entries_to_pagesize(memory_mode, entries);
host->health.enabled = ((memory_mode == RRD_DB_MODE_NONE)) ? false : health;

spinlock_init(&host->receiver_lock);

Expand Down
6 changes: 6 additions & 0 deletions src/go/plugin/go.d/collector/mysql/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,12 @@ func (c *Collector) addInnoDBOSLogCharts() {
}
}

func (c *Collector) addInnoDBOSLogIOChart() {
if err := c.Charts().Add(chartInnoDBOSLogIO.Copy()); err != nil {
c.Warning(err)
}
}

func (c *Collector) addMyISAMCharts() {
if err := c.Charts().Add(*chartsMyISAM.Copy()...); err != nil {
c.Warning(err)
Expand Down
9 changes: 9 additions & 0 deletions src/go/plugin/go.d/collector/mysql/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func (c *Collector) collect() (map[string]int64, error) {

if hasInnodbOSLog(mx) {
c.addInnoDBOSLogOnce.Do(c.addInnoDBOSLogCharts)
} else if hasInnodbOSLogIO(mx) {
// most of Innodb_os_log_* status variables was removed in MariaDB 10.8
// but InnoDB_os_log_written was preserved
c.addInnoDBOSLogOnce.Do(c.addInnoDBOSLogIOChart)
}
if hasInnodbDeadlocks(mx) {
c.addInnodbDeadlocksOnce.Do(c.addInnodbDeadlocksChart)
Expand Down Expand Up @@ -127,6 +131,11 @@ func hasInnodbOSLog(collected map[string]int64) bool {
return ok
}

func hasInnodbOSLogIO(collected map[string]int64) bool {
_, ok := collected["innodb_os_log_written"]
return ok
}

func hasInnodbDeadlocks(collected map[string]int64) bool {
_, ok := collected["innodb_deadlocks"]
return ok
Expand Down
1 change: 1 addition & 0 deletions src/go/plugin/go.d/pkg/iprange/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Range interface {
Family() Family
Contains(ip net.IP) bool
Size() *big.Int
Iterate() iter.Seq[net.IP]
fmt.Stringer
}
```
Expand Down
41 changes: 41 additions & 0 deletions src/go/plugin/go.d/pkg/iprange/iterator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-or-later

package iprange

import (
"iter"
"net"
)

func iterate(r Range) iter.Seq[net.IP] {
ipCopy := make(net.IP, len(r.getStart()))
nextBuf := make(net.IP, len(r.getStart()))

return func(yield func(net.IP) bool) {
for ip := r.getStart(); ip != nil; ip = nextIP(ip, nextBuf) {
copy(ipCopy, ip)
if !yield(ipCopy) {
return
}
if ip.Equal(r.getEnd()) {
break
}
}
}
}

func nextIP(ip net.IP, buf net.IP) net.IP {
ip = ip.To16()
if ip == nil {
return nil
}
copy(buf, ip)

for i := len(buf) - 1; i >= 0; i-- {
buf[i]++
if buf[i] != 0 {
break
}
}
return buf
}
19 changes: 19 additions & 0 deletions src/go/plugin/go.d/pkg/iprange/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package iprange
import (
"bytes"
"fmt"
"iter"
"math/big"
"net"
)
Expand All @@ -24,7 +25,11 @@ type Range interface {
Family() Family
Contains(ip net.IP) bool
Size() *big.Int
Iterate() iter.Seq[net.IP]
fmt.Stringer

getStart() net.IP
getEnd() net.IP
}

// New returns new IP Range.
Expand All @@ -45,6 +50,13 @@ type v4Range struct {
end net.IP
}

func (r v4Range) getStart() net.IP { return r.start }
func (r v4Range) getEnd() net.IP { return r.end }

func (r v4Range) Iterate() iter.Seq[net.IP] {
return iterate(r)
}

// String returns the string form of the range.
func (r v4Range) String() string {
return fmt.Sprintf("%s-%s", r.start, r.end)
Expand All @@ -70,6 +82,13 @@ type v6Range struct {
end net.IP
}

func (r v6Range) getStart() net.IP { return r.start }
func (r v6Range) getEnd() net.IP { return r.end }

func (r v6Range) Iterate() iter.Seq[net.IP] {
return iterate(r)
}

// String returns the string form of the range.
func (r v6Range) String() string {
return fmt.Sprintf("%s-%s", r.start, r.end)
Expand Down
46 changes: 46 additions & 0 deletions src/go/plugin/go.d/pkg/iprange/range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ func TestV4Range_Contains(t *testing.T) {
}
}

func TestV4Range_Iterate(t *testing.T) {
tests := map[string]struct {
input string
}{
"Single IP": {input: "192.0.2.0"},
"IP range": {input: "192.0.2.0-192.0.2.10"},
"IP CIDR": {input: "192.0.2.0/24"},
}

for name, test := range tests {
t.Run(name, func(t *testing.T) {
r, err := ParseRange(test.input)
require.NoError(t, err)

var n int64
for range r.Iterate() {
n++
}
assert.Equal(t, r.Size().Int64(), n)
})
}
}

func TestV6Range_String(t *testing.T) {
tests := map[string]struct {
input string
Expand Down Expand Up @@ -198,3 +221,26 @@ func TestV6Range_Contains(t *testing.T) {
})
}
}

func TestV6Range_Iterate(t *testing.T) {
tests := map[string]struct {
input string
}{
"Single IP": {input: "2001:db8::5"},
"IP range": {input: "2001:db8::-2001:db8::10"},
"IP CIDR": {input: "2001:db8::/124"},
}

for name, test := range tests {
t.Run(name, func(t *testing.T) {
r, err := ParseRange(test.input)
require.NoError(t, err)

var n int64
for range r.Iterate() {
n++
}
assert.Equal(t, r.Size().Int64(), n)
})
}
}
6 changes: 5 additions & 1 deletion src/health/health.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ void health_plugin_disable(void) {
}


static void health_load_config_defaults(void) {
void health_load_config_defaults(void) {
static bool done = false;
if(done) return;
done = true;

char filename[FILENAME_MAX + 1];

health_globals.config.enabled =
Expand Down
2 changes: 2 additions & 0 deletions src/health/health.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,6 @@ uint64_t health_evloop_current_iteration(void);
void rrdhost_set_health_evloop_iteration(RRDHOST *host);
uint64_t rrdhost_health_evloop_last_iteration(RRDHOST *host);

void health_load_config_defaults(void);

#endif //NETDATA_HEALTH_H
Loading