Merge pull request #235 from AnalogJ/change_scrutiny_default_path

pull/93/head^2
Jason Kulatunga 3 years ago committed by GitHub
commit d9632ae34b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,14 +6,14 @@ There are multiple ways to develop on the scrutiny codebase locally. The two mos
## Docker Development
```
docker build -f docker/Dockerfile . -t analogj/scrutiny
docker build -f docker/Dockerfile . -t chcr.io/analogj/scrutiny:master-omnibus
docker run -it --rm -p 8080:8080 \
-v /run/udev:/run/udev:ro \
--cap-add SYS_RAWIO \
--device=/dev/sda \
--device=/dev/sdb \
ghcr.io/analogj/scrutiny:master-omnibus
/scrutiny/bin/scrutiny-collector-metrics run
/opt/scrutiny/bin/scrutiny-collector-metrics run
```

@ -72,8 +72,8 @@ If you're using Docker, getting started is as simple as running the following co
```bash
docker run -it --rm -p 8080:8080 \
-v `pwd`/scrutiny:/scrutiny/config \
-v `pwd`/influxdb2:/scrutiny/influxdb \
-v `pwd`/scrutiny:/opt/scrutiny/config \
-v `pwd`/influxdb2:/opt/scrutiny/influxdb \
-v /run/udev:/run/udev:ro \
--cap-add SYS_RAWIO \
--device=/dev/sda \
@ -102,7 +102,7 @@ docker run --rm -p 8086:8086 \
influxdb:2.2
docker run --rm -p 8080:8080 \
-v `pwd`/scrutiny:/scrutiny/config \
-v `pwd`/scrutiny:/opt/scrutiny/config \
--name scrutiny-web \
ghcr.io/analogj/scrutiny:master-web
@ -135,11 +135,11 @@ For users of the docker Hub/Spoke deployment or manual install: initially the da
After the first collector run, you'll be greeted with a list of all your hard drives and their current smart status.
```bash
docker exec scrutiny /scrutiny/bin/scrutiny-collector-metrics run
docker exec scrutiny /opt/scrutiny/bin/scrutiny-collector-metrics run
```
# Configuration
By default Scrutiny looks for its YAML configuration files in `/scrutiny/config`
By default Scrutiny looks for its YAML configuration files in `/opt/scrutiny/config`
There are two configuration files available:

@ -29,7 +29,7 @@ func main() {
}
//we're going to load the config file manually, since we need to validate it.
err = config.ReadConfig("/scrutiny/config/collector.yaml") // Find and read the config file
err = config.ReadConfig("/opt/scrutiny/config/collector.yaml") // Find and read the config file
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
//ignore "could not find config file"
} else if err != nil {

@ -16,22 +16,22 @@ FROM node:lts-slim as frontendbuild
#reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false
WORKDIR /scrutiny/src
COPY webapp/frontend /scrutiny/src
WORKDIR /opt/scrutiny/src
COPY webapp/frontend /opt/scrutiny/src
RUN npm install -g @angular/cli@9.1.4 && \
mkdir -p /scrutiny/dist && \
npm install && \
ng build --output-path=/scrutiny/dist --deploy-url="/web/" --base-href="/web/" --prod
ng build --output-path=/opt/scrutiny/dist --deploy-url="/web/" --base-href="/web/" --prod
########
FROM ubuntu:bionic as runtime
ARG TARGETARCH
EXPOSE 8080
WORKDIR /scrutiny
ENV PATH="/scrutiny/bin:${PATH}"
ENV INFLUXD_CONFIG_PATH=/scrutiny/influxdb
WORKDIR /opt/scrutiny
ENV PATH="/opt/scrutiny/bin:${PATH}"
ENV INFLUXD_CONFIG_PATH=/opt/scrutiny/influxdb
RUN apt-get update && apt-get install -y cron smartmontools=7.0-0ubuntu1~ubuntu18.04.1 ca-certificates curl tzdata \
&& update-ca-certificates \
@ -48,18 +48,18 @@ RUN dpkg -i /tmp/influxdb2-2.2.0-${TARGETARCH}.deb && rm -rf /tmp/influxdb2-2.2.
COPY /rootfs /
COPY /rootfs/etc/cron.d/scrutiny /etc/cron.d/scrutiny
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny /scrutiny/bin/
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-selftest /scrutiny/bin/
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-metrics /scrutiny/bin/
COPY --from=frontendbuild /scrutiny/dist /scrutiny/web
RUN chmod +x /scrutiny/bin/scrutiny && \
chmod +x /scrutiny/bin/scrutiny-collector-selftest && \
chmod +x /scrutiny/bin/scrutiny-collector-metrics && \
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny /opt/scrutiny/bin/
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-selftest /opt/scrutiny/bin/
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-metrics /opt/scrutiny/bin/
COPY --from=frontendbuild /opt/scrutiny/dist /opt/scrutiny/web
RUN chmod +x /opt/scrutiny/bin/scrutiny && \
chmod +x /opt/scrutiny/bin/scrutiny-collector-selftest && \
chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics && \
chmod 0644 /etc/cron.d/scrutiny && \
rm -f /etc/cron.daily/* && \
mkdir -p /scrutiny/web && \
mkdir -p /scrutiny/config && \
chmod -R ugo+rwx /scrutiny/config
mkdir -p /opt/scrutiny/web && \
mkdir -p /opt/scrutiny/config && \
chmod -R ugo+rwx /opt/scrutiny/config
CMD ["/init"]

@ -12,16 +12,16 @@ RUN go mod vendor && \
########
FROM ubuntu:bionic as runtime
WORKDIR /scrutiny
ENV PATH="/scrutiny/bin:${PATH}"
ENV PATH="/opt/scrutiny/bin:${PATH}"
RUN apt-get update && apt-get install -y cron smartmontools=7.0-0ubuntu1~ubuntu18.04.1 ca-certificates tzdata && update-ca-certificates
COPY /docker/entrypoint-collector.sh /entrypoint-collector.sh
COPY /rootfs/etc/cron.d/scrutiny /etc/cron.d/scrutiny
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-selftest /scrutiny/bin/
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-metrics /scrutiny/bin/
RUN chmod +x /scrutiny/bin/scrutiny-collector-selftest && \
chmod +x /scrutiny/bin/scrutiny-collector-metrics && \
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-selftest /opt/scrutiny/bin/
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-metrics /opt/scrutiny/bin/
RUN chmod +x /opt/scrutiny/bin/scrutiny-collector-selftest && \
chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics && \
chmod +x /entrypoint-collector.sh && \
chmod 0644 /etc/cron.d/scrutiny && \
rm -f /etc/cron.daily/apt /etc/cron.daily/dpkg /etc/cron.daily/passwd

@ -14,27 +14,27 @@ FROM node:lts-slim as frontendbuild
#reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false
WORKDIR /scrutiny/src
COPY webapp/frontend /scrutiny/src
WORKDIR /opt/scrutiny/src
COPY webapp/frontend /opt/scrutiny/src
RUN npm install -g @angular/cli@9.1.4 && \
mkdir -p /scrutiny/dist && \
mkdir -p /opt/scrutiny/dist && \
npm install && \
ng build --output-path=/scrutiny/dist --deploy-url="/web/" --base-href="/web/" --prod
ng build --output-path=/opt/scrutiny/dist --deploy-url="/web/" --base-href="/web/" --prod
########
FROM ubuntu:bionic as runtime
EXPOSE 8080
WORKDIR /scrutiny
ENV PATH="/scrutiny/bin:${PATH}"
WORKDIR /opt/scrutiny
ENV PATH="/opt/scrutiny/bin:${PATH}"
RUN apt-get update && apt-get install -y ca-certificates curl tzdata && update-ca-certificates
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny /scrutiny/bin/
COPY --from=frontendbuild /scrutiny/dist /scrutiny/web
RUN chmod +x /scrutiny/bin/scrutiny && \
mkdir -p /scrutiny/web && \
mkdir -p /scrutiny/config && \
chmod -R ugo+rwx /scrutiny/config
CMD ["/scrutiny/bin/scrutiny", "start"]
COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny /opt/scrutiny/bin/
COPY --from=frontendbuild /opt/scrutiny/dist /opt/scrutiny/web
RUN chmod +x /opt/scrutiny/bin/scrutiny && \
mkdir -p /opt/scrutiny/web && \
mkdir -p /opt/scrutiny/config && \
chmod -R ugo+rwx /opt/scrutiny/config
CMD ["/opt/scrutiny/bin/scrutiny", "start"]

@ -10,7 +10,7 @@ services:
- "8080:8080"
volumes:
- /run/udev:/run/udev:ro
- ./config:/scrutiny/config
- ./config:/opt/scrutiny/config
- ./influxdb:/var/lib/influxdb2
devices:
- "/dev/sda"

@ -64,7 +64,7 @@ using a collector config file. See [example.collector.yaml](/example.collector.y
> If you're unsure, run `smartctl --scan` on your host, and pass all listed devices to the container.
```yaml
# /scrutiny/config/collector.yaml
# /opt/scrutiny/config/collector.yaml
devices:
# Dell PERC/Broadcom Megaraid example: https://github.com/AnalogJ/scrutiny/issues/30
- device: /dev/bus/0

@ -1,6 +1,6 @@
# Commented Scrutiny Configuration File
#
# The default location for this file is /scrutiny/config/collector.yaml.
# The default location for this file is /opt/scrutiny/config/collector.yaml.
# In some cases to improve clarity default values are specified,
# uncommented. Other example values are commented out.
#

@ -1,6 +1,6 @@
# Commented Scrutiny Configuration File
#
# The default location for this file is /scrutiny/config/scrutiny.yaml.
# The default location for this file is /opt/scrutiny/config/scrutiny.yaml.
# In some cases to improve clarity default values are specified,
# uncommented. Other example values are commented out.
#
@ -22,10 +22,10 @@ web:
host: 0.0.0.0
database:
# can also set absolute path here
location: /scrutiny/config/scrutiny.db
location: /opt/scrutiny/config/scrutiny.db
src:
frontend:
path: /scrutiny/web
path: /opt/scrutiny/web
influxdb:
host: 0.0.0.0
port: 8086

@ -11,5 +11,5 @@ MAILTO=""
# correctly route collector logs (STDOUT & STDERR) to Cron foreground (collectable by Docker STDOUT)
# cron schedule to run daily at midnight: '0 0 * * *'
# System environmental variables are stripped by cron, source our dump of the docker environmental variables before each command (/env.sh)
{COLLECTOR_CRON_SCHEDULE} root . /env.sh; /scrutiny/bin/scrutiny-collector-metrics run >/proc/1/fd/1 2>/proc/1/fd/2
{COLLECTOR_CRON_SCHEDULE} root . /env.sh; /opt/scrutiny/bin/scrutiny-collector-metrics run >/proc/1/fd/1 2>/proc/1/fd/2
# An empty line is required at the end of this file for a valid cron file.

@ -10,4 +10,4 @@ s6-svc -O /var/run/s6/services/collector-once
until $(curl --output /dev/null --silent --head --fail http://localhost:8080/api/health); do echo "scrutiny api not ready" && sleep 5; done
echo "starting scrutiny collector"
/scrutiny/bin/scrutiny-collector-metrics run
/opt/scrutiny/bin/scrutiny-collector-metrics run

@ -1,13 +1,13 @@
#!/usr/bin/with-contenv bash
mkdir -p /scrutiny/influxdb/
mkdir -p /opt/scrutiny/influxdb/
if [ -f "/scrutiny/influxdb/config.yaml" ]; then
if [ -f "/opt/scrutiny/influxdb/config.yaml" ]; then
echo "influxdb config file already exists. skipping."
else
cat << 'EOF' > /scrutiny/influxdb/config.yaml
bolt-path: /scrutiny/influxdb/influxd.bolt
engine-path: /scrutiny/influxdb/engine
cat << 'EOF' > /opt/scrutiny/influxdb/config.yaml
bolt-path: /opt/scrutiny/influxdb/influxd.bolt
engine-path: /opt/scrutiny/influxdb/engine
http-bind-address: ":8086"
reporting-disabled: true
EOF

@ -27,7 +27,7 @@ func main() {
}
//we're going to load the config file manually, since we need to validate it.
err = config.ReadConfig("/scrutiny/config/scrutiny.yaml") // Find and read the config file
err = config.ReadConfig("/opt/scrutiny/config/scrutiny.yaml") // Find and read the config file
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
//ignore "could not find config file"
} else if err != nil {

@ -30,8 +30,8 @@ func (c *configuration) Init() error {
//set defaults
c.SetDefault("web.listen.port", "8080")
c.SetDefault("web.listen.host", "0.0.0.0")
c.SetDefault("web.src.frontend.path", "/scrutiny/web")
c.SetDefault("web.database.location", "/scrutiny/config/scrutiny.db")
c.SetDefault("web.src.frontend.path", "/opt/scrutiny/web")
c.SetDefault("web.database.location", "/opt/scrutiny/config/scrutiny.db")
c.SetDefault("log.level", "INFO")
c.SetDefault("log.file", "")
@ -49,9 +49,9 @@ func (c *configuration) Init() error {
//c.SetDefault("disks.include", []string{})
//c.SetDefault("disks.exclude", []string{})
//c.SetDefault("notify.metric.script", "/scrutiny/config/notify-metrics.sh")
//c.SetDefault("notify.long.script", "/scrutiny/config/notify-long-test.sh")
//c.SetDefault("notify.short.script", "/scrutiny/config/notify-short-test.sh")
//c.SetDefault("notify.metric.script", "/opt/scrutiny/config/notify-metrics.sh")
//c.SetDefault("notify.long.script", "/opt/scrutiny/config/notify-long-test.sh")
//c.SetDefault("notify.short.script", "/opt/scrutiny/config/notify-short-test.sh")
//c.SetDefault("collect.metric.enable", true)
//c.SetDefault("collect.metric.command", "-a -o on -S on")

Loading…
Cancel
Save