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.

61 lines
2.6KB

  1. #!/usr/bin/env bash
  2. # -------------------------------------------------------------------------
  3. # Netdata installer for Ubuntu/Debian
  4. # -------------------------------------------------------------------------
  5. # Website: https://virtubox.net
  6. # GitHub: https://github.com/VirtuBox
  7. # Copyright (c) 2019 VirtuBox <contact@virtubox.net>
  8. # This script is licensed under M.I.T
  9. # -------------------------------------------------------------------------
  10. # Check if user is root
  11. [ "$(id -u)" != "0" ] && {
  12. echo "Error: You must be root or use sudo to run this script"
  13. exit 1
  14. }
  15. ## optimize netdata resources usage
  16. echo 1 > /sys/kernel/mm/ksm/run
  17. echo 1000 > /sys/kernel/mm/ksm/sleep_millisecs
  18. ## install nedata
  19. wget -qO kickstart.sh https://my-netdata.io/kickstart.sh
  20. chmod +x kickstart.sh
  21. echo "Installing Netdata"
  22. ./kickstart.sh all --dont-wait --no-updates >> /dev/null 2>&1
  23. echo "Installing Netdata [OK]"
  24. rm kickstart.sh
  25. # If MySQL installed, create netdata user for MySQL monitoring
  26. if [ -n "$(command -v mysqladmin)" ]; then
  27. MYSQL_CHECK="$(mysqladmin ping | grep alive)"
  28. if [ -n "$MYSQL_CHECK" ]; then
  29. if [ -f $HOME/.my.cnf ] || [ -f /etc/mysql/conf.d/my.cnf ]; then
  30. echo "Adding netdata user for MySQL monitoring"
  31. mysql -e "create user 'netdata'@'localhost';"
  32. mysql -e "grant usage on *.* to 'netdata'@'localhost';"
  33. mysql -e "flush privileges;"
  34. elif [ -f /etc/psa/.psa.shadow ]; then
  35. echo "Adding netdata user for MySQL monitoring"
  36. MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin -e "create user 'netdata'@'localhost';"
  37. MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin -e "grant usage on *.* to 'netdata'@'localhost';"
  38. MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin -e "flush privileges;"
  39. echo "Updating Netdata configuration for Apache monitoring"
  40. if [ -d /etc/netdata ]; then
  41. sed -i 's/http:\/\/localhost\/server-status?auto/http:\/\/localhost:7080\/server-status?auto/' /usr/lib/netdata/conf.d/python.d/apache.conf
  42. cp /usr/lib/netdata/conf.d/python.d/apache.conf /etc/netdata/python.d/apache.conf -f
  43. fi
  44. fi
  45. # installing required python package for mysql monitoring
  46. apt-get update -qq &&
  47. apt-get install python3-mysqldb -y -qq
  48. fi
  49. fi
  50. # disable mail notifications
  51. sed -i 's/SEND_EMAIL="YES"/SEND_EMAIL="NO"/' /usr/lib/netdata/conf.d/health_alarm_notify.conf
  52. if [ -d /etc/netdata ]; then
  53. cp /usr/lib/netdata/conf.d/health_alarm_notify.conf /etc/netdata/health_alarm_notify.conf -f
  54. fi
  55. service netdata restart