Skip to content

Commit 4d0ca59

Browse files
Expose Docker host environment metrics
1 parent e6cec2f commit 4d0ca59

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎internal/docker/reader.go‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ import (
1212

1313
type Reader struct{ client *client.Client }
1414
type Snapshot struct {
15-
Available bool `json:"available"`
16-
Message string `json:"message,omitempty"`
17-
EngineVersion string `json:"engine_version,omitempty"`
18-
Containers int `json:"containers"`
19-
Running int `json:"running"`
20-
Images int `json:"images"`
21-
Swarm Swarm `json:"swarm"`
15+
Available bool `json:"available"`
16+
Message string `json:"message,omitempty"`
17+
EngineVersion string `json:"engine_version,omitempty"`
18+
Containers int `json:"containers"`
19+
Running int `json:"running"`
20+
Images int `json:"images"`
21+
OperatingSystem string `json:"operating_system,omitempty"`
22+
CPUs int `json:"cpus,omitempty"`
23+
MemoryBytes int64 `json:"memory_bytes,omitempty"`
24+
Swarm Swarm `json:"swarm"`
2225
}
2326
type Swarm struct {
2427
Active bool `json:"active"`
@@ -78,6 +81,9 @@ func (r *Reader) Snapshot(ctx context.Context) Snapshot {
7881
out.Containers = info.Containers
7982
out.Running = info.ContainersRunning
8083
out.Images = info.Images
84+
out.OperatingSystem = info.OperatingSystem
85+
out.CPUs = info.NCPU
86+
out.MemoryBytes = info.MemTotal
8187
}
8288
swarm, err := r.client.SwarmInspect(ctx)
8389
if err != nil {

‎web/src/views/Setup.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<script setup lang="ts">import {onMounted,ref} from 'vue';import {useRouter} from 'vue-router';const router=useRouter(),step=ref(1),name=ref(''),email=ref(''),password=ref(''),error=ref(''),environment=ref<any>({});onMounted(async()=>{environment.value=(await (await fetch('/api/v1/setup/status')).json()).infrastructure||{}});async function submit(){const r=await fetch('/api/v1/setup/admin',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({name:name.value,email:email.value,password:password.value})});if(r.ok)step.value=4;else error.value='Revise os dados informados.'}</script>
2-
<template><div class="center"><p class="kicker">STEP {{step}} OF 4 · STACKHOST SETUP</p><div v-if="step===1"><h1>Build your control plane.</h1><p class="muted">A calm, reliable home for your infrastructure.</p><div class="empty"><h2>Welcome to StackHost</h2><p>We will create your administrator and check the environment in a few seconds.</p><button class="primary" @click="step=2">Get started</button></div></div><div v-else-if="step===2"><h1>Create your administrator.</h1><p class="muted">This account will manage this local environment.</p><form @submit.prevent="step=3"><label>Name<input v-model="name" required /></label><label>Email<input v-model="email" type="email" required /></label><label>Password<input v-model="password" type="password" minlength="8" required /></label><button class="primary">Continue</button></form></div><div v-else-if="step===3"><h1>Check your environment.</h1><p class="muted">Docker is optional for onboarding and can be connected later.</p><div class="status"><span class="dot"></span><div><strong>{{environment.available?'Docker connected':'Docker optional'}}</strong><p>{{environment.available?`Docker ${environment.engine_version} detected`:'The panel can continue without Docker.'}}</p></div><span class="pill">{{environment.swarm?.active?'Swarm ready':'No Swarm'}}</span></div><button class="primary" @click="submit">Create administrator</button></div><div v-else><h1>You are ready.</h1><p class="muted">Your administrator account is active.</p><div class="empty"><h2>Welcome aboard</h2><p>Open the dashboard to start organizing your projects.</p><button class="primary" @click="router.push('/')">Open dashboard</button></div></div><p class="error">{{error}}</p></div></template>
2+
<template><div class="center"><p class="kicker">STEP {{step}} OF 4 · STACKHOST SETUP</p><div v-if="step===1"><h1>Build your control plane.</h1><p class="muted">A calm, reliable home for your infrastructure.</p><div class="empty"><h2>Welcome to StackHost</h2><p>We will create your administrator and check the environment in a few seconds.</p><button class="primary" @click="step=2">Get started</button></div></div><div v-else-if="step===2"><h1>Create your administrator.</h1><p class="muted">This account will manage this local environment.</p><form @submit.prevent="step=3"><label>Name<input v-model="name" required /></label><label>Email<input v-model="email" type="email" required /></label><label>Password<input v-model="password" type="password" minlength="8" required /></label><button class="primary">Continue</button></form></div><div v-else-if="step===3"><h1>Check your environment.</h1><p class="muted">Docker is optional for onboarding and can be connected later.</p><div class="status"><span class="dot"></span><div><strong>{{environment.available?'Docker connected':'Docker optional'}}</strong><p>{{environment.available?`Docker ${environment.engine_version} · ${environment.operating_system||'OS unavailable'} · ${environment.cpus||'—'} CPUs · ${environment.memory_bytes?Math.round(environment.memory_bytes/1073741824)+' GB memory':'memory unavailable'}`:'The panel can continue without Docker.'}}</p></div><span class="pill">{{environment.swarm?.active?'Swarm ready':'No Swarm'}}</span></div><button class="primary" @click="submit">Create administrator</button></div><div v-else><h1>You are ready.</h1><p class="muted">Your administrator account is active.</p><div class="empty"><h2>Welcome aboard</h2><p>Open the dashboard to start organizing your projects.</p><button class="primary" @click="router.push('/')">Open dashboard</button></div></div><p class="error">{{error}}</p></div></template>

0 commit comments

Comments
 (0)