@yuuki824/kanshi 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +34 -0
- package/Dockerfile +53 -0
- package/LICENSE +661 -0
- package/README.md +219 -0
- package/bin/kanshi.js +63 -0
- package/docker-compose.yml +84 -0
- package/go.mod +3 -0
- package/internal/access/access.go +275 -0
- package/internal/access/listeners.go +229 -0
- package/internal/config/config.go +256 -0
- package/internal/config/defaults_other.go +5 -0
- package/internal/config/defaults_windows.go +4 -0
- package/internal/config/envfile.go +147 -0
- package/internal/dockerstats/dial.go +32 -0
- package/internal/dockerstats/dial_other.go +13 -0
- package/internal/dockerstats/dial_windows.go +62 -0
- package/internal/dockerstats/dockerstats.go +626 -0
- package/internal/roots/roots.go +175 -0
- package/internal/roots/roots_linux.go +132 -0
- package/internal/roots/roots_windows.go +74 -0
- package/internal/server/access.go +155 -0
- package/internal/server/server.go +523 -0
- package/internal/server/static.go +165 -0
- package/internal/storage/cache.go +283 -0
- package/internal/storage/dir_linux.go +177 -0
- package/internal/storage/dir_windows.go +244 -0
- package/internal/storage/statat_fast.go +21 -0
- package/internal/storage/statat_other.go +11 -0
- package/internal/storage/storage.go +598 -0
- package/internal/storage/sysnum_amd64.go +7 -0
- package/internal/storage/sysnum_generic.go +7 -0
- package/internal/storage/walk.go +342 -0
- package/internal/vitals/vitals.go +246 -0
- package/internal/vitals/vitals_linux.go +548 -0
- package/internal/vitals/vitals_windows.go +286 -0
- package/main.go +129 -0
- package/main_other.go +11 -0
- package/main_windows.go +29 -0
- package/package.json +49 -0
- package/web/app.js +835 -0
- package/web/apple-touch-icon.png +0 -0
- package/web/icon.svg +6 -0
- package/web/index.html +151 -0
- package/web/style.css +356 -0
- package/web/treemap.js +217 -0
package/.env.example
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copy to .env (Docker Compose) or kanshi.env (the standalone binary) to
|
|
2
|
+
# override. Every value here is the built-in default.
|
|
3
|
+
|
|
4
|
+
# Who can open the dashboard. This computer (localhost) always can. Add any of:
|
|
5
|
+
# lan other devices on your local network, wired or Wi-Fi
|
|
6
|
+
# tailscale your devices on your tailnet
|
|
7
|
+
# all every interface — kanshi has no login, so only behind a firewall
|
|
8
|
+
# Combine with commas, e.g. KANSHI_ACCESS=lan,tailscale
|
|
9
|
+
KANSHI_ACCESS=local
|
|
10
|
+
KANSHI_PORT=8100
|
|
11
|
+
|
|
12
|
+
# Live metrics
|
|
13
|
+
KANSHI_POLL_INTERVAL=5
|
|
14
|
+
KANSHI_DOCKER_CONCURRENCY=8
|
|
15
|
+
KANSHI_IDLE_TIMEOUT=30
|
|
16
|
+
|
|
17
|
+
# Storage map. "auto" is / plus every drive under /mnt on Linux, or C:\, your
|
|
18
|
+
# user folder and every other fixed drive on Windows. List paths to replace
|
|
19
|
+
# that, or mix: auto,/srv
|
|
20
|
+
KANSHI_STORAGE_ROOTS=auto
|
|
21
|
+
# A cached folder size older than this many seconds is measured again the next
|
|
22
|
+
# time the folder around it is opened.
|
|
23
|
+
KANSHI_STORAGE_INTERVAL=21600
|
|
24
|
+
# Paths to skip entirely, comma separated. The biggest win on a Docker host is
|
|
25
|
+
# /var/lib/docker — ~100k overlay2 files.
|
|
26
|
+
KANSHI_STORAGE_EXCLUDE=
|
|
27
|
+
# Share of one core, in percent, the walk may average. 100 = unthrottled.
|
|
28
|
+
KANSHI_STORAGE_CPU=25
|
|
29
|
+
# Folder levels remembered from each measurement. Deeper folders are measured
|
|
30
|
+
# when they are opened.
|
|
31
|
+
KANSHI_TREE_DEPTH=4
|
|
32
|
+
# Where folder sizes are cached. Defaults to ~/.cache/kanshi/storage.cache on
|
|
33
|
+
# Linux and %LocalAppData%\kanshi\storage.cache on Windows.
|
|
34
|
+
#KANSHI_STORAGE_CACHE=
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Build stage. It always runs on the build machine's own architecture and
|
|
2
|
+
# cross-compiles for the target, which Go does natively — so a multi-arch
|
|
3
|
+
# image builds at full speed with no QEMU emulation. The module has no
|
|
4
|
+
# third-party dependencies, so there is nothing to download.
|
|
5
|
+
FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS build
|
|
6
|
+
|
|
7
|
+
ARG TARGETOS=linux
|
|
8
|
+
ARG TARGETARCH
|
|
9
|
+
ARG VERSION=dev
|
|
10
|
+
|
|
11
|
+
WORKDIR /src
|
|
12
|
+
COPY go.mod ./
|
|
13
|
+
COPY main.go main_other.go ./
|
|
14
|
+
COPY internal ./internal
|
|
15
|
+
COPY web ./web
|
|
16
|
+
|
|
17
|
+
# CGO off because nothing here needs libc: /proc is read as plain files and the
|
|
18
|
+
# Docker socket is a plain unix socket. That is what makes a scratch image
|
|
19
|
+
# possible at all.
|
|
20
|
+
ENV CGO_ENABLED=0
|
|
21
|
+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath \
|
|
22
|
+
-ldflags="-s -w -X main.version=${VERSION}" -o /kanshi .
|
|
23
|
+
|
|
24
|
+
# Runtime stage. The web assets are embedded in the binary, so the image is one
|
|
25
|
+
# static file and nothing else — no shell, no package manager, no CVE surface.
|
|
26
|
+
FROM scratch
|
|
27
|
+
|
|
28
|
+
ARG VERSION=dev
|
|
29
|
+
LABEL org.opencontainers.image.title="kanshi" \
|
|
30
|
+
org.opencontainers.image.description="A one-page, mobile-first glance at a homeserver: CPU, memory, a storage treemap and Docker containers." \
|
|
31
|
+
org.opencontainers.image.source="https://github.com/rene-roid/kanshi" \
|
|
32
|
+
org.opencontainers.image.licenses="AGPL-3.0-only" \
|
|
33
|
+
org.opencontainers.image.version="${VERSION}"
|
|
34
|
+
|
|
35
|
+
COPY --from=build /kanshi /kanshi
|
|
36
|
+
|
|
37
|
+
# The Compose file mounts the host's / here; the storage map then finds the
|
|
38
|
+
# host's drives under /hostfs/mnt on its own.
|
|
39
|
+
ENV KANSHI_HOST_ROOT=/hostfs
|
|
40
|
+
|
|
41
|
+
# Folder sizes are cached here so a restart does not walk the disk again. The
|
|
42
|
+
# root filesystem is read-only, so this has to be a volume.
|
|
43
|
+
ENV KANSHI_STORAGE_CACHE=/data/storage.cache
|
|
44
|
+
VOLUME /data
|
|
45
|
+
|
|
46
|
+
EXPOSE 8100
|
|
47
|
+
|
|
48
|
+
# The probe is the binary itself: a scratch image has no curl to call. It asks
|
|
49
|
+
# 127.0.0.1, which is listened on in every access mode.
|
|
50
|
+
HEALTHCHECK --interval=60s --timeout=5s --start-period=10s --retries=3 \
|
|
51
|
+
CMD ["/kanshi", "-healthcheck"]
|
|
52
|
+
|
|
53
|
+
ENTRYPOINT ["/kanshi"]
|