mirror of
https://github.com/YunoHost-Apps/netdata_ynh.git
synced 2024-09-03 19:46:33 +02:00
Monitor PostgreSQL if installed through YunoHost helpers
This commit is contained in:
parent
dfab6d5473
commit
cd1979b58e
3 changed files with 32 additions and 15 deletions
|
@ -3,10 +3,17 @@
|
||||||
# Common variables
|
# Common variables
|
||||||
#
|
#
|
||||||
|
|
||||||
pkg_dependencies="zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl jq nodejs python-mysqldb libipmimonitoring-dev acl"
|
pkg_dependencies="zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl jq nodejs python-mysqldb libipmimonitoring-dev acl python-psycopg2"
|
||||||
|
|
||||||
# Configure NetData
|
# Configure NetData
|
||||||
configure_netdata() {
|
configure_netdata() {
|
||||||
|
|
||||||
|
# Add a web_log entry for every YunoHost domain
|
||||||
|
netdata_add_yunohost_web_logs
|
||||||
|
|
||||||
|
# If PostgreSQL is installed, add a PostgreSQL entry using instance password
|
||||||
|
netdata_add_yunohost_postgres_configuration
|
||||||
|
|
||||||
# Create netdata user to monitor MySQL (if needed)
|
# Create netdata user to monitor MySQL (if needed)
|
||||||
is_mysql_user_existing=$(ynh_mysql_execute_as_root "select user from mysql.user where user = 'netdata';")
|
is_mysql_user_existing=$(ynh_mysql_execute_as_root "select user from mysql.user where user = 'netdata';")
|
||||||
if [ -z "$is_mysql_user_existing" ] ; then
|
if [ -z "$is_mysql_user_existing" ] ; then
|
||||||
|
@ -29,21 +36,39 @@ configure_netdata() {
|
||||||
systemctl restart netdata
|
systemctl restart netdata
|
||||||
|
|
||||||
# Store the uninstaller for the removal script
|
# Store the uninstaller for the removal script
|
||||||
mv ./netdata-uninstaller.sh /opt/netdata/etc/netdata
|
[ -f ./netdata-uninstaller.sh ] && mv ./netdata-uninstaller.sh /opt/netdata/etc/netdata
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add a web_log entry for every YunoHost domain
|
# Add a web_log entry for every YunoHost domain
|
||||||
netdata_add_yunohost_web_logs () {
|
netdata_add_yunohost_web_logs () {
|
||||||
echo "# ------------YUNOHOST DOMAINS---------------" >> /opt/netdata/etc/netdata/python.d/web_log.conf
|
local web_log_file="/opt/netdata/etc/netdata/python.d/web_log.conf"
|
||||||
for domain in $(yunohost domain list --output-as plain); do
|
if [ -z "$(grep "YUNOHOST" $web_log_file)" ] ; then
|
||||||
domain_label=${domain//\./_} # Replace "." by "_" for the domain label
|
echo "# ------------YUNOHOST DOMAINS---------------" >> $web_log_file
|
||||||
cat >> /opt/netdata/etc/netdata/python.d/web_log.conf <<EOF
|
for domain in $(yunohost domain list --output-as plain); do
|
||||||
|
domain_label=${domain//\./_} # Replace "." by "_" for the domain label
|
||||||
|
cat >> $web_log_file <<EOF
|
||||||
${domain_label}_log:
|
${domain_label}_log:
|
||||||
name: '${domain_label}'
|
name: '${domain_label}'
|
||||||
path: '/var/log/nginx/$domain-access.log'
|
path: '/var/log/nginx/$domain-access.log'
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# If PostgreSQL is installed, add a PostgreSQL entry using instance password
|
||||||
|
netdata_add_yunohost_postgres_configuration () {
|
||||||
|
if [ -f /etc/yunohost/psql ] && [ -z "$(grep "yunohost:" /opt/netdata/etc/netdata/python.d/postgres.conf)" ] ; then
|
||||||
|
cat >> /opt/netdata/etc/netdata/python.d/postgres.conf <<EOF
|
||||||
|
yunohost:
|
||||||
|
name : 'local'
|
||||||
|
database : 'postgres'
|
||||||
|
user : 'postgres'
|
||||||
|
password : '$(cat /etc/yunohost/psql)'
|
||||||
|
host : 'localhost'
|
||||||
|
port : 5432
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ============= FUTURE YUNOHOST HELPER =============
|
# ============= FUTURE YUNOHOST HELPER =============
|
||||||
|
|
|
@ -93,9 +93,6 @@ ynh_add_nginx_config
|
||||||
pushd $NETDATA_TMPDIR
|
pushd $NETDATA_TMPDIR
|
||||||
./netdata-installer.sh --install /opt --dont-wait
|
./netdata-installer.sh --install /opt --dont-wait
|
||||||
|
|
||||||
# Add a web_log entry for every YunoHost domain
|
|
||||||
netdata_add_yunohost_web_logs
|
|
||||||
|
|
||||||
configure_netdata
|
configure_netdata
|
||||||
|
|
||||||
# Store the app.src file
|
# Store the app.src file
|
||||||
|
|
|
@ -94,11 +94,6 @@ rm -f /etc/systemd/system/netdata.service
|
||||||
|
|
||||||
./netdata-installer.sh --install /opt --dont-wait >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA"
|
./netdata-installer.sh --install /opt --dont-wait >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA"
|
||||||
|
|
||||||
# If YunoHost web logs have never been set in netdata configuration, set them
|
|
||||||
if [ -z "$(grep "YUNOHOST" /opt/netdata/etc/netdata/python.d/web_log.conf)" ] ; then
|
|
||||||
netdata_add_yunohost_web_logs
|
|
||||||
fi
|
|
||||||
|
|
||||||
configure_netdata
|
configure_netdata
|
||||||
|
|
||||||
# Store the app.src file
|
# Store the app.src file
|
||||||
|
|
Loading…
Add table
Reference in a new issue