SCG: Como coletar o status de integridade do SCG pela API
Summary: Como coletar o status de integridade do Gateway de conexão segura (SCG) a partir de uma consulta de interface de programação de aplicativos (API). Esse método é útil para analisar o status de todos os componentes do SCG (status de conectividade, status de keepalive, status de todos os serviços, informações do sistema de dispositivos conectados). ...
Instructions
Ele foi testado no gateway de conexão segura versão 5.10.00.10.
Veja abaixo as etapas necessárias para executar uma consulta de API ao SCG e coletar todas as informações de integridade:
- Habilite as interfaces da API REST no Secure Connect Gateway.
Você deve habilitar as interfaces da API REST no SCG para permitir a integração com suas ferramentas e aplicativos de data center.
Para ativar as interfaces API, abra o painel SCG no navegador da Web (https://<IP_SCG>:5700)), vá para Settings > API settings, marque a caixa de seleção Enable API interfaces for this gateway e clique em Apply:
- Abra uma sessão SSH no gateway SCG com o usuário root e execute os comandos abaixo:
Gerando o token de autenticação com o gateway SCG — Para executar todas as consultas de APIs ao gateway SCG, é necessário antes de obter o token de autorização. Nesse caso, obteremos o token de autorização e o armazenaremos em uma variável do sistema para facilitar as próximas consultas de API:AUTH_TOKEN=`curl -k -s -L -i -X --header "Content-Type: application/json" --request POST --data '{"username":"admin","password":"admin_password"}' 'https://10.108.0.40:5700/SupportAssist/api/v2/auth/token?accessToken' | grep "accessToken" | awk -F ":" {'print $2'} | sed 's/,$//' | sed 's/^..//' | sed 's/.$//'`Onde:- admin = usuário administrador do SCG
- admin_password = senha de administrador do SCG
- 10.108.0.40 = endereço IP do SCG
scg:~ # AUTH_TOKEN=`curl -k -s -L -i -X --header "Content-Type: application/json" --request POST --data '{"username":"admin","password":"admin_password"}' 'https://10.108.0.40:5700/SupportAssist/api/v2/auth/token?accessToken' | grep "accessToken" | awk -F ":" {'print $2'} | sed 's/,$//' | sed 's/^..//' | sed 's/.$//'` scg:~ # echo $AUTH_TOKEN eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwicm9sZSI6IlNDR0FkbWlucyIsInJlcXVlc3RpbmdJUCI6IjEwLjEwNy4wLjM5IiwiYXBwTW9kZSI6IkFQUExJQU5DRVMiLCJhcGlVc2FnZU1vZGUiOiJSZXN0IiwiaW5zdGFuY2VJRCI6ImJGMFhhdUk2MVI2REtZM3A5a0NKTHdVWlMwTGhPUjRNaVJydEhPTkgxamFxa2Zrb0xONDlGeXNraXB5ZVFjUmxsSlFyTFJQQkJtNlRZeGNTWGxleEJBPT0iLCJ0b2tlblR5cGUiOiJBQ0NFU1MiLCJ1dWlkIjoiZGFkYjYxY2EtNjNmZi00ODRlLWEwOGUtOTA0OGY0NzczYzJmIiwiaWF0IjoxNjQ4NzQzODk2LCJleHAiOjE2NDg3NDU2OTZ9.D2ziJJhc8dAyqiFIwXucluWLwsdKVSv1TqQAnt1b8KA - Executando a consulta de API para obter o status de integridade do SCG:
Com essa consulta de API, é possível ver muitas informações sobre o SCG:
- Status de conectividade
- Status de keepalive
- Status de cada serviço SCG (esrshttpd, esrshttpdR, esrsconnectemc, networkConnectivity e outros)
- Status dos dispositivos
monitorados Veja abaixo a consulta à API para coletar o status das informações de integridade:curl -k -X GET --header "Accept: application/json" --header "Authorization: Bearer $AUTH_TOKEN" https://10.108.0.40:5700/SupportAssist/api/v2/service/healthstatus?
Exemplo:scg:~ # curl -k -X GET --header "Accept: application/json" --header "Authorization: Bearer $AUTH_TOKEN" https://10.108.0.40:5700/SupportAssist/api/v2/service/healthstatus? { "data" : { "runDate" : "Mar 31, 2022 12:03:57 -EDT", "gatewayInfo" : { "serialNumber" : "XXXXXXXXXX", "productModel" : "SECURECONNECTGATEWAY-APPLIANCE", "ipAddress" : "10.108.0.40", "gatewayVersion" : "5.00.07.10" }, "connectivity" : { "mqttStatus" : { "state" : "CONNECTED", "updatedAt" : "2022-03-28T20:58:38.244+00:00", "recommendation" : "" }, "keepaliveStatus" : { "state" : "CONNECTED", "updatedAt" : "2021-11-22T04:27:05.198+0000", "recommendation" : "" } }, "services" : [ { "serviceName" : "esrshttpd", "criticality" : "Critical", "serviceType" : "Core service status", "description" : "Service to securely transfer files between your devices and secure connect gateway", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrshttpdR", "criticality" : "Critical", "serviceType" : "Core service status", "description" : "A service that manages file transfers from your gateway to Dell Technologies, or to your devices", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsconnectemc", "criticality" : "Critical", "serviceType" : "Core service status", "description" : "A service at Dell Technologies that receives alert data from your devices", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsclientproxy", "criticality" : "Warning", "serviceType" : "Core service status", "description" : "A service for connectivity between devices and Dell Technologies", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrswatchdogservice", "criticality" : "Warning", "serviceType" : "Core service status", "description" : "A service that monitors whether or not other services are running or down. When services go down unexpectedly, the watchdog service will attempt to restart them so they start functioning normally again", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrshttpdftp", "criticality" : "Critical", "serviceType" : "Core service status", "description" : "A service at Dell Technologies that receives alert data from your devices", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrshttpdlistener", "criticality" : "Critical", "serviceType" : "Core service status", "description" : "A service at Dell Technologies that receives alert data from your devices", "status" : "Running", "recommendation" : "" }, { "serviceName" : "shibd", "criticality" : "Critical", "serviceType" : "Core service status", "description" : "A Service for remote secure credentials", "status" : "Running", "recommendation" : "" }, { "serviceName" : "apache2", "criticality" : "Critical", "serviceType" : "Core service status", "description" : "A Service for remote secure credentials", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsjcemc", "criticality" : "Critical", "serviceType" : "Restful service status", "description" : "A service at Dell Technologies that receives alert data from your devices", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrskeepalive", "criticality" : "Critical", "serviceType" : "Restful service status", "description" : "Device service that sends heartbeat status from devices to Dell Technologies", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsmftauth", "criticality" : "Critical", "serviceType" : "Restful service status", "description" : "A service that transfers files between Dell, your gateway, and your devices", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsupdate", "criticality" : "Critical", "serviceType" : "Restful service status", "description" : "A service to retreives update information from Dell Technologies", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsdigitaltwinservice", "criticality" : "Critical", "serviceType" : "Restful service status", "description" : "A service for connectivity between devices and Dell Technologies", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsmqttclient", "criticality" : "Critical", "serviceType" : "Restful service status", "description" : "A service that monitors connectivity between the gateway and Dell", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsmosquitto", "criticality" : "Critical", "serviceType" : "Core service status", "description" : "A service that transfers files between your gateway local system to Dell", "status" : "Running", "recommendation" : "" }, { "serviceName" : "esrsmqttauth", "criticality" : "Critical", "serviceType" : "Restful service status", "description" : "A service that validates credentials for remote support activities", "status" : "Running", "recommendation" : "" }, { "serviceName" : "srsadapter", "description" : "A service that manages the communications between containers", "status" : "running" }, { "serviceName" : "secureconnectgateway", "description" : "A service that allows access to secure connect gateway's user interface.", "status" : "running" }, { "serviceName" : "cases", "description" : "A service that manages alerts, events, and support cases generated by your gateway.", "status" : "running" }, { "serviceName" : "auditlog", "description" : "A service that displays your gateway's activity history.", "status" : "running" }, { "serviceName" : "connectivity", "description" : "A service that manages connectivity with the Dell Technologies backend.", "status" : "running" }, { "serviceName" : "appsettings", "description" : "A service to save changes for configuration settings.", "status" : "running" }, { "serviceName" : "consoleadapter", "description" : "A service that manages connectivity with systems management consoles.", "status" : "running" }, { "serviceName" : "registration", "description" : "A service that registers your secure connect gateway.", "status" : "running" }, { "serviceName" : "collection", "description" : "A service that initiates collection of telemetry from devices, then retreives that telemetry and displays it in your gateway. ", "status" : "running" }, { "serviceName" : "inventory", "description" : "A service that retreives inventory information from devices.", "status" : "running" }, { "serviceName" : "secureconnectgatewaydb", "description" : "A service that allows access to secure connect gateway's database.", "status" : "running" }, { "serviceName" : "email", "description" : "A service that manages and sends emails from secure connect gateway.", "status" : "running" } ], "networkConnectivity" : [ { "hostName" : "esrs3-core.emc.com", "port443" : { "status" : "CONNECTED", "recommendation" : "" }, "port8443" : { "status" : "CONNECTED", "recommendation" : "" } }, { "hostName" : "esrs3-coredr.emc.com", "port443" : { "status" : "CONNECTED", "recommendation" : "" }, "port8443" : { "status" : "CONNECTED", "recommendation" : "" } } ], "systemInfo" : { "systemInfo" : "VMware, Inc.", "noOfProcessors" : 4, "memory" : { "memoryUsage" : "12.21 / 15.66 GB (78%)", "status" : "HEALTHY", "message" : "" }, "cpu" : { "cpuLoad" : "2.65%", "status" : "HEALTHY" }, "diskSpaceDetails" : [ { "partitionName" : "/dev/sda1", "availableDiskSpace" : "0.21 GB", "used" : "28%" }, { "partitionName" : "/dev/mapper/scgVG-LVRoot", "availableDiskSpace" : "13.31 GB", "used" : "13%" }, { "partitionName" : "/dev/mapper/scgVG-LVvar_lib_docker", "availableDiskSpace" : "86.77 GB", "used" : "8%" }, { "partitionName" : "/dev/mapper/scgVG-LVvar_log", "availableDiskSpace" : "7.35 GB", "used" : "6%" }, { "partitionName" : "/dev/mapper/scgVG-LVvar_lib_scgve", "availableDiskSpace" : "7.36 GB", "used" : "6%" }, { "partitionName" : "/dev/mapper/scgVG-LVopt_esrsve", "availableDiskSpace" : "7.35 GB", "used" : "6%" } ] }, "smtp" : { "status" : "Connected" } }, "email" : "Timed out after waiting 30000(ms) for a reply. address: __vertx.reply.1bd9b6f0-73e1-4f27-8f57-207c3c5577bb, repliedAddress: emailApplianceService.queue" }scg:~ #
Para salvar o relatório em um arquivo:
curl -k -X GET --header "Accept: application/json" -o report_scg.txt --header "Authorization: Bearer $AUTH_TOKEN" https://10.108.0.40:5700/SupportAssist/api/v2/service/healthstatus?
Onde:-o report_scg.txt = Esta opção é usada para salvar o resultado no "report_scg.txt" arquivo.
Importante — mecanismos de autenticação:
O processo de autenticação é iniciado quando o client faz uma solicitação de um token do servidor fornecendo suas credenciais. Em resposta, o Secure Connect Gateway retorna um token de acesso e um token de atualização. O token de atualização é válido por 24 horas, enquanto o token de acesso é válido por 30 minutos. Depois que o token de acesso expirar, você poderá gerar um novo token de acesso usando o token de atualização.
Additional Information
Guia da API REST do gateway de conexão segura: