From 266c95f857dcdd0f3581656afc69ef482d264247 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Fri, 18 Sep 2020 09:23:39 -0600 Subject: [PATCH] fix #3 Make sure that the collector attempts to correctly communicate with webapp container, even when running in dedicated container (and triggered manually). fixes cron schedule to run daily. added instructions for dedicated containers. --- README.md | 13 +++++++++++++ .../cmd/collector-metrics/collector-metrics.go | 12 +++++++----- .../cmd/collector-selftest/collector-selftest.go | 12 +++++++----- docker/Dockerfile.web | 2 +- rootfs/scrutiny/jobber/jobber.yaml | 4 ++-- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5502a72..464008c 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,19 @@ In addition to the Omnibus image (available under the `latest` tag) there are 2 - `analogj/scrutiny:collector` - Contains the Scrutiny data collector, `smartctl` binary and cron-like scheduler. You can run one collector on each server. - `analogj/scrutiny:web` - Contains the Web UI, API and Database. Only one container necessary +```bash +docker run -it --rm -p 8080:8080 \ +--name scrutiny-web \ +analogj/scrutiny:web + +docker run -it --rm \ +-v /run/udev:/run/udev:ro \ +-v /dev/disk:/dev/disk \ +-e SCRUTINY_API_ENDPOINT=http://SCRUTINY_WEB_IPADDRESS:8080 \ +--name scrutiny-collector \ +--privileged analogj/scrutiny:collector +``` + ## Usage diff --git a/collector/cmd/collector-metrics/collector-metrics.go b/collector/cmd/collector-metrics/collector-metrics.go index 135f7f0..c7f76ac 100644 --- a/collector/cmd/collector-metrics/collector-metrics.go +++ b/collector/cmd/collector-metrics/collector-metrics.go @@ -99,14 +99,16 @@ OPTIONS: Flags: []cli.Flag{ &cli.StringFlag{ - Name: "api-endpoint", - Usage: "The api server endpoint", - Value: "http://localhost:8080", + Name: "api-endpoint", + Usage: "The api server endpoint", + Value: "http://localhost:8080", + EnvVars: []string{"SCRUTINY_API_ENDPOINT"}, }, &cli.BoolFlag{ - Name: "debug", - Usage: "Enable debug logging", + Name: "debug", + Usage: "Enable debug logging", + EnvVars: []string{"DEBUG"}, }, }, }, diff --git a/collector/cmd/collector-selftest/collector-selftest.go b/collector/cmd/collector-selftest/collector-selftest.go index 63500d6..3800a5f 100644 --- a/collector/cmd/collector-selftest/collector-selftest.go +++ b/collector/cmd/collector-selftest/collector-selftest.go @@ -99,14 +99,16 @@ OPTIONS: Flags: []cli.Flag{ &cli.StringFlag{ - Name: "api-endpoint", - Usage: "The api server endpoint", - Value: "http://localhost:8080", + Name: "api-endpoint", + Usage: "The api server endpoint", + Value: "http://localhost:8080", + EnvVars: []string{"SCRUTINY_API_ENDPOINT"}, }, &cli.BoolFlag{ - Name: "debug", - Usage: "Enable debug logging", + Name: "debug", + Usage: "Enable debug logging", + EnvVars: []string{"DEBUG"}, }, }, }, diff --git a/docker/Dockerfile.web b/docker/Dockerfile.web index 5944b16..aa42cfa 100644 --- a/docker/Dockerfile.web +++ b/docker/Dockerfile.web @@ -15,7 +15,7 @@ FROM node:lts-slim as frontendbuild ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false WORKDIR /scrutiny/src -COPY ./webapp/frontend /scrutiny/src +COPY webapp/frontend /scrutiny/src RUN npm install -g @angular/cli@9.1.4 && \ mkdir -p /scrutiny/dist && \ diff --git a/rootfs/scrutiny/jobber/jobber.yaml b/rootfs/scrutiny/jobber/jobber.yaml index 108002f..64e8b7c 100644 --- a/rootfs/scrutiny/jobber/jobber.yaml +++ b/rootfs/scrutiny/jobber/jobber.yaml @@ -19,9 +19,9 @@ resultSinks: jobs: MetricsJob: - cmd: /scrutiny/bin/scrutiny-collector-metrics run --api-endpoint ${SCRUTINY_API_ENDPOINT:-http://localhost:8080} + cmd: /scrutiny/bin/scrutiny-collector-metrics run # run daily at midnight. - time: '0 0 * * *' + time: '0 0 0 * * *' onError: Backoff notifyOnSuccess: - *filesystemSink