群晖 DSM 7.x 安装 哪吒监控 Agent

本文最后更新于 70 天前, 如有失效请评论区留言.

前情

年前进行macOS备份Time Machine操作导致存储池只读,几经操作没法恢复,只能丢数据重新来过了。

下载哪吒客户端Agent

从哪吒客户端下载页下载符合自己群晖 CPU 架构的 Agent 客户端

这里默认以我自己的群晖为例啦,DS218+, Intel CPU,下载nezha-agent_linux_amd64.zip就可以了

也可以直接使用我提供的目前最新版本0.15.19

https://dfcos.ysicing.net/oss/tiga/linux/amd64/nezha-agent

群晖开启ssh功能

控制面板-终端机和SNMP-终端机开启ssh功能

配置哪吒

SSH 到群晖,使用 sudo -i 切换到 root 账号

举个例子:

ssh [email protected] -p 9922
sudo -i

下载或同步nezha-agent

wget https://dfcos.ysicing.net/oss/tiga/linux/amd64/nezha-agent
chmod 777 nezha-agent
mkdir /opt/nezha/agent/
mv nezha-agent /opt/nezha/agent/nezha-agent

验证二进制文件

root@nas:~# /opt/nezha/agent/nezha-agent -v
0.15.19

测试链接服务端

/opt/nezha/agent/nezha-agent -s <Dashboard服务器地址>:<端口> -p <连接密码>
# 如果是https协议
/opt/nezha/agent/nezha-agent -s <Dashboard服务器地址>:<端口> -p <连接密码> --tls

执行后,没报错,并且在 Web 上能看到信息就可以

配置系统守护

DSM 7 内置 systemctl 命令,可以很方便设置为系统服务,守护进程。

编辑/etc/systemd/system/nezha-agent.service

[Unit]
Description=Nezha Agent
After=syslog.target
#After=network.target
#After=nezha-dashboard.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=root
Group=root
WorkingDirectory=/opt/nezha/agent/
ExecStart=/opt/nezha/agent/nezha-agent -s 连接地址:443 -p 连接密码  --disable-force-update --disable-command-execute --disable-auto-update --tls
Restart=always
#Environment=DEBUG=true

# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
#ProtectSystem=full
#PrivateDevices=yes
#PrivateTmp=yes
#NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

加载配置文件并启动

systemctl daemon-reload
systemctl enable nezha-agent
systemctl restart nezha-agent

最后

贴一下我的哪吒监控

Sponsor

Like this article? $1 reward

Comments