bash functions and aliases
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.6 KiB

#!/usr/bin/env bash
# -------------------------------------------------------------------------
# Netdata installer for Ubuntu/Debian
# -------------------------------------------------------------------------
# Website:
# GitHub:
# 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
chmod +x
echo "Installing Netdata"
./ all --dont-wait --no-updates >> /dev/null 2>&1
echo "Installing Netdata [OK]"
# 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
# installing required python package for mysql monitoring
apt-get update -qq &&
apt-get install python3-mysqldb -y -qq
# 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
service netdata restart