Update setup_server_laravel.sh
This commit is contained in:
parent
80859182a9
commit
a9bbaf40d9
1 changed files with 39 additions and 4 deletions
|
@ -307,21 +307,56 @@ crontab_content="################## START $domain ####################
|
||||||
|
|
||||||
# Setup monitoring (Prometheus + Node Exporter)
|
# Setup monitoring (Prometheus + Node Exporter)
|
||||||
log_message "INFO" "Setting up monitoring..."
|
log_message "INFO" "Setting up monitoring..."
|
||||||
apt-get install -y prometheus node-exporter
|
|
||||||
|
|
||||||
# Configure Prometheus
|
# Install Prometheus
|
||||||
|
apt-get install -y prometheus
|
||||||
|
|
||||||
|
# Install Node Exporter manually
|
||||||
|
log_message "INFO" "Installing Node Exporter..."
|
||||||
|
NODE_EXPORTER_VERSION="1.7.0"
|
||||||
|
wget -q https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
|
||||||
|
tar xzf node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
|
||||||
|
mv node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64/node_exporter /usr/local/bin/
|
||||||
|
rm -rf node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64*
|
||||||
|
|
||||||
|
# Create Node Exporter systemd service
|
||||||
|
cat > /etc/systemd/system/node_exporter.service << 'ENDOFSERVICE'
|
||||||
|
[Unit]
|
||||||
|
Description=Node Exporter
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=root
|
||||||
|
ExecStart=/usr/local/bin/node_exporter
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
ENDOFSERVICE
|
||||||
|
|
||||||
|
# Configure Prometheus to scrape Node Exporter
|
||||||
cat > /etc/prometheus/prometheus.yml << 'ENDOFPROMETHEUS'
|
cat > /etc/prometheus/prometheus.yml << 'ENDOFPROMETHEUS'
|
||||||
global:
|
global:
|
||||||
scrape_interval: 15s
|
scrape_interval: 15s
|
||||||
|
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
|
- job_name: 'prometheus'
|
||||||
|
static_configs:
|
||||||
|
- targets: ['localhost:9090']
|
||||||
|
|
||||||
- job_name: 'node'
|
- job_name: 'node'
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ['localhost:9100']
|
- targets: ['localhost:9100']
|
||||||
ENDOFPROMETHEUS
|
ENDOFPROMETHEUS
|
||||||
|
|
||||||
systemctl enable prometheus node-exporter
|
# Start and enable services
|
||||||
systemctl start prometheus node-exporter
|
systemctl daemon-reload
|
||||||
|
systemctl enable node_exporter
|
||||||
|
systemctl start node_exporter
|
||||||
|
systemctl enable prometheus
|
||||||
|
systemctl restart prometheus
|
||||||
|
|
||||||
|
log_message "INFO" "Monitoring setup completed successfully"
|
||||||
|
|
||||||
# Install Fail2Ban
|
# Install Fail2Ban
|
||||||
log_message "INFO" "Installing Fail2Ban..."
|
log_message "INFO" "Installing Fail2Ban..."
|
||||||
|
|
Loading…
Reference in a new issue