Skip to content

Instantly share code, notes, and snippets.

@balda
Created October 1, 2014 10:14
Show Gist options
  • Save balda/05e20b0655c3c52b00a4 to your computer and use it in GitHub Desktop.
Save balda/05e20b0655c3c52b00a4 to your computer and use it in GitHub Desktop.
Bootstrap ELK
#!/bin/bash
# update package repo
apt_install () {
echo "Europe/Paris" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# sytem upgrade
apt-get update; apt-get upgrade -y
# install nginx. libcurl3 is needed to monitor Nginx with collectd
apt-get install -y libcurl3 openntpd
}
# install collectd
collectd_install () {
apt-get install -y collectd collectd-utils
service collectd stop
rm -f /etc/collectd/collectd.conf
ln -sf /vagrant/files/collectd/collectd.conf /etc/collectd/collectd.conf
# cp /vagrant/files/collectd/collectd.conf /etc/collectd/collectd.conf
service collectd start
}
apache_install () {
apt-get install -y apache2
rm -rf /var/www
mkdir /var/www
chown www-data.www-data /var/www
}
elasticsearch_install () {
wget -qO - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb http://packages.elasticsearch.org/elasticsearch/1.3/debian stable main" > /etc/apt/sources.list.d/elasticsearch.list
# echo 'deb http://packages.elasticsearch.org/elasticsearch/1.3/debian stable main' | sudo tee /etc/apt/sources.list.d/elasticsearch.list
apt-get update && apt-get install elasticsearch
update-rc.d elasticsearch defaults 95 10
# vi /etc/elasticsearch/elasticsearch.yml
service elasticsearch restart
}
logstash_install () {
# wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add -
echo "deb http://packages.elasticsearch.org/logstash/1.4/debian stable main" > /etc/apt/sources.list.d/logstash.list
# echo 'deb http://packages.elasticsearch.org/logstash/1.4/debian stable main' | sudo tee /etc/apt/sources.list.d/logstash.list
apt-get update && apt-get install logstash logstash-contrib
update-rc.d logstash defaults
service logstash restart
}
kibana_install () {
cd ~
wget https://download.elasticsearch.org/kibana/kibana/kibana-latest.tar.gz
tar xvf kibana-latest.tar.gz
mv kibana-latest/* /var/www/
rmdir kibana-latest
cp -pf /vagrant/files/kibana/config.js /var/www/config.js
chown www-data.www-data /var/www
a2dissite 000-default.conf
cp -pf /vagrant/files/apache/kibana.conf /etc/apache2/sites-available/kibana.conf
a2ensite kibana.conf
service apache2 reload
}
# ----- MAIN -----------
apt_install
collectd_install
apache_install
elasticsearch_install
logstash_install
kibana_install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment