🎉 Sync 2026-03-23 03:47:01

This commit is contained in:
github-actions[bot] committed 2026-03-23 03:47:01 +08:00
1 parent 9028beac27
commit 5e79f3a579
78 files changed
+1873 -11153

No files matched your search

@@ -12,26 +12,26 @@
},
"admin/status/netdata/netdata": {
"title": "Netdata",
"order": 10,
"order": 1,
"action": {
"type": "view",
"path": "netdata/netdata"
}
},
"admin/status/netdata/basic": {
"title": "Basic Setting",
"order": 20,
"action": {
"type": "view",
"path": "netdata/basic"
"path": "netdata/main"
}
},
"admin/status/netdata/config": {
"title": "Config Setting",
"order": 30,
"title": "Config",
"order": 2,
"action": {
"type": "view",
"path": "netdata/config"
}
},
"admin/status/netdata/advanced": {
"title": "Advanced",
"order": 3,
"action": {
"type": "view",
"path": "netdata/advanced"
}
}
}
@@ -1,33 +0,0 @@
# Full configuration can be retrieved from the running
# server at http://localhost:19999/netdata.conf
#
# Example:
# curl -o /etc/netdata/netdata.conf http://localhost:19999/netdata.conf
#
[global]
update every = 2
memory deduplication (ksm) = no
debug log = none
error log = none
access log = none
run as user = root
[web]
default port = 19999
allow connections from = *
allow dashboard from = *
[plugins]
cgroups = no
apps = no
charts.d = no
fping = no
node.d = no
python.d = no
[health]
enabled = no
[plugin:proc:ipc]
shared memory totals = no
@@ -1,3 +0,0 @@
config netdata 'netdata'
option enabled '0'
option port '19999'
@@ -1,105 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
APPBINARY=/usr/sbin/netdata
CONFIGFILE=/etc/netdata/netdata.conf
config_load 'netdata'
get_config() {
config_get_bool enabled $1 enabled 0
config_get port $1 port 19999
config_get_bool ssl $1 enable_ssl 0
config_get cert_file $1 cert_file '/etc/ssl/ezopwrt.crt'
config_get key_file $1 key_file '/etc/ssl/ezopwrt.key'
config_get_bool ennginx $1 nginx_support 0
config_get_bool auth $1 auth 0
config_get userpw $1 user_passwd 'admin:$apr1$t7qQjoqb$YBHtAb7VGSkjIdObMG.Oy0'
[ "$ennginx" == "1" ] && ssl=0
}
#read_option <option>
read_option() {
[ -n "$1" ] || return 1
sed -En "/^\[web\]/,/^(\[|$)/{s|^\s*$1 = *(.*)$|\1|p}" "$CONFIGFILE"
}
#white_option <option> [value]
white_option() {
[ -n "$1" ] || return 1
if [ -n "$(sed -En "/^\[web\]/,/^(\[|$)/{s|^\s*($1) =.*$|\1|p}" "$CONFIGFILE")" ]; then
sed -Ei "/^\[web\]/,/^(\[|$)/{s|^(\s*)$1 =.*|\1$1 = $2|}" "$CONFIGFILE"
else
sed -Ei "/^\[web\]/a\\\t$1 = $2" "$CONFIGFILE"
fi
}
white_conf() {
if [ "x$ssl" == "x1" ] ;then
rm -f $certskey $certscrt
hostname=$(uci -q get system.@system[0].hostname | awk '{print tolower($0)}')
uci -q set network.lan.hostname=${hostname}
uci -q set dhcp.@dnsmasq[0].domain="${hostname}.lan"
openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -keyout $key_file -out $cert_file -subj "/C=CN/CN=$hostname.lan"
uci commit dhcp
uci commit network
else
local cert_file='' key_file=''
fi
[ "$port" == "$(read_option 'default port')" ] || white_option 'default port' "$port"
[ "$cert_file" == "$(read_option 'ssl certificate')" ] || white_option 'ssl certificate' "$cert_file"
[ "$key_file" == "$(read_option 'ssl key')" ] || white_option 'ssl key' "$key_file"
}
write_nginx() {
local location="/etc/nginx/conf.d/netdata.locations"
local htpasswd="/etc/nginx/conf.d/netdata.htpasswd"
echo "$userpw" > "$htpasswd"
[ "$(sed -En "s|^\s*proxy_pass\s+https?://[^:]+:(\d+).*|\1|p" "$location")" == "$port" ] || sed -Ei "/proxy_pass/{s|(\bproxy_pass\b)(\s+.+)?|\1 http://localhost:$port/;|}" "$location"
if [ "$auth" == "1" ];then
sed -Ei "s|#(\bauth_basic_user_file\b)|\1|" "$location"
else
sed -Ei "s|^(\s*)(\bauth_basic_user_file\b)|\1#\2|" "$location"
fi
/etc/init.d/nginx reload
}
netdata_instance() {
mkdir -m 0755 -p /var/cache/netdata
chown nobody /var/cache/netdata
mkdir -m 0755 -p /var/lib/netdata
chown nobody /var/lib/netdata
mkdir -m 0755 -p /var/lib/netdata/cloud.d
chown nobody /var/lib/netdata/cloud.d
mkdir -m 0755 -p /var/log/netdata
chown nobody /var/log/netdata
procd_open_instance
procd_set_param command $APPBINARY -D -c $CONFIGFILE
procd_set_param file $CONFIGFILE
procd_set_param respawn
procd_close_instance
}
start_service() {
config_foreach get_config 'netdata'
[ "${enabled:=0}" == "0" ] && stop_service && return 1
white_conf
[ "$ennginx" == "1" ] && write_nginx
netdata_instance
}
stop_service() {
pgrep -f $APPBINARY | xargs kill -9 >/dev/null 2>&1
return 0
}
service_triggers() {
procd_add_reload_trigger 'netdata'
}
reload_service() {
restart
}
@@ -5,15 +5,10 @@
"file": {
"/etc/netdata/netdata.conf": [ "read" ],
"/etc/init.d/netdata": [ "exec" ],
"/usr/bin/openssl passwd -apr1 *": [ "exec" ],
"/bin/pidof": [ "exec" ],
"/bin/ps": [ "exec" ],
"/bin/ash": [ "exec" ]
"/usr/bin/openssl passwd -apr1 *": [ "exec" ]
},
"ubus": {
"rc": [ "*" ],
"file": [ "read" ],
"luci.netdata": [ "*" ]
"file": [ "read" ]
},
"uci": [ "netdata" ]
},
@@ -22,8 +17,7 @@
"/etc/netdata/netdata.conf": [ "write" ]
},
"ubus": {
"file": [ "write" ],
"luci.netdata": [ "*" ]
"file": [ "write" ]
},
"uci": [ "netdata" ]
}
@@ -1,53 +0,0 @@
#!/usr/bin/ucode
/*
* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (C) 2021-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/luci-app-netdata
*/
'use strict';
import { access, popen } from 'fs';
function get_netdata_version() {
if (!access('/usr/sbin/netdata'))
return null;
const fd = popen("a=`/usr/sbin/netdata -v`&&echo $a |awk -F v '{printf $2}'");
if (fd) {
let output = trim(fd.read('all'));
fd.close();
// 方法1: 简单替换(推荐)
let version_with_v = replace(output, "netdata ", "");
// 方法2: 去掉 v 前缀
let version_clean = replace(version_with_v, "v", "");
return version_with_v; // 返回 "v2.3.2"
}
return null;
}
const methods = {
get_version: {
call: function() {
let version = get_netdata_version();
if (!version)
return { version: null, error: '无法获取 netdata 版本' };
return { version: version };
}
},
get_version_clean: {
call: function() {
let version = get_netdata_version();
if (!version)
return { version: null, error: '无法获取 netdata 版本' };
// 去掉 "v" 前缀,返回纯数字版本
let clean_version = replace(version, /^v/, "");
return { version: clean_version };
}
}
};
return { 'luci.netdata': methods };