mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-29 18:55:13 +08:00
update 2026-10-07 18:47:42
This commit is contained in:
1 parent
617f7ca2a6
commit
bd061545ed
4832 files changed
+1693456
No files matched your search
@@ -0,0 +1,48 @@
|
||||
# This is the configuration for charts.d.plugin
|
||||
|
||||
# Each of its collectors can read configuration eiher from this file
|
||||
# or a NAME.conf file (where NAME is the collector name).
|
||||
# The collector specific file has higher precedence.
|
||||
|
||||
# This file is a shell script too.
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# number of seconds to run without restart
|
||||
# after this time, charts.d.plugin will exit
|
||||
# netdata will restart it, but a small gap
|
||||
# will appear in the charts.d.plugin charts.
|
||||
#restart_timeout=$[3600 * 4]
|
||||
|
||||
# when making iterations, charts.d can loop more frequently
|
||||
# to prevent plugins missing iterations.
|
||||
# this is a percentage relative to update_every to align its
|
||||
# iterations.
|
||||
# The minimum is 10%, the maximum 100%.
|
||||
# So, if update_every is 1 second and time_divisor is 50,
|
||||
# charts.d will iterate every 500ms.
|
||||
# Charts will be called to collect data only if the time
|
||||
# passed since the last time the collected data is equal or
|
||||
# above their update_every.
|
||||
#time_divisor=50
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# the default enable/disable for all charts.d collectors
|
||||
# the default is "yes"
|
||||
enable_all_charts="no"
|
||||
|
||||
# BY DEFAULT ENABLED MODULES
|
||||
# ap=yes
|
||||
# apcupsd=yes
|
||||
# libreswan=yes
|
||||
# nut=yes
|
||||
# opensips=yes
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# THESE NEED TO BE SET TO "force" TO BE ENABLED
|
||||
|
||||
# Nothing useful.
|
||||
# Just an example charts.d plugin you can use as a template.
|
||||
# example=force
|
||||
sensors=force
|
||||
@@ -0,0 +1,35 @@
|
||||
# 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 = syslog
|
||||
error log = syslog
|
||||
access log = none
|
||||
run as user = root
|
||||
|
||||
[web]
|
||||
default port = 19999
|
||||
allow connections from = 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 = 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]
|
||||
cgroups = no
|
||||
apps = no
|
||||
charts.d = yes
|
||||
fping = no
|
||||
node.d = no
|
||||
python.d = no
|
||||
|
||||
[health]
|
||||
enabled = 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,90 @@
|
||||
#!/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/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'
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user