これまで OpenWRT ルータや仮想マシンDNSサーバへ個別にインストールしたリアルタイム 監視ツール Netdata を、そのクラウドサービス Netdata Cloud へ登録して、どこからでも複数のデバイスを一元監視できるようにしました。
Netdata Cloud無償アカウント作成
Netdataのクラウドサービスは有償と無償とがあるのですが、無償でも制限らしい制限がないので思いっきり遊べます。
ページ右上の Sign up をクリックしてユーザ登録します。
当初、メールアドレスでアカウントを作成したものの、2回目以降のログイン認証がメールではうまく行かなかったので、Googleアカウントで作り直しました。アプリ連携でよくある初回のGoogleからの認証を許可すれば、以降もシングルサインオンすることができます。
いずれの場合でも、Netdata Cloudのアカウントにはパスワードが存在しないというのは、独特のシステムポリシーなのでしょう。
1台目のデバイスを登録
ログイン直後は、まだ何もNodeの無い空っぽの状態。
Add Nodes の緑色のボタンを見つけてクリックすると、各プラットフォーム向けにNode追加用のスクリプトが用意されています。
早速、以前Alpine LinuxのUnbound DNSサーバにインストールしたNetdataを、Netdata Cloudへ登録してみます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
$ wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh \ --claim-token ######################################################################################## \ --claim-url https://app.netdata.cloud Connecting to my-netdata.io (172.67.156.192:443) saving to '/tmp/netdata-kickstart.sh' netdata-kickstart.sh 100% |*********************************************************| 82038 0:00:00 ETA '/tmp/netdata-kickstart.sh' saved --- Using /tmp/netdata-kickstart-XXXXALAACM as a temporary directory. --- --- Checking for existing installations of Netdata... --- Root privileges required to run sh -c cat "//etc/netdata/.install-type" > "/tmp/netdata-kickstart-XXXXALAACM/install-type" [/tmp/netdata-kickstart-XXXXALAACM]$ sudo sh -c cat "//etc/netdata/.install-type" > "/tmp/netdata-kickstart-XXXXALAACM/install-type" [sudo] password for user: OK --- Attempting to claim existing install at /. --- --- Attempting to claim agent to https://app.netdata.cloud --- --- Attempting to claim agent to https://app.netdata.cloud --- 9367 9372 9516 9520 Root privileges required to run /usr/sbin/netdata-claim.sh -token=####################### -rooms= -url=https://app.netdata.cloud [/tmp/netdata-kickstart-XXXXALAACM]$ sudo /usr/sbin/netdata-claim.sh -token=###################################### -rooms= -url=https://app.netdata.cloud Token: **************** Base URL: https://app.netdata.cloud Id: ################################### Rooms: Hostname: resolv9 Proxy: Netdata user: netdata Generating private/public key for the first time. Extracting public key from private key. writing RSA key Connection attempt 1 successful Node was successfully claimed. OK --- Successfully claimed node --- Root privileges required to run rm -rf /tmp/netdata-kickstart-XXXXALAACM [/home/user]$ sudo rm -rf /tmp/netdata-kickstart-XXXXALAACM OK |
実行後ほどなく、Netdata Cloudへ1つ目のNodeが登録されていました。
Alpine Linux版Netdataを最新版に
追加されたNodeについてよく見ると、Netdataの動作バージョンに関するアラートが出ています。本記事執筆当時のNetdata現行版はv1.37.1に対して、Alpine Linux v3.17のCommunityレポジトリに収録されているNetdataパッケージがv1.36.1なのがその理由です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
$ netdata -W buildinfo Version: netdata v1.36.1 Configure options: '--prefix=/usr' '--sysconfdir=/etc' '--localstatedir=/var' '--with-zlib' '--with-math' '--enable-https' '--with-webdir=/usr/share/webapps/netdata' '--with-user=netdata' 'CC=gcc' 'CFLAGS=-Os -fomit-frame-pointer' 'LDFLAGS=-Wl,--as-needed,-O1,--sort-common' 'CPPFLAGS=-Os -fomit-frame-pointer' 'CXX=g++' 'CXXFLAGS=-Os -fomit-frame-pointer' Install type: custom Features: dbengine: YES Native HTTPS: YES Netdata Cloud: YES ACLK Next Generation: YES ACLK-NG New Cloud Protocol: YES ACLK Legacy: NO TLS Host Verification: YES Machine Learning: YES Stream Compression: YES Libraries: protobuf: YES (system) jemalloc: NO JSON-C: YES libcap: YES libcrypto: YES libm: YES tcalloc: NO zlib: YES Plugins: apps: YES cgroup Network Tracking: YES CUPS: NO EBPF: NO IPMI: NO NFACCT: NO perf: YES slabinfo: YES Xen: NO Xen VBD Error Tracking: NO Exporters: AWS Kinesis: NO GCP PubSub: NO MongoDB: NO Prometheus Remote Write: NO |
このままでも動作に問題はありませんが、Edgeブランチを参照すると最新版が収録されているようなので、
パッケージマネージャのレポジトリ設定を編集して、Edgeブランチを有効にした上で、パッケージを更新してみました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
$ sudo vi /etc/apk/repositories $ cat /etc/apk/repositories #/media/cdrom/apks http://ftp.udx.icscoe.jp/Linux/alpine/v3.17/main http://ftp.udx.icscoe.jp/Linux/alpine/v3.17/community #http://ftp.udx.icscoe.jp/Linux/alpine/edge/main http://ftp.udx.icscoe.jp/Linux/alpine/edge/community #http://ftp.udx.icscoe.jp/Linux/alpine/edge/testing $ sudo apk update fetch http://ftp.udx.icscoe.jp/Linux/alpine/v3.17/main/x86_64/APKINDEX.tar.gz fetch http://ftp.udx.icscoe.jp/Linux/alpine/v3.17/community/x86_64/APKINDEX.tar.gz fetch http://ftp.udx.icscoe.jp/Linux/alpine/edge/community/x86_64/APKINDEX.tar.gz v3.17.1-200-g1154cd7c59a [http://ftp.udx.icscoe.jp/Linux/alpine/v3.17/main] v3.17.1-200-g1154cd7c59a [http://ftp.udx.icscoe.jp/Linux/alpine/v3.17/community] v20230208-134-g2e6603fbd0 [http://ftp.udx.icscoe.jp/Linux/alpine/edge/community] OK: 29536 distinct packages available $ sudo apk upgrade (1/26) Upgrading libcrypto3 (3.0.7-r2 -> 3.0.8-r0) (2/26) Upgrading libssl3 (3.0.7-r2 -> 3.0.8-r0) (3/26) Upgrading bind-libs (9.18.10-r0 -> 9.18.11-r0) (4/26) Upgrading bind-tools (9.18.10-r0 -> 9.18.11-r0) (5/26) Upgrading linux-virt (5.15.88-r0 -> 5.15.93-r0) (6/26) Upgrading netdata (1.36.1-r0 -> 1.38.0-r0) (7/26) Upgrading netdata-openrc (1.36.1-r0 -> 1.38.0-r0) (8/26) Upgrading netdata-go-plugins (0.50.0-r0 -> 0.50.0-r1) (9/26) Upgrading glib (2.74.4-r0 -> 2.74.5-r0) (10/26) Upgrading open-vm-tools (12.1.0-r0 -> 12.1.5-r0) Executing open-vm-tools-12.1.5-r0.post-upgrade (11/26) Upgrading open-vm-tools-openrc (12.1.0-r0 -> 12.1.5-r0) (13/26) Upgrading open-vm-tools-deploypkg (12.1.0-r0 -> 12.1.5-r0) (14/26) Upgrading open-vm-tools-guestinfo (12.1.0-r0 -> 12.1.5-r0) (15/26) Upgrading openssh-keygen (9.1_p1-r1 -> 9.1_p1-r2) (16/26) Upgrading openssh-client-common (9.1_p1-r1 -> 9.1_p1-r2) (17/26) Upgrading openssh-client-default (9.1_p1-r1 -> 9.1_p1-r2) (18/26) Upgrading openssh-sftp-server (9.1_p1-r1 -> 9.1_p1-r2) (19/26) Upgrading openssh-server-common (9.1_p1-r1 -> 9.1_p1-r2) (20/26) Upgrading openssh-server (9.1_p1-r1 -> 9.1_p1-r2) (21/26) Upgrading openssh (9.1_p1-r1 -> 9.1_p1-r2) (22/26) Upgrading openssl (3.0.7-r2 -> 3.0.8-r0) (23/26) Upgrading sudo (1.9.12_p1-r1 -> 1.9.12_p2-r0) (24/26) Upgrading unbound-libs (1.17.0-r0 -> 1.17.1-r0) (25/26) Upgrading unbound (1.17.0-r0 -> 1.17.1-r0) (26/26) Upgrading unbound-openrc (1.17.0-r0 -> 1.17.1-r0) Executing busybox-1.35.0-r29.trigger Executing ca-certificates-20220614-r4.trigger Executing kmod-30-r1.trigger Executing mkinitfs-3.7.0-r0.trigger ==> initramfs: creating /boot/initramfs-virt Executing grub-2.06-r6.trigger Generating grub configuration file ... Found linux image: /boot/vmlinuz-virt Found initrd image: /boot/initramfs-virt Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. Adding boot menu entry for UEFI Firmware Settings ... done OK: 211 MiB in 116 packages |
これでNetdata Cloudの警告メッセージが消えました。
1 2 3 4 5 6 |
$ netdata -W buildinfo Version: netdata v1.38.0 Configure options: '--prefix=/usr' '--sysconfdir=/etc' '--localstatedir=/var' '--with-zlib' '--with-math' '--enable-https' '--with-webdir=/usr/share/webapps/netdata' '--with-user=netdata' 'CC=gcc' 'CFLAGS=-Os -fomit-frame-pointer' 'LDFLAGS=-Wl,--as-needed,-O1,--sort-common' 'CPPFLAGS=-Os -fomit-frame-pointer' 'CXX=g++' 'CXXFLAGS=-Os -fomit-frame-pointer' Install type: custom |
Oracle Cloud上のインスタンスへNetdata導入
次に、Oracle CloudのAlways Free枠を利用して以前構築した、Nextcloudが稼働するインスタンスへもNetdataを導入してみます。
インスタンスに使われているOSは、Ubuntu 20.04です。
1 2 3 4 5 6 7 8 |
$ uname -a Linux ubnxc 5.15.0-1029-oracle #35~20.04.1-Ubuntu SMP Wed Jan 25 10:16:03 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.5 LTS Release: 20.04 Codename: focal |
先ほどクラウドへ登録する際に使用した kickstart.sh を使ってインストールしてみると、スクリプトがパッケージマネージャを呼び出し、パッケージ版をインストールしていました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
$ wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --2023-02-10 11:15:40-- https://my-netdata.io/kickstart.sh Resolving my-netdata.io (my-netdata.io)...104.21.13.159, 172.67.156.192, 2606:4700:3031::6815:d9f, ... Connecting to my-netdata.io (my-netdata.io)|104.21.13.159|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/octet-stream] Saving to: ‘/tmp/netdata-kickstart.sh’ /tmp/netdata-kickstart.sh [ <=> ] 80.12K --.-KB/s in 0.002s 2023-02-10 11:15:41 (44.4 MB/s) - ‘/tmp/netdata-kickstart.sh’ saved [82038] --- Using /tmp/netdata-kickstart-q3ONjHV7JT as a temporary directory. --- --- Checking for existing installations of Netdata... --- --- No existing installations of netdata found, assuming this is a fresh install. --- --- Attempting to install using native packages... --- --- Checking for availability of repository configuration package. --- [/tmp/netdata-kickstart-q3ONjHV7JT]$ curl --fail -q -sSL --connect-timeout 10 --retry 3 --output /tmp/netdata-kickstart-q3ONjHV7JT/netdata-repo-edge_2-1+ubuntu20.04_all.deb https://repo.netdata.cloud/repos/repoconfig/ubuntu/focal/netdata-repo-edge_2-1+ubuntu20.04_all.deb OK Root privileges required to run env apt-get update [/tmp/netdata-kickstart-q3ONjHV7JT]$ sudo env apt-get update Hit:1 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease Hit:2 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal InRelease Get:4 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal-updates InRelease [114 kB] Hit:3 https://packagecloud.io/ookla/speedtest-cli/ubuntu focal InRelease Hit:5 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal-backports InRelease Get:6 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 Packages [1,710 kB] Get:7 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 Packages [948 kB] Fetched 2,772 kB in 3s (826 kB/s) Reading package lists... Done OK Root privileges required to run env apt-get install /tmp/netdata-kickstart-q3ONjHV7JT/netdata-repo-edge_2-1+ubuntu20.04_all.deb [/tmp/netdata-kickstart-q3ONjHV7JT]$ sudo env apt-get install /tmp/netdata-kickstart-q3ONjHV7JT/netdata-repo-edge_2-1+ubuntu20.04_all.deb Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'netdata-repo-edge' instead of '/tmp/netdata-kickstart-q3ONjHV7JT/netdata-repo-edge_2-1+ubuntu20.04_all.deb' The following additional packages will be installed: debian-archive-keyringThe following NEW packages will be installed: debian-archive-keyring netdata-repo-edge 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 73.4 kB/77.5 kB of archives. After this operation, 168 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 /tmp/netdata-kickstart-q3ONjHV7JT/netdata-repo-edge_2-1+ubuntu20.04_all.deb netdata-repo-edge all 2-1 [4,054 B] Get:2 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal/universe arm64 debian-archive-keyring all 2019.1ubuntu2 [73.4 kB] Fetched 73.4 kB in 1s (70.3 kB/s) Selecting previously unselected package debian-archive-keyring. (Reading database ... 136092 files and directories currently installed.) Preparing to unpack .../debian-archive-keyring_2019.1ubuntu2_all.deb ... Unpacking debian-archive-keyring (2019.1ubuntu2) ... Selecting previously unselected package netdata-repo-edge. Preparing to unpack .../netdata-repo-edge_2-1+ubuntu20.04_all.deb ... Unpacking netdata-repo-edge (2-1) ... Setting up debian-archive-keyring (2019.1ubuntu2) ... Setting up netdata-repo-edge (2-1) ... N: Download is performed unsandboxed as root as file '/tmp/netdata-kickstart-q3ONjHV7JT/netdata-repo-edge_2-1+ubuntu20.04_all.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied) OK Root privileges required to run env apt-get update [/tmp/netdata-kickstart-q3ONjHV7JT]$ sudo env apt-get update Ign:1 http://repo.netdata.cloud/repos/edge/ubuntu focal/ InRelease Hit:2 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease Hit:3 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal InRelease Hit:5 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal-updates InRelease Ign:6 http://repo.netdata.cloud/repos/repoconfig/ubuntu focal/ InRelease Get:7 http://repo.netdata.cloud/repos/edge/ubuntu focal/ Release [558 B] Get:8 http://repo.netdata.cloud/repos/repoconfig/ubuntu focal/ Release [546 B] Get:9 http://repo.netdata.cloud/repos/edge/ubuntu focal/ Release.gpg [687 B] Hit:10 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal-backports InRelease Hit:4 https://packagecloud.io/ookla/speedtest-cli/ubuntu focal InRelease Get:11 http://repo.netdata.cloud/repos/repoconfig/ubuntu focal/ Release.gpg [687 B] Get:12 http://repo.netdata.cloud/repos/edge/ubuntu focal/ Packages [19.5 kB] Get:13 http://repo.netdata.cloud/repos/repoconfig/ubuntu focal/ Packages [732 B] Fetched 22.7 kB in 2s (12.7 kB/s) Reading package lists... Done OK Root privileges required to run env apt-get install netdata [/tmp/netdata-kickstart-q3ONjHV7JT]$ sudo env apt-get install netdata Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libnetfilter-acct1 libprotobuf17 The following NEW packages will be installed: libnetfilter-acct1 libprotobuf17 netdata 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. Need to get 20.9 MB of archives. After this operation, 103 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal/universe arm64 libnetfilter-acct1 arm64 1.0.3-2 [6,776 B] Get:2 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports focal/main arm64 libprotobuf17 arm64 3.6.1.3-2ubuntu5 [690 kB] Get:3 http://repo.netdata.cloud/repos/edge/ubuntu focal/ netdata 1.38.0-51-nightly [20.2 MB] Fetched 20.9 MB in 3s (7,668 kB/s) Selecting previously unselected package libnetfilter-acct1:arm64. (Reading database ... 136113 files and directories currently installed.) Preparing to unpack .../libnetfilter-acct1_1.0.3-2_arm64.deb ... Unpacking libnetfilter-acct1:arm64 (1.0.3-2) ... Selecting previously unselected package libprotobuf17:arm64. Preparing to unpack .../libprotobuf17_3.6.1.3-2ubuntu5_arm64.deb ... Unpacking libprotobuf17:arm64 (3.6.1.3-2ubuntu5) ... Selecting previously unselected package netdata. Preparing to unpack .../netdata_1.38.0-51-nightly_arm64.deb ... Unpacking netdata (1.38.0-51-nightly) ... Setting up libnetfilter-acct1:arm64 (1.0.3-2) ... Setting up libprotobuf17:arm64 (3.6.1.3-2ubuntu5) ... Setting up netdata (1.38.0-51-nightly) ... WARNING: libcap needs an update (cap=40 should have a name). Created symlink /etc/systemd/system/multi-user.target.wants/netdata.service → /lib/systemd/system/netdata.service. Processing triggers for systemd (245.4-4ubuntu3.19) ... Processing triggers for libc-bin (2.31-0ubuntu9.9) ... OK Root privileges required to run //usr/libexec/netdata/netdata-updater.sh --enable-auto-updates [/tmp/netdata-kickstart-q3ONjHV7JT]$ sudo //usr/libexec/netdata/netdata-updater.sh --enable-auto-updates Fri 10 Feb 2023 11:16:26 AM HKT : INFO: netdata-updater.sh: Auto-updating has been ENABLED through cron, updater script linked to /etc/cron.daily/netdata-updater Fri 10 Feb 2023 11:16:26 AM HKT : INFO: netdata-updater.sh: If the update process fails and you have email notifications set up correctly for cron on this system, you should receive an email notification of the failure. Fri 10 Feb 2023 11:16:26 AM HKT : INFO: netdata-updater.sh: Successful updates will not send an email. OK Successfully installed the Netdata Agent. Official documentation can be found online at https://learn.netdata.cloud/docs/. Looking to monitor all of your infrastructure with Netdata? Check out Netdata Cloud at https://app.netdata.cloud. Join our community and connect with us on: - GitHub: https://github.com/netdata/netdata/discussions - Discord: https://discord.gg/5ygS846fR6 - Our community forums: https://community.netdata.cloud/Root privileges required to run rm -rf /tmp/netdata-kickstart-q3ONjHV7JT [/home/ubuntu]$ sudo rm -rf /tmp/netdata-kickstart-q3ONjHV7JT OK |
そして、Alpine Linuxと同じ要領でNetdata CloudへのNode追加スクリプトを実行するだけで、
1 2 3 |
$ wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh \ --claim-token ######################################################################################## \ --claim-url https://app.netdata.cloud |
居場所の異なる2つのデバイスを1つの画面に現せるようになりました。
Nextcloud用プラグインをインストールすれば、Nextcloudに特化した監視項目が利用可能になるようなので、また別途試してみるつもりです。
とここまでは比較的容易なウォーミングアップでしたが、次ページではOpenWRTに入っているNetdataをCloud対応させる手順を解説します。