Advertisement
Skylighty

main-server

Jan 23rd, 2022
843
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Script is basically for AMD64 based OS
  4.  
  5. # Apt commands to get all of the common netutils
  6. # and necessary for the further process of configuration.
  7. apt-get -y update && apt-get install -y nano  \\
  8.     && apt-get install -y curl \\
  9.     && apt-get install -y net-tools \\
  10.     && apt-get install -y nc \\
  11.     && apt-get install -y unzip \\
  12.     && apt-get install -y traceroute
  13.  
  14.  
  15. # All binaries and monitoring PGL stack applications
  16. # are contained in /home/MONITORING path
  17. cd /home/
  18. mkdir MONITORING
  19. cd MONITORING/
  20.  
  21.  
  22.  
  23. # =================================================
  24. # Prometheus Server
  25. # =================================================
  26. wget https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz
  27. tar -xvzf prometheus-2.32.1.linux-amd64.tar.gz
  28. rm -f prometheus-2.32.1.linux-amd64.tar.gz
  29. tee /home/MONITORING/prometheus-2.32.1.linux-amd64/prometheus.yml <<EOF
  30. # Global scrape interval settings
  31. global:
  32.   scrape_interval: 10s
  33.   evaluation_interval: 10s
  34.  
  35. # Prometheus can also alert about exceeding the trasholds
  36. alerting:
  37.   alertmanagers:
  38.     - static_configs:
  39.         - targets:
  40.  
  41. # Here is the place to include rule files
  42. rule_files:
  43.  
  44. # How the scraping is being done
  45. scrape_configs:
  46.  
  47.     # Scrape local prometheus metrics about collecting metrics ;)
  48.   - job_name: "prometheus"
  49.     static_configs:
  50.       - targets: ["localhost:9090"]
  51. EOF
  52. touch /etc/systemd/system/prometheus.service
  53. tee /etc/systemd/system/prometheus.service << EOF
  54. [Unit]
  55. Description=System service for Prometheus Server
  56. Wants=network.target
  57. After=syslog.target network-online.target
  58.  
  59. [Service]
  60. Type=simple
  61. ExecStart=/home/MONITORING/prometheus-2.32.1.linux-amd64/prometheus --config.file=/home/MONITORING/prometheus-2.32.1.linux-amd64/prometheus.yml
  62. User=root
  63. Restart=on-failure
  64. RestartSec=10
  65. KillMode=process
  66.  
  67. [Install]
  68. WantedBy=multi-user.target
  69. EOF
  70. chmod 640 /etc/systemd/system/prometheus.service
  71. systemctl daemon-reload
  72. systemctl enable prometheus.service
  73. systemctl start prometheus.service
  74.  
  75.  
  76.  
  77.  
  78. # =================================================
  79. # Loki Server
  80. # =================================================
  81. wget https://github.com/grafana/loki/releases/download/v2.4.2/loki-linux-amd64.zip
  82. unzip loki-linux-amd64.zip
  83. rm -f loki-linux-amd64.zip
  84. tee /home/MONITORING/loki-config.yaml << EOF
  85. auth_enabled: false
  86.  
  87. server:
  88.   http_listen_port: 3100
  89.   grpc_listen_port: 9096
  90.  
  91. common:
  92.   path_prefix: /tmp/loki
  93.   storage:
  94.     filesystem:
  95.       chunks_directory: /tmp/loki/chunks
  96.       rules_directory: /tmp/loki/rules
  97.   replication_factor: 1
  98.   ring:
  99.     instance_addr: 127.0.0.1
  100.     kvstore:
  101.       store: inmemory
  102.  
  103. schema_config:
  104.   configs:
  105.     - from: 2020-10-24
  106.       store: boltdb-shipper
  107.       object_store: filesystem
  108.       schema: v11
  109.       index:
  110.         prefix: index_
  111.         period: 24h
  112.  
  113. ruler:
  114.   alertmanager_url: http://localhost:9093
  115. EOF
  116. touch /etc/systemd/system/loki.service
  117. tee /etc/systemd/system/loki.service << EOF
  118. [Unit]
  119. Description=System service for Loki Server
  120. Wants=network.target
  121. After=syslog.target network-online.target
  122.  
  123. [Service]
  124. Type=simple
  125. ExecStart=/home/MONITORING/loki-linux-amd64 -config.file=/home/MONITORING/loki-config.yaml
  126. User=root
  127. Restart=on-failure
  128. RestartSec=10
  129. KillMode=process
  130.  
  131. [Install]
  132. WantedBy=multi-user.target
  133. EOF
  134. chmod 640 /etc/systemd/system/loki.service
  135. systemctl daemon-reload
  136. systemctl enable prometheus.service
  137. systemctl start prometheus.service
  138.  
  139.  
  140.  
  141. # ====================================================
  142. # Grafana Server
  143. # ===================================================
  144. wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.3.4.linux-amd64.tar.gz
  145. tar -zxvf grafana-enterprise-8.3.4.linux-amd64.tar.gz
  146. rm -f grafana-enterprise-8.3.4.linux-amd64.tar.gz
  147. touch /etc/systemd/system/grafana.service
  148. tee /etc/systemd/system/grafana.service << EOF
  149. [Unit]
  150. Description=System service for Grafana Server maintaining
  151. Wants=network.target
  152. After=syslog.target network-online.target
  153.  
  154. [Service]
  155. Type=simple
  156. ExecStart=/home/MONITORING/grafana-8.3.4/grafana-server
  157. User=root
  158. Restart=on-failure
  159. RestartSec=10
  160. KillMode=process
  161.  
  162. [Install]
  163. WantedBy=multi-user.target
  164. EOF
  165. chmod 640 /etc/systemd/system/grafana.service
  166. systemctl daemon-reload
  167. systemctl enable grafana.service
  168. systemctl start grafana.service
  169.  
  170. # TODO - automatyzacja wprowadzania statycznych targetow
  171. # TODO - wariacja dla systemów Windows (w sumie po chuj?)
  172.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement