Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- :<<'END'
- Written on 04.02.2022 by Pawel Gasiewski aka Syklighty for Hawe Telekom sp.z.o.o
- Versions of installed software are up to date and working for a date above.
- Software is designated for Linux AMD64 architecture.
- ____ _ _ _ _ _
- / ___|| | ___ _| (_) __ _| |__ | |_ _ _
- \___ \| |/ / | | | | |/ _` | '_ \| __| | | |
- ___) | <| |_| | | | (_| | | | | |_| |_| |
- |____/|_|\_\\__, |_|_|\__, |_| |_|\__|\__, |
- |___/ |___/ |___/
- END
- # =======================================================================================
- # =======================================================================================
- GREEN='\033[0;32m'
- RED='\033[0;31m'
- NC='\033[0m'
- # =======================================================================================
- cd /usr/local/bin
- apt-get install -y unzip > /dev/null
- PS3='Please enter what do you want to install: '
- options=("Promtail" "Grafana Server" "Prometheus Server" "Loki Server" "Node Exporter" "Quit")
- select opt in "${options[@]}"
- do
- # CASES - OPTIONS
- case $opt in
- # =======================================================================================
- "Promtail")
- echo -e "${GREEN}OK. Installing Promtail and adding system service${NC} \n"
- wget https://github.com/grafana/loki/releases/download/v2.4.2/promtail-linux-amd64.zip
- unzip promtail-linux-amd64.zip
- rm -f promtail-linux-amd64.zip
- touch config-promtail.yaml
- tee /etc/systemd/system/promtail.service << EOF > /dev/null
- [Unit]
- Description=System service for Promtail - Loki agent for pushing logs
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/usr/local/bin/promtail-linux-amd64 -config.file=/usr/local/bin/config-promtail.yaml
- User=root
- Restart=on-failure
- RestartSec=10
- KillMode=process
- [Install]
- WantedBy=multi-user.target
- EOF
- chmod 640 /etc/systemd/system/promtail.service
- systemctl daemon-reload
- systemctl enable promtail.service
- echo -e "${RED}! UWAGA !${NC}\n"
- echo -e "${GREEN} Powyzsza instalacja nie zawiera konfiguracji Promtaila!${NC}\n"
- echo -e "${GREEN} Promtail powinien być skonfigurowany indywidualnie wedle potrzeb uzytkownika${NC}\n"
- echo -e "${GREEN} Edytuj plik /usr/local/bin/config-promtail.yaml${NC}\n"
- echo -e "${GREEN} A nastepnie uruchom serwis - ${NC}${RED} systemctl start promtail${NC}\n"
- ;;
- # =======================================================================================
- "Grafana Server")
- echo -e "${GREEN}OK. Installing Grafana Server and adding system service${NC} \n"
- apt-get install -y adduser libfontconfig1
- wget https://dl.grafana.com/enterprise/release/grafana-enterprise_8.3.4_amd64.deb
- dpkg -i grafana-enterprise_8.3.4_amd64.deb
- rm -f grafana-enterprise_8.3.4_amd64.deb
- systemctl daemon-reload
- systemctl enable grafana-server
- systemctl start grafana-server
- ;;
- # =======================================================================================
- "Prometheus Server")
- echo -e "${GREEN}OK. Installing Prometheus Server with default config and adding system service${NC} \n"
- wget https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz
- tar -xvzf prometheus-2.32.1.linux-amd64.tar.gz
- rm -f prometheus-2.32.1.linux-amd64.tar.gz
- tee /etc/systemd/system/prometheus.service << EOF > /dev/null
- [Unit]
- Description=System service for Prometheus Server
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/usr/local/bin/prometheus-2.32.1.linux-amd64/prometheus --config.file=/usr/local/bin/prometheus-2.32.1.linux-amd64/prometheus.yml
- User=root
- Restart=on-failure
- RestartSec=10
- KillMode=process
- [Install]
- WantedBy=multi-user.target
- EOF
- chmod 640 /etc/systemd/system/prometheus.service
- systemctl daemon-reload
- systemctl enable prometheus.service
- systemctl start prometheus.service
- ;;
- # =======================================================================================
- "Loki Server")
- echo -e "${GREEN}OK. Installing Loki Server with default config and adding systems service ${NC} \n"
- wget https://github.com/grafana/loki/releases/download/v2.4.2/loki-linux-amd64.zip
- unzip loki-linux-amd64.zip
- rm -f loki-linux-amd64.zip
- tee config-loki.yaml << EOF > /dev/null
- auth_enabled: false
- server:
- http_listen_port: 3100
- grpc_listen_port: 9096
- common:
- path_prefix: /tmp/loki
- storage:
- filesystem:
- chunks_directory: /tmp/loki/chunks
- rules_directory: /tmp/loki/rules
- replication_factor: 1
- ring:
- instance_addr: 127.0.0.1
- kvstore:
- store: inmemory
- schema_config:
- configs:
- - from: 2020-10-24
- store: boltdb-shipper
- object_store: filesystem
- schema: v11
- index:
- prefix: index_
- period: 24h
- ruler:
- alertmanager_url: http://localhost:9093
- EOF
- tee /etc/systemd/system/loki.service << EOF > /dev/null
- [Unit]
- Description=System service for Loki Server
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/usr/local/bin/loki-linux-amd64 -config.file=/usr/local/bin/config-loki.yaml
- User=root
- Restart=on-failure
- RestartSec=10
- KillMode=process
- [Install]
- WantedBy=multi-user.target
- EOF
- chmod 640 /etc/systemd/system/loki.service
- systemctl daemon-reload
- systemctl enable loki.service
- systemctl start loki.service
- ;;
- # =======================================================================================
- "Node Exporter")
- echo -e "${GREEN}OK. Installing Node Exporter and adding system service${NC} \n"
- wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
- tar -xvzf node_exporter-1.3.1.linux-amd64.tar.gz
- rm -f node_exporter-1.3.1.linux-amd64.tar.gz
- cp node_exporter-1.3.1.linux-amd64/node_exporter .
- rm -r node_exporter-1.3.1.linux-amd64
- tee /etc/systemd/system/node-exporter.service << EOF > /dev/null
- [Unit]
- Description=System service Node Exporter - hardware metrics exporter
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/usr/local/bin/node_exporter
- User=root
- Restart=on-failure
- RestartSec=10
- KillMode=process
- [Install]
- WantedBy=multi-user.target
- EOF
- chmod 640 /etc/systemd/system/node-exporter.service
- systemctl daemon-reload
- systemctl enable node-exporter.service
- systemctl start node-exporter.service
- ;;
- # =======================================================================================
- "Quit")
- echo -e "${GREEN}User requsted exit${NC} \n"
- exit
- ;;
- *) echo -e "${RED}Invalid option $REPLY ${NC} \n";;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement