How to manage Netdata installation on Mac (reclaim)?

Hi, I am familiar with some Linux distros as well as Unix. But I always skipped OSX (Mac).

Could anybody assist how to manage Netdata agent at MacOS?

I installed Netdata using brew. Then I tried to claim a node. First I realized that netdata-claim.sh does not exist at usual location, so I copied it from another linux server :man_facepalming::

sudo ./netdata-claim.sh -token=TKN -room=RM -url=https://app.netdata.cloud
Unable to communicate with Netdata daemon, querying config from disk instead.
Token: ****************
Base URL: https://app.netdata.cloud
...
Connection attempt 1 successful
./netdata-claim.sh: line 404: /usr/sbin/netdatacli: No such file or directory
The claim was successful but the agent could not be notified (0)- it requires a restart to connect to the cloud.

Then I found a useful command to determine where Netdata files are located on Mac:

brew list netdata

...
/opt/homebrew/Cellar/netdata/1.29.3/homebrew.mxcl.netdata.plist
...
/opt/homebrew/Cellar/netdata/1.29.3/sbin/netdata
/opt/homebrew/Cellar/netdata/1.29.3/sbin/netdata-claim.sh
/opt/homebrew/Cellar/netdata/1.29.3/sbin/netdatacli
...

Next I wanted to unclaim the node (it appeared in cloud with unreacheable status) to repeat the claiming again. I removed the folder:

sudo rm -rf /var/lib/netdata/cloud.d

Somewhere I read how to restart macos service and tried the command:

sudo launchctl load -w /opt/homebrew/Cellar/netdata/1.29.3/homebrew.mxcl.netdata.plist
/opt/homebrew/Cellar/netdata/1.29.3/homebrew.mxcl.netdata.plist: Path had bad ownership/permissions
Load failed: 122: Path had bad ownership/permissions

sudo launchctl unload /opt/homebrew/Cellar/netdata/1.29.3/homebrew.mxcl.netdata.plist
/opt/homebrew/Cellar/netdata/1.29.3/homebrew.mxcl.netdata.plist: Could not find specified service
Unload failed: 113: Could not find specified service

# Command `sudo launchctl list | grep netdata` show nothing.

At the result I think I have Netdata agent installed but I don’t know how to manage the service. Please advise.

Hi @ivan

Currently, the most reliable way to have cloud support for Mac is to install the agent from source as described in Install Netdata on macOS | Learn Netdata.

After installation you can use the claim script found under /usr/local/netdata/usr/sbin.

Best,

Kostas

Thanks @Kostas_Kaskavelis .

I chosen brew because of unfulfilled prerequisities of the script. First error pointed to missing openssl (which actually was installed at different folder). I modified netdata-installer.sh with:

/opt/homebrew/opt/openssl
# instead of 
/usr/local/opt/openssl

Now I get a message that libuv is missed. But it is installed. I cannot fix it.

checking operating system... macos with id 3
...
checking for uv_fs_scandir_next in -luv... no
configure: error: libuv required but not found. Try installing 'libuv1-dev' or 'libuv-devel'.
 FAILED

brew install libuv
...
Warning: libuv 1.41.0 is already installed and up-to-date.
To reinstall 1.41.0, run:
  brew reinstall libuv

You are working I guess on an M1 Mac then? Just asking due to different paths in that case which may justify this.

Exactly M1 Mac. Thanks!

Ok then, we are aware of such problems with M1 Macs, I will follow up & come back on this as soon as we have news.
Thanks!

1 Like

Just to clarify, the command to manage netdata service on M1 Mac is

brew services start | restart | stop netdata

So, I tried to reinstall it using brew:

brew install netdata
# To have launchd start netdata now and restart at login:
brew services start netdata
# Or, if you don't want/need a background service you can just run:
#  /opt/homebrew/sbin/netdata -D

brew services restart netdata
==> Successfully started `netdata` (label: homebrew.mxcl.netdata)

The agent has been installed. Next I found the location of netdata-claim.sh

brew list netdata
...
/opt/homebrew/Cellar/netdata/1.29.3/sbin/netdata-claim.sh

Used the full path to the script I tried to claim the node:

sudo /opt/homebrew/Cellar/netdata/1.29.3/sbin/netdata-claim.sh -token=TKN -rooms=RM -url=https://app.netdata.cloud
This agent was built without the dependencies for Cloud and cannot be claimed

The message sais that agent from brew cannot be claimed, right?

Just to give an update to this, they are two distinct subjects.

  1. Netdata support (including cloud) for Mac with M1 chips. This is a known compatibility issue that we have and working on a fix. The best estimation is that it’s not gonna come very soon though, needing at least 2-4 weeks from now.
  2. Brew installation & cloud support. We are not actually maintaining the brew package (see here for more details). However it is as well something we can improve.

Best,

Kostas

1 Like

Hi Ivan! Kostas_Kaskavelis is spot on, we’re working on the support for M1 macs.

In the meantime, until we get proper support on our build system, if you’re feeling “hacky” :slight_smile: can you try to build from a (somewhat latest) source using:

CFLAGS="-I /opt/homebrew/include/ -I /opt/homebrew/opt/openssl@1.1/include/" LDFLAGS="-L /opt/homebrew/lib/ -L/opt/homebrew/opt/openssl@1.1/lib/" ./netdata-installer.sh --aclk-ng --install /Some/local/path/netdata/

You should then be able to claim it to the cloud. We’ll be interested in your results !

Thanks!

Hi @Manolis_Vasilakis thank you very much for this!

I’ve just tried but no success. Probably I missed something? I run with sudo and even added path to libuv folder.

Finally:

Full log:

Also I tried:

sudo CFLAGS="-DUV_INCLUDE_DIR=/opt/homebrew/Cellar/libuv/1.41.0/include/ -DUV_LIBRARY=/opt/homebrew/Cellar/libuv/1.41.0/lib/ -I /opt/homebrew/include/ -I /opt/homebrew/opt/openssl@1.1/include/" LDFLAGS="-L /opt/homebrew/lib/ -L /opt/homebrew/opt/openssl@1.1/lib/" ./netdata-installer.sh --aclk-ng --install /opt

No chance :thinking:

Hmm, thanks ivan!

That’s strange… what I’ve noticed is that at line 458 of your pastebin, it doesn’t include in the LDFLAGS /opt/homebrew/lib/ so, then it fails to link it…

Can you please paste the output of brew config ? Thanks!!

netdata % brew config
HOMEBREW_VERSION: 3.1.11
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9657303ed2c484a4bd8f7527706940f9e4d43354
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: b266534ef05dee66e83051f7dc3479fdbaabff8e
Core tap last commit: 2 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0.5 build 1205
Git: 2.30.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.3.1-arm64
CLT: 12.5.0.22.9
Xcode: 12.5
Rosetta 2: false
uname -a
Darwin MacMiniTlt.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:41 PDT 2021; root:xnu-7195.101.2~1/RELEASE_ARM64_T8101 arm64

I am not familiar with OSX/BSD systems, so navigate me please how to get useful info from this Mac :slight_smile:

Me too, but we’ll find it… :slight_smile:

Ok, next check, do you by any chance have any custom environmental variables, like $LIBRARY_PATH or $LD_LIBRARY_PATH ? (You can find out if you do e.g. echo $LIBRARY_PATH).

Thanks!!

No I don’t. I just added wget and unzip to the PATH. This machine is used in continuous integration (Gitlab CI)

Mobile@MacMiniTlt ~ % env
USER=Mobile
LOGNAME=Mobile
HOME=/Users/Mobile
PATH=/opt/homebrew/opt/wget/bin:/opt/homebrew/opt/unzip/bin:/opt/homebrew/bin:/Users/Mobile/.nvm/versions/node/v16.0.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
SHELL=/bin/zsh
TERM=xterm
SSH_TTY=/dev/ttys000
TMPDIR=/var/folders/w3/53zp3wn550qfttznwwvs46c40000gr/T/
SHLVL=1
PWD=/Users/Mobile
OLDPWD=/Users/Mobile
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
NVM_DIR=/Users/Mobile/.nvm
NVM_CD_FLAGS=-q
NVM_BIN=/Users/Mobile/.nvm/versions/node/v16.0.0/bin
NVM_INC=/Users/Mobile/.nvm/versions/node/v16.0.0/include/node
_=/usr/bin/env

Hi Ivan! Perhaps sudo messes up with paths, can you please try without sudo? (That though will require to specify a local install path, i.e. /Users/xxxx/netdata).

Thank you for your patience! Your input here will help us streamline installation of netdata on macs!

Hi Manolis, thanks for your interest! Actually the issue with Mac is not very important for me.

Previously I forgot to clarify that env output is almost the same both from user and from root. There is no $LIBRARY_PATH in both envs.

I tried to run the command from user:

CFLAGS="-DUV_INCLUDE_DIR=/opt/homebrew/Cellar/libuv/1.41.0/include/ \
-DUV_LIBRARY=/opt/homebrew/Cellar/libuv/1.41.0/lib/ \
-I /opt/homebrew/include/ -I /opt/homebrew/opt/openssl@1.1/include/" \
LDFLAGS="-L /opt/homebrew/lib/ -L /opt/homebrew/opt/openssl@1.1/lib/" \
./netdata-installer.sh --aclk-ng --install /Users/Mobile

Trying to work around libuv issue I added -DUV_INCLUDE_DIR and -DUV_LIBRARY as explained here.

The output is available here: