HANDS-ON TASK · 1 OF 1

Fleet report binary

Project: Fleet report binary

This is the capstone. You are shipping a small tool that other engineers at esc bash will run on any machine - it reads an inventory of servers, records where it ran, and prints a summary as JSON. It has to be a single self contained binary with no runtime dependencies, so you will build it static, the way you would to drop it into a scratch container.

Set up the project

Run this first. It seeds the server inventory:

bash
curl -fsSL https://raw.githubusercontent.com/Esc-Bash/project-init-scripts/main/go/project-3/init.sh | bash

This creates /root/mission/servers.json and the /root/answers folder. The inventory is a JSON array of servers, each with a name and a CPU count:

[
  {"name": "web1", "cpu": 2},
  {"name": "web2", "cpu": 4},
  {"name": "db1", "cpu": 8}
]

What to build

Create a Go module at /root/fleetreport with a main.go. The program reads /root/mission/servers.json, counts the servers, sums their CPU counts, records the machine's hostname, and writes /root/answers/fleet.json with this exact shape:

{
  "server_count": <number of servers>,
  "total_cpu": <sum of every server's cpu>,
  "generated_by": "<this machine's hostname>"
}

Get the hostname with os.Hostname (or by running the hostname command through os/exec), and build the JSON with encoding/json.

Then compile it into a single static Linux binary named fleetreport, sitting next to your source at /root/fleetreport/fleetreport. Build it static so it carries no libc dependency, the way the building and shipping topic covered. Run that binary so it writes the report:

/root/fleetreport/fleetreport

Press Submit when the binary is built, runs, and the report is correct.

Start the lab on the right to run checks.

Pass the checks to continue
Spin up a fresh environment and practice live.
go · fresh machine · ready in under a minute