mirror of
https://github.com/YunoHost-Apps/grafana_ynh.git
synced 2024-09-03 20:36:29 +02:00
Migrate NetData backend conf to Exporting Engine
This commit is contained in:
parent
6c529bdd89
commit
be98a9f158
3 changed files with 66 additions and 37 deletions
|
@ -8,6 +8,7 @@ Changelog
|
|||
|
||||
#### Changed
|
||||
* Upgrade to upstream version 7.3.2
|
||||
* Migrate NetData configuration from deprecated backend configuration to Exporting Engine configuration
|
||||
|
||||
## [7.0.3~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/21) - 2020-06-13
|
||||
|
||||
|
|
|
@ -100,26 +100,28 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring Grafana and InfluxDB..." --weight=30
|
||||
# If NetData is installed, configure it to feed InfluxDB
|
||||
netdata_conf="/opt/netdata/etc/netdata/netdata.conf"
|
||||
netdata_conf="/opt/netdata/etc/netdata/exporting.conf"
|
||||
if [ -f "$netdata_conf" ] ; then
|
||||
# If there is already a [backend] section
|
||||
if [ -n "$(cat $netdata_conf | grep '\[backend\]')" ] ; then
|
||||
# These regexps replaces patterns inside ini [sections] ([backend] section, here)
|
||||
# (source: https://stackoverflow.com/a/16987794)
|
||||
sed -i '/^\[backend\]$/,/^\[/ {
|
||||
s/# enabled = no/enabled = yes/
|
||||
s/# type = graphite/type = opentsdb/
|
||||
s/# destination = localhost/destination = localhost:4242/
|
||||
sed -i '/^\[exporting:global\]$/,/^\[/ {
|
||||
s/enabled = no/enabled = yes/
|
||||
s/# update every = 10/update every = 60/
|
||||
}' $netdata_conf
|
||||
else
|
||||
# Otherwise create the section
|
||||
echo "[backend]
|
||||
enabled = yes
|
||||
type = opentsdb
|
||||
destination = localhost:4242" | tee -a $netdata_conf
|
||||
if [ -z "$(grep "yunohost" $netdata_conf)" ] ; then
|
||||
cat >> $netdata_conf <<EOF
|
||||
[opentsdb:yunohost]
|
||||
enabled = yes
|
||||
destination = localhost:4242
|
||||
# data source = average
|
||||
# prefix = netdata
|
||||
# hostname = my_hostname
|
||||
update every = 60
|
||||
# buffer on failures = 10
|
||||
# timeout ms = 20000
|
||||
# send names instead of ids = yes
|
||||
# send charts matching = *
|
||||
# send hosts matching = localhost *
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Restart NetData
|
||||
ynh_systemd_action --service_name=netdata --action="restart"
|
||||
fi
|
||||
|
|
|
@ -103,29 +103,55 @@ ynh_install_extra_app_dependencies --repo="deb https://packages.grafana.com/oss/
|
|||
|
||||
ynh_script_progression --message="Configuring Grafana and InfluxDB..." --weight=3
|
||||
# If NetData is installed, configure it to feed InfluxDB
|
||||
netdata_conf="/opt/netdata/etc/netdata/netdata.conf"
|
||||
if [ -f "$netdata_conf" ] ; then
|
||||
if [ -d "/opt/netdata" ] ; then
|
||||
netdata_conf="/opt/netdata/etc/netdata/exporting.conf"
|
||||
if [ ! -f $netdata_conf ] ; then
|
||||
cp /opt/netdata/usr/lib/netdata/conf.d/exporting.conf $netdata_conf
|
||||
fi
|
||||
sed -i '/^\[exporting:global\]$/,/^\[/ {
|
||||
s/enabled = no/enabled = yes/
|
||||
s/# update every = 10/update every = 60/
|
||||
}' $netdata_conf
|
||||
if [ -z "$(grep "yunohost" $netdata_conf)" ] ; then
|
||||
cat >> $netdata_conf <<EOF
|
||||
[opentsdb:yunohost]
|
||||
enabled = yes
|
||||
destination = localhost:4242
|
||||
# data source = average
|
||||
# prefix = netdata
|
||||
# hostname = my_hostname
|
||||
update every = 60
|
||||
# buffer on failures = 10
|
||||
# timeout ms = 20000
|
||||
# send names instead of ids = yes
|
||||
# send charts matching = *
|
||||
# send hosts matching = localhost *
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Remove obsolete NetData backend if in use
|
||||
netdata_conf="/opt/netdata/etc/netdata/netdata.conf"
|
||||
if [ -f "$netdata_conf" ] ; then
|
||||
# If there is already a [backend] section
|
||||
if [ -n "$(cat $netdata_conf | grep '\[backend\]')" ] ; then
|
||||
# These regexps replaces patterns inside ini [sections] ([backend] section, here)
|
||||
sed -i '/^\[backend\]$/,/^\[/ {
|
||||
s/# enabled = no/enabled = yes/
|
||||
s/# type = graphite/type = opentsdb/
|
||||
s/# destination = localhost/destination = localhost:4242/
|
||||
s/# update every = 10/update every = 60/
|
||||
s/enabled = yes/enabled = no/
|
||||
}' $netdata_conf
|
||||
else
|
||||
# Otherwise create the section
|
||||
echo "[backend]
|
||||
enabled = yes
|
||||
type = opentsdb
|
||||
destination = localhost:4242" | tee -a $netdata_conf
|
||||
enabled = yes
|
||||
type = opentsdb
|
||||
destination = localhost:4242" | tee -a $netdata_conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Restart NetData
|
||||
ynh_systemd_action --service_name=netdata --action="restart"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Update default dashboard for NetData (source: https://grafana.com/grafana/dashboards/2701)
|
||||
# Remove new lines
|
||||
tr -d '\n' < ../conf/netdata_dashboard.json > dashboard.json
|
||||
|
|
Loading…
Reference in a new issue