Skip to content

Instantly share code, notes, and snippets.

@VirtuBox
Last active June 1, 2019 10:40
Show Gist options
  • Save VirtuBox/b96decd7bcb21779482726765b10261c to your computer and use it in GitHub Desktop.
Save VirtuBox/b96decd7bcb21779482726765b10261c to your computer and use it in GitHub Desktop.
Netdata installer for Ubuntu/Debian
#!/usr/bin/env bash
# -------------------------------------------------------------------------
# Netdata installer for Ubuntu/Debian
# -------------------------------------------------------------------------
# Website: https://virtubox.net
# GitHub: https://github.com/VirtuBox
# Copyright (c) 2019 VirtuBox <[email protected]>
# This script is licensed under M.I.T
# -------------------------------------------------------------------------
# curl -sL vtb.cx/netdata | sudo -E bash -
# -------------------------------------------------------------------------
# Check if user is root
[ "$(id -u)" != "0" ] && {
echo "Error: You must be root or use sudo to run this script"
exit 1
}
## optimize netdata resources usage
echo 1 > /sys/kernel/mm/ksm/run
echo 1000 > /sys/kernel/mm/ksm/sleep_millisecs
## install nedata
wget -qO kickstart.sh https://my-netdata.io/kickstart.sh
chmod +x kickstart.sh
echo "Installing Netdata"
./kickstart.sh all --dont-wait --no-updates >> /dev/null 2>&1
echo "Installing Netdata [OK]"
rm kickstart.sh
# If MySQL installed, create netdata user for MySQL monitoring
if [ -n "$(command -v mysqladmin)" ]; then
MYSQL_CHECK="$(mysqladmin ping | grep alive)"
if [ -n "$MYSQL_CHECK" ]; then
# General MySQL monitoring
if [ -f $HOME/.my.cnf ] || [ -f /etc/mysql/conf.d/my.cnf ]; then
echo "Adding netdata user for MySQL monitoring"
mysql -e "create user 'netdata'@'localhost';"
mysql -e "grant usage on *.* to 'netdata'@'localhost';"
mysql -e "flush privileges;"
# MySQL monitoring with Plesk
elif [ -f /etc/psa/.psa.shadow ]; then
echo "Adding netdata user for MySQL monitoring"
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin -e "create user 'netdata'@'localhost';"
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin -e "grant usage on *.* to 'netdata'@'localhost';"
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin -e "flush privileges;"
echo "Updating Netdata configuration for Apache monitoring"
sed -i 's/http:\/\/localhost\/server-status?auto/http:\/\/localhost:7080\/server-status?auto/' /usr/lib/netdata/conf.d/python.d/apache.conf
fi
# installing required python package for mysql monitoring
apt-get update -qq &&
apt-get install python3-mysqldb -y -qq
fi
fi
# disable mail notifications
sed -i 's/SEND_EMAIL="YES"/SEND_EMAIL="NO"/' /usr/lib/netdata/conf.d/health_alarm_notify.conf
service netdata restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment