Update setup_server_laravel.sh

This commit is contained in:
HHF Technology 2024-12-01 15:25:21 +05:30
parent 80859182a9
commit a9bbaf40d9

View file

@ -307,21 +307,56 @@ crontab_content="################## START $domain ####################
# Setup monitoring (Prometheus + Node Exporter)
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'
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
ENDOFPROMETHEUS
systemctl enable prometheus node-exporter
systemctl start prometheus node-exporter
# Start and enable services
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
log_message "INFO" "Installing Fail2Ban..."