https://github.com/bocaletto-luca/server-gen
Server Generator Author: Bocaletto Luca Server-Gen is a multi-platform Go application that collects system metrics (IP, OS, CPU, memory, users) and emails a templated report on a configurable schedule. It also exposes a /healthz endpoint for basic health checks.
https://github.com/bocaletto-luca/server-gen
admin admin-tools administration auto-mail auto-send-message bocaletto-luca generator information linux opensource send-mail sendmail server server-generator system tools windows
Last synced: 13 days ago
JSON representation
Server Generator Author: Bocaletto Luca Server-Gen is a multi-platform Go application that collects system metrics (IP, OS, CPU, memory, users) and emails a templated report on a configurable schedule. It also exposes a /healthz endpoint for basic health checks.
- Host: GitHub
- URL: https://github.com/bocaletto-luca/server-gen
- Owner: bocaletto-luca
- License: gpl-3.0
- Created: 2025-06-13T06:33:40.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-06-13T07:00:33.000Z (11 months ago)
- Last Synced: 2025-06-13T07:36:23.027Z (11 months ago)
- Topics: admin, admin-tools, administration, auto-mail, auto-send-message, bocaletto-luca, generator, information, linux, opensource, send-mail, sendmail, server, server-generator, system, tools, windows
- Language: Go
- Homepage: https://bocaletto-luca.github.io/
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Server Generator
#### Author: Bocaletto Luca
**Server-Gen** is a multi-platform Go application that collects system metrics (IP, OS, CPU, memory, users) and emails a templated report on a configurable schedule. It also exposes a `/healthz` endpoint for basic health checks.
---
## π Features
- Cron-style scheduling (`@every 30m`, `0 8 * * *`, etc.)
- Collects:
- Network interfaces & IPs
- Hostname & OS version
- CPU utilization
- Memory usage
- Active users
- Sends HTML/text email via SMTP with TLS + retry
- Configuration via YAML + environmentβvariable overrides
- Built-in HTTP health endpoint (`/healthz`)
- Structured JSON+console logging (zerolog)
- Docker multi-stage build
- CI with GitHub Actions (matrix builds, tests, linting)
---
## π Repository Layout
```
server-gen/
βββ .github/
β βββ workflows/ci.yml
βββ cmd/
β βββ server-gen/
β βββ main.go
βββ configs/
β βββ config.yaml
βββ internal/
β βββ config/
β β βββ config.go
β βββ mailer/
β β βββ mailer.go
β βββ sysinfo/
β βββ sysinfo.go
βββ Dockerfile
βββ go.mod
βββ README.md
```
---
## βοΈ Requirements
- Go β₯ 1.21
- Docker (optional)
- SMTP server (StartTLS or SMTPS)
---
## π§ Installation
```bash
# Clone the repo
git clone https://github.com/bocaletto-luca/server-gen.git
cd server-gen
# Build binary
go build -o server-gen ./cmd/server-gen
```
---
## π οΈ Configuration
Copy `configs/config.yaml` and fill in your settings. You can also override any value via environment variables.
```yaml
# configs/config.yaml
schedule: "@every 30m"
smtp:
host: "${SMTP_HOST}"
port: ${SMTP_PORT}
username: "${SMTP_USER}"
password: "${SMTP_PASS}"
from: "${SMTP_FROM}"
to:
- "${SMTP_TO1}"
- "${SMTP_TO2}"
modules:
- ip
- os
- cpu
- mem
- users
http:
addr: ":8080"
```
**Env vars**
```bash
export SMTP_HOST=smtp.example.com
export SMTP_PORT=587
export SMTP_USER=alert@example.com
export SMTP_PASS=supersecret
export SMTP_FROM=alert@example.com
export SMTP_TO1=admin1@example.com
export SMTP_TO2=admin2@example.com
```
---
## βΆοΈ Usage
```bash
./server-gen --config configs/config.yaml
```
- The app starts an HTTP server on `http://localhost:8080/healthz`.
- It schedules jobs per `schedule` in the config.
- Each run gathers metrics and emails the report.
---
## π³ Docker
Build and run with Docker:
```bash
# Build image
docker build -t bocaletto-luca/server-gen .
# Run container
docker run -d \
-v $(pwd)/configs/config.yaml:/app/configs/config.yaml:ro \
-e SMTP_HOST -e SMTP_PORT -e SMTP_USER -e SMTP_PASS \
-e SMTP_FROM -e SMTP_TO1 -e SMTP_TO2 \
--name server-gen \
bocaletto-luca/server-gen
```
---
## π§ͺ Testing & CI
- **Unit tests**:
```bash
go test ./internal/config
go test ./internal/sysinfo
go test ./internal/mailer
```
- **Lint & vet**:
```bash
go vet ./...
```
- **GitHub Actions** runs tests & builds for Go 1.19β1.21.
---
## π€ Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feat/your-feature`)
3. Commit your changes (`git commit -m "feat: ..."`); run tests
4. Push to your branch (`git push origin feat/your-feature`)
5. Open a Pull Request
---
## π License
This project is licensed under the **MGPL License**.
See [LICENSE](LICENSE) for details.