diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e07d5473..8d7fdd9a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Build + - name: Test env: GOOS: linux GOARCH: amd64 @@ -22,39 +22,53 @@ jobs: cd $PROJECT_PATH go mod vendor - go test -race -coverprofile=coverage.txt -covermode=atomic -v -tags "static" $(go list ./... | grep -v /vendor/) - + - name: Build amd64 + env: + GOOS: linux + GOARCH: amd64 + run: | + cd $PROJECT_PATH go build -ldflags "-X main.goos=linux -X main.goarch=amd64" -o scrutiny-web-linux-amd64 -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go go build -ldflags "-X main.goos=linux -X main.goarch=amd64" -o scrutiny-collector-metrics-linux-amd64 -tags "static" collector/cmd/collector-metrics/collector-metrics.go chmod +x scrutiny-web-linux-amd64 chmod +x scrutiny-collector-metrics-linux-amd64 + + - name: Build arm64 + env: + GOOS: linux + GOARCH: arm64 + run: | + cd $PROJECT_PATH + go build -ldflags "-X main.goos=linux -X main.goarch=arm64" -o scrutiny-web-linux-arm64 -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go + go build -ldflags "-X main.goos=linux -X main.goarch=arm64" -o scrutiny-collector-metrics-linux-arm64 -tags "static" collector/cmd/collector-metrics/collector-metrics.go + + chmod +x scrutiny-web-linux-arm64 + chmod +x scrutiny-collector-metrics-linux-arm64 + + - name: Build windows + env: + GOOS: windows + GOARCH: amd64 + run: | + cd $PROJECT_PATH + go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o scrutiny-web-windows-amd64.exe -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go + go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o scrutiny-collector-metrics-windows-amd64.exe -tags "static" collector/cmd/collector-metrics/collector-metrics.go + - name: Archive uses: actions/upload-artifact@v2 with: - name: binaries + name: binaries.zip path: | ${{ env.PROJECT_PATH }}/scrutiny-web-linux-amd64 ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-amd64 + ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm64 + ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm64 + ${{ env.PROJECT_PATH }}/scrutiny-web-windows-amd64.exe + ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-windows-amd64.exe - uses: codecov/codecov-action@v1 with: file: ${{ env.PROJECT_PATH }}/coverage.txt flags: unittests fail_ci_if_error: true - build-docker: - name: Build Docker - runs-on: ubuntu-latest - container: docker:19.03.2 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Build Docker - run: | - docker build -t analogj/scrutiny -f docker/Dockerfile . - docker save -o docker-analogj-scrutiny-latest.tar analogj/scrutiny:latest - - name: Archive Docker - uses: actions/upload-artifact@v2 - with: - name: docker - path: docker-analogj-scrutiny-latest.tar diff --git a/README.md b/README.md index 8a1032b0..4e09f872 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,19 @@ Scrutiny is a simple but focused application, with a couple of core features: # Getting Started +## RAID/Virtual Drives + +Scrutiny uses `smartctl --scan` to detect devices/drives. + +- All RAID controllers supported by `smartctl` are automatically supported by Scrutiny. + - While some RAID controllers support passing through the underlying SMART data to `smartctl` others do not. + - In some cases `--scan` does not correctly detect the device type, returning [incomplete SMART data](https://github.com/AnalogJ/scrutiny/issues/45). + Scrutiny will eventually support overriding detected device type via the config file. +- If you use docker, you **must** pass though the RAID virtual disk to the container using `--device` (see below) + - This device may be in `/dev/*` or `/dev/bus/*`. + - If you're unsure, run `smartctl --scan` on your host, and pass all listed devices to the container. + + ## Docker If you're using Docker, getting started is as simple as running the following command: @@ -68,8 +81,8 @@ analogj/scrutiny - `/run/udev` is necessary to provide the Scrutiny collector with access to your device metadata - `--cap-add SYS_RAWIO` is necessary to allow `smartctl` permission to query your device SMART data - - NOTE: If you have NVMe drives, you must use `--cap-add SYS_ADMIN` instead. See issue [#26](https://github.com/AnalogJ/scrutiny/issues/26#issuecomment-696817130) -- `--device` entries are required to ensure that your hard disk devices are accessible within the container + - NOTE: If you have **NVMe** drives, you must add `--cap-add SYS_ADMIN` as well. See issue [#26](https://github.com/AnalogJ/scrutiny/issues/26#issuecomment-696817130) +- `--device` entries are required to ensure that your hard disk devices are accessible within the container. - `analogj/scrutiny` is a omnibus image, containing both the webapp server (frontend & api) as well as the S.M.A.R.T metric collector. (see below) ### Hub/Spoke Deployment @@ -94,6 +107,13 @@ docker run -it --rm \ analogj/scrutiny:collector ``` +## Manual Installation (without-Docker) + +While the easiest way to get started with [Scrutiny is using Docker](https://github.com/AnalogJ/scrutiny#docker), +it is possible to run it manually without much work. You can even mix and match, using Docker for one component and +a manual installation for the other. + +See [docs/INSTALL_MANUAL.md](docs/INSTALL_MANUAL.md) for instructions. ## Usage diff --git a/collector/pkg/detect/devices_windows.go b/collector/pkg/detect/devices_windows.go index ad5b8403..8ecb781d 100644 --- a/collector/pkg/detect/devices_windows.go +++ b/collector/pkg/detect/devices_windows.go @@ -2,7 +2,6 @@ package detect import ( "github.com/analogj/scrutiny/collector/pkg/models" - "github.com/jaypipes/ghw" "strings" ) diff --git a/docs/INSTALL_MANUAL.md b/docs/INSTALL_MANUAL.md index 3c7f7a48..9be3307a 100644 --- a/docs/INSTALL_MANUAL.md +++ b/docs/INSTALL_MANUAL.md @@ -6,6 +6,8 @@ a manual installation for the other. Scrutiny is made up of two components: a collector and a webapp/api. Here's how each component can be deployed manually. +> Note: the `/opt/scrutiny` directory is not hardcoded, you can use any directory name/path. + ## Webapp/API ### Dependencies @@ -19,9 +21,9 @@ which is included by most linux OS's already. Now let's create a directory structure to contain the Scrutiny files & binary. ``` -mkdir -p /etc/scrutiny/config -mkdir -p /etc/scrutiny/web -mkdir -p /etc/scrutiny/bin +mkdir -p /opt/scrutiny/config +mkdir -p /opt/scrutiny/web +mkdir -p /opt/scrutiny/bin ``` ### Config file @@ -30,19 +32,19 @@ While it is possible to run the webapp/api without a config file, the defaults a and so will need to be overridden. So the first thing you'll need to do is create a config file that looks like the following: ``` -# stored in /etc/scrutiny/config/scrutiny.yaml +# stored in /opt/scrutiny/config/scrutiny.yaml version: 1 web: database: # The Scrutiny webapp will create a database for you, however the parent directory must exist. - location: /etc/scrutiny/config/scrutiny.db + location: /opt/scrutiny/config/scrutiny.db src: frontend: # The path to the Scrutiny frontend files (js, css, images) must be specified. # We'll populate it with files in the next section - path: /etc/scrutiny/web + path: /opt/scrutiny/web ``` > Note: for a full list of available configuration options, please check the [example.scrutiny.yaml](https://github.com/AnalogJ/scrutiny/blob/master/example.scrutiny.yaml) file. @@ -52,8 +54,8 @@ web: Next, we'll download the Scrutiny API binary and frontend files from the [latest Github release](https://github.com/analogj/scrutiny/releases). The files you need to download are named: -- **scrutiny-web-linux-amd64** - save this file to `/etc/scrutiny/bin` -- **scrutiny-web-frontend.tar.gz** - save this file to `/etc/scrutiny/web` +- **scrutiny-web-linux-amd64** - save this file to `/opt/scrutiny/bin` +- **scrutiny-web-frontend.tar.gz** - save this file to `/opt/scrutiny/web` ### Prepare Scrutiny @@ -61,22 +63,75 @@ Now that we have downloaded the required files, let's prepare the filesystem. ``` # Let's make sure the Scrutiny webapp is executable. -chmod +x /etc/scrutiny/bin/scrutiny-web-linux-amd64 +chmod +x /opt/scrutiny/bin/scrutiny-web-linux-amd64 # Next, lets extract the frontend files. -cd /etc/scrutiny/web +cd /opt/scrutiny/web tar xvzf scrutiny-web-frontend.tar.gz --strip-components 1 -C . # Cleanup rm -rf scrutiny-web-frontend.tar.gz ``` -### Start Scrutiny Webapp +### Install Scrutiny systemd service + +You may install Scrutiny as a systemd service: + +Create user and group for the service: + +``` +groupadd -r scrutiny +useradd -m -d /opt/scrutiny -s /sbin/nologin -r -g scrutiny scrutiny +``` + +Change file permissions: + +``` +chown -R scrutiny\:scrutiny /opt/scrutiny +``` + +Create the service unit file: + +``` +cat > /etc/systemd/system/scrutiny.service < /etc/systemd/system/scrutiny-collector.service < /etc/systemd/system/scrutiny-collector.timer <