mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-09-11 02:44:57 +08:00
🏅 Sync 2026-04-06 15:50:29
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# 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]
|
||||
run as user = root
|
||||
|
||||
[db]
|
||||
memory deduplication (ksm) = no
|
||||
|
||||
[logs]
|
||||
daemon = syslog
|
||||
debug = none
|
||||
access = none
|
||||
|
||||
[web]
|
||||
default port = 19999
|
||||
allow connections from = fd* localhost 10.* 192.168.* 172.16.* 172.17.* 172.18.* 172.19.* 172.20.* 172.21.* 172.22.* 172.23.* 172.24.* 172.25.* 172.26.* 172.27.* 172.28.* 172.29.* 172.30.* 172.31.*
|
||||
allow dashboard from = fd* localhost 10.* 192.168.* 172.16.* 172.17.* 172.18.* 172.19.* 172.20.* 172.21.* 172.22.* 172.23.* 172.24.* 172.25.* 172.26.* 172.27.* 172.28.* 172.29.* 172.30.* 172.31.*
|
||||
ssl certificate = /etc/netdata/cert.crt
|
||||
ssl key = /etc/netdata/cert.key
|
||||
|
||||
[plugins]
|
||||
apps = no
|
||||
cgroups = no
|
||||
charts.d = no
|
||||
python.d = no
|
||||
|
||||
[plugin:proc:ipc]
|
||||
shared memory totals = no
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
config netdata
|
||||
option enabled '0'
|
||||
option port '19999'
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
admin:$apr1$t7qQjoqb$YBHtAb7VGSkjIdObMG.Oy0
|
||||
@@ -0,0 +1,96 @@
|
||||
#!/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/netdata/cert.crt'
|
||||
config_get key_file $1 key_file '/etc/netdata/cert.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() {
|
||||
[ "$ssl" == "0" ] && local cert_file='' key_file=''
|
||||
|
||||
[ "$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
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
location /netdata/ {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_pass http://localhost:19999/;
|
||||
proxy_redirect default;
|
||||
proxy_set_header Connection "keep-alive";
|
||||
auth_basic 'Please login to continue';
|
||||
#auth_basic_user_file /etc/nginx/conf.d/netdata.htpasswd;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -i "s/initTabs();$/initTabs();loadDashboard();/" /usr/share/netdata/web/index.html
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user