From a9bbaf40d95efa16fe71c29f499f9de37e2a3df6 Mon Sep 17 00:00:00 2001 From: hhf Date: Sun, 1 Dec 2024 15:25:21 +0530 Subject: [PATCH] Update setup_server_laravel.sh --- setup_server_laravel.sh | 43 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/setup_server_laravel.sh b/setup_server_laravel.sh index 2c822ef..7516205 100644 --- a/setup_server_laravel.sh +++ b/setup_server_laravel.sh @@ -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..."