curl -fsSL https://gist.githubusercontent.com/murilogteixeira/7e1687f4b0474b76658efa0fdf5658f0/raw/8cefc36565716ffc7e53c2b43f4d0b1a7f7a60c9/install-glances.sh | bash
Last active
July 31, 2025 02:51
-
-
Save murilogteixeira/7e1687f4b0474b76658efa0fdf5658f0 to your computer and use it in GitHub Desktop.
Install Glances on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Instalação do Glances API (Modo Servidor sem Web UI) | |
| # Execute com: sudo ./install_glances_api.sh | |
| set -e # Encerra o script em caso de erro | |
| echo "🔄 Atualizando pacotes..." | |
| sudo apt update -qq | |
| echo "📦 Instalando Glances e dependências..." | |
| sudo apt install -y glances #python3-pip curl | |
| echo "🔧 Configurando serviço systemd..." | |
| sudo tee /etc/systemd/system/glances-api.service > /dev/null <<'EOF' | |
| [Unit] | |
| Description=Glances API (Sem Web UI) | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| ExecStart=/usr/bin/glances -w --disable-webui | |
| Restart=on-failure | |
| RestartSec=5s | |
| User=root | |
| Environment="PYTHONUNBUFFERED=1" | |
| [Install] | |
| WantedBy=multi-user.target | |
| EOF | |
| echo "🔄 Recarregando serviços..." | |
| sudo systemctl daemon-reload | |
| echo "🚀 Ativando serviço..." | |
| sudo systemctl enable --now glances-api | |
| echo "⏳ Verificando status..." | |
| sleep 3 | |
| systemctl status glances-api --no-pager | |
| echo "🔍 Testando API..." | |
| curl -s http://localhost:61208/api/3/version | jq . 2>/dev/null || { | |
| echo -e "\n❌ API não respondeu, mas o serviço está ativo. Verifique com:" | |
| echo "journalctl -u glances-api -xe --no-pager" | |
| } | |
| echo -e "\n✅ Instalação concluída!" | |
| echo "📌 Endpoint: http://$(hostname -I | awk '{print $1}'):61208/api/3/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment