#!/usr/bin/env bash # ------------------------------------------------------------------------- # Netdata installer for Ubuntu/Debian # ------------------------------------------------------------------------- # Website: https://virtubox.net # GitHub: https://github.com/VirtuBox # Copyright (c) 2019 VirtuBox # This script is licensed under M.I.T # ------------------------------------------------------------------------- # 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 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;" 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" if [ -d /etc/netdata ]; then sed -i 's/http:\/\/localhost\/server-status?auto/http:\/\/localhost:7080\/server-status?auto/' /usr/lib/netdata/conf.d/python.d/apache.conf cp /usr/lib/netdata/conf.d/python.d/apache.conf /etc/netdata/python.d/apache.conf -f fi 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 if [ -d /etc/netdata ]; then cp /usr/lib/netdata/conf.d/health_alarm_notify.conf /etc/netdata/health_alarm_notify.conf -f fi service netdata restart