mirror of
https://github.com/YunoHost-Apps/grafana_ynh.git
synced 2024-09-03 20:36:29 +02:00
Merge pull request #22 from YunoHost-Apps/testing
This commit is contained in:
commit
8e3209f3e0
7 changed files with 90 additions and 43 deletions
|
@ -4,6 +4,12 @@ Changelog
|
||||||
## Unreleased
|
## Unreleased
|
||||||
- Nothing for now...
|
- Nothing for now...
|
||||||
|
|
||||||
|
## [7.3.3~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/22) - 2020-11-15
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
* Upgrade to upstream version 7.3.3
|
||||||
|
* 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
|
## [7.0.3~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/21) - 2020-06-13
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
|
|
|
@ -13,7 +13,7 @@ NetData only collects, displays and sets alarms based on data from the last hour
|
||||||
|
|
||||||
Note: You can use it without NetData, but you'll have to install a collection application (e.g. collectd) to gather data.
|
Note: You can use it without NetData, but you'll have to install a collection application (e.g. collectd) to gather data.
|
||||||
|
|
||||||
**Shipped version:** 7.0.3
|
**Shipped version:** 7.3.3
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Beautiful metric & analytic dashboards for monitoring",
|
"en": "Beautiful metric & analytic dashboards for monitoring",
|
||||||
"fr": "Tableaux de bords de supervision"
|
"fr": "Tableaux de bords de supervision"
|
||||||
},
|
},
|
||||||
"version": "7.0.3~ynh1",
|
"version": "7.3.3~ynh1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"url": "http://grafana.org/",
|
"url": "http://grafana.org/",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Debian package version for Grafana
|
# Debian package version for Grafana
|
||||||
GRAFANA_VERSION="7.0.3"
|
GRAFANA_VERSION="7.3.3"
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="influxdb"
|
pkg_dependencies="influxdb"
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,23 @@ ynh_print_info --message="Backing up the InfluxDB database..."
|
||||||
# Backup InfluxDB data
|
# Backup InfluxDB data
|
||||||
# Source: http://stackoverflow.com/questions/39501416/how-to-restore-data-base-using-influxd
|
# Source: http://stackoverflow.com/questions/39501416/how-to-restore-data-base-using-influxd
|
||||||
mkdir influxdb_data
|
mkdir influxdb_data
|
||||||
# Backup only if database exists
|
# Backup only if database exists (compatible with automated tests where NetData is not present)
|
||||||
# That happens when passing automated tests (NetData not present)
|
# and if BACKUP_CORE_ONY/do_not_backup_data not set
|
||||||
|
BACKUP_CORE_ONLY=${BACKUP_CORE_ONLY:-0}
|
||||||
|
do_not_backup_data=$(ynh_app_setting_get --app=$app --key=do_not_backup_data)
|
||||||
|
|
||||||
if [ -d "/var/lib/influxdb/data/opentsdb" ]; then
|
if [ -d "/var/lib/influxdb/data/opentsdb" ]; then
|
||||||
|
if ( [ ${do_not_backup_data:-0} -eq 1 ] || [ $BACKUP_CORE_ONLY -eq 1 ] )
|
||||||
|
then
|
||||||
|
if [ $BACKUP_CORE_ONLY -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_print_warn --message="The InfluxDB database will not be saved, because 'BACKUP_CORE_ONLY' is set."
|
||||||
|
else
|
||||||
|
ynh_print_warn --message="The InfluxDB database will not be saved, because 'do_not_backup_data' is set."
|
||||||
|
fi
|
||||||
|
else
|
||||||
influxd backup -database opentsdb influxdb_data
|
influxd backup -database opentsdb influxdb_data
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -100,26 +100,28 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Grafana and InfluxDB..." --weight=30
|
ynh_script_progression --message="Configuring Grafana and InfluxDB..." --weight=30
|
||||||
# If NetData is installed, configure it to feed InfluxDB
|
# 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 [ -f "$netdata_conf" ] ; then
|
||||||
# If there is already a [backend] section
|
sed -i '/^\[exporting:global\]$/,/^\[/ {
|
||||||
if [ -n "$(cat $netdata_conf | grep '\[backend\]')" ] ; then
|
s/enabled = no/enabled = yes/
|
||||||
# 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/
|
|
||||||
s/# update every = 10/update every = 60/
|
s/# update every = 10/update every = 60/
|
||||||
}' $netdata_conf
|
}' $netdata_conf
|
||||||
else
|
if [ -z "$(grep "yunohost" $netdata_conf)" ] ; then
|
||||||
# Otherwise create the section
|
cat >> $netdata_conf <<EOF
|
||||||
echo "[backend]
|
[opentsdb:yunohost]
|
||||||
enabled = yes
|
enabled = yes
|
||||||
type = opentsdb
|
destination = localhost:4242
|
||||||
destination = localhost:4242" | tee -a $netdata_conf
|
# 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
|
fi
|
||||||
|
|
||||||
# Restart NetData
|
# Restart NetData
|
||||||
ynh_systemd_action --service_name=netdata --action="restart"
|
ynh_systemd_action --service_name=netdata --action="restart"
|
||||||
fi
|
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
|
ynh_script_progression --message="Configuring Grafana and InfluxDB..." --weight=3
|
||||||
# If NetData is installed, configure it to feed InfluxDB
|
# If NetData is installed, configure it to feed InfluxDB
|
||||||
netdata_conf="/opt/netdata/etc/netdata/netdata.conf"
|
if [ -d "/opt/netdata" ] ; then
|
||||||
if [ -f "$netdata_conf" ] ; 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 there is already a [backend] section
|
||||||
if [ -n "$(cat $netdata_conf | grep '\[backend\]')" ] ; then
|
if [ -n "$(cat $netdata_conf | grep '\[backend\]')" ] ; then
|
||||||
# These regexps replaces patterns inside ini [sections] ([backend] section, here)
|
# These regexps replaces patterns inside ini [sections] ([backend] section, here)
|
||||||
sed -i '/^\[backend\]$/,/^\[/ {
|
sed -i '/^\[backend\]$/,/^\[/ {
|
||||||
s/# enabled = no/enabled = yes/
|
s/enabled = yes/enabled = no/
|
||||||
s/# type = graphite/type = opentsdb/
|
|
||||||
s/# destination = localhost/destination = localhost:4242/
|
|
||||||
s/# update every = 10/update every = 60/
|
|
||||||
}' $netdata_conf
|
}' $netdata_conf
|
||||||
else
|
else
|
||||||
# Otherwise create the section
|
# Otherwise create the section
|
||||||
echo "[backend]
|
echo "[backend]
|
||||||
enabled = yes
|
enabled = yes
|
||||||
type = opentsdb
|
type = opentsdb
|
||||||
destination = localhost:4242" | tee -a $netdata_conf
|
destination = localhost:4242" | tee -a $netdata_conf
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart NetData
|
# Restart NetData
|
||||||
ynh_systemd_action --service_name=netdata --action="restart"
|
ynh_systemd_action --service_name=netdata --action="restart"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Update default dashboard for NetData (source: https://grafana.com/grafana/dashboards/2701)
|
# Update default dashboard for NetData (source: https://grafana.com/grafana/dashboards/2701)
|
||||||
# Remove new lines
|
# Remove new lines
|
||||||
tr -d '\n' < ../conf/netdata_dashboard.json > dashboard.json
|
tr -d '\n' < ../conf/netdata_dashboard.json > dashboard.json
|
||||||
|
|
Loading…
Reference in a new issue