Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script is basically for AMD64 based OS
- # Apt commands to get all of the common netutils
- # and necessary for the further process of configuration.
- apt-get -y update && apt-get install -y nano \\
- && apt-get install -y curl \\
- && apt-get install -y net-tools \\
- && apt-get install -y nc \\
- && apt-get install -y unzip \\
- && apt-get install -y traceroute
- # All binaries and monitoring PGL stack applications
- # are contained in /home/MONITORING path
- cd /home/
- mkdir MONITORING
- cd MONITORING/
- # =================================================
- # Prometheus Server
- # =================================================
- 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 /home/MONITORING/prometheus-2.32.1.linux-amd64/prometheus.yml <<EOF
- # Global scrape interval settings
- global:
- scrape_interval: 10s
- evaluation_interval: 10s
- # Prometheus can also alert about exceeding the trasholds
- alerting:
- alertmanagers:
- - static_configs:
- - targets:
- # Here is the place to include rule files
- rule_files:
- # How the scraping is being done
- scrape_configs:
- # Scrape local prometheus metrics about collecting metrics ;)
- - job_name: "prometheus"
- static_configs:
- - targets: ["localhost:9090"]
- EOF
- touch /etc/systemd/system/prometheus.service
- tee /etc/systemd/system/prometheus.service << EOF
- [Unit]
- Description=System service for Prometheus Server
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/home/MONITORING/prometheus-2.32.1.linux-amd64/prometheus --config.file=/home/MONITORING/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
- # =================================================
- 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 /home/MONITORING/loki-config.yaml << EOF
- 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
- touch /etc/systemd/system/loki.service
- tee /etc/systemd/system/loki.service << EOF
- [Unit]
- Description=System service for Loki Server
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/home/MONITORING/loki-linux-amd64 -config.file=/home/MONITORING/loki-config.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 prometheus.service
- systemctl start prometheus.service
- # ====================================================
- # Grafana Server
- # ===================================================
- wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.3.4.linux-amd64.tar.gz
- tar -zxvf grafana-enterprise-8.3.4.linux-amd64.tar.gz
- rm -f grafana-enterprise-8.3.4.linux-amd64.tar.gz
- touch /etc/systemd/system/grafana.service
- tee /etc/systemd/system/grafana.service << EOF
- [Unit]
- Description=System service for Grafana Server maintaining
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/home/MONITORING/grafana-8.3.4/grafana-server
- User=root
- Restart=on-failure
- RestartSec=10
- KillMode=process
- [Install]
- WantedBy=multi-user.target
- EOF
- chmod 640 /etc/systemd/system/grafana.service
- systemctl daemon-reload
- systemctl enable grafana.service
- systemctl start grafana.service
- # TODO - automatyzacja wprowadzania statycznych targetow
- # TODO - wariacja dla systemów Windows (w sumie po chuj?)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement