-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add steps to create systemd services #63
Open
nithinphilips
wants to merge
14
commits into
AnalogJ:master
Choose a base branch
from
nithinphilips:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4456511
Add steps to create systemd services
nithinphilips c7c1e37
updating docs. use /opt/ not /etc/. Describe RAID instructions.
AnalogJ 6473ec1
Adding automatic builds to CI for arm64 + windows - eventual support.…
AnalogJ 7742f4c
fixing windows binary build during CI. Update config missing error me…
AnalogJ 95e5a5e
remove windows build.
AnalogJ 94559d2
fixes for ARM build
AnalogJ cd6c595
fixes -- guess and check development. :(
AnalogJ 9816c75
multiple builds.
AnalogJ f0c3fdd
fixes - multiple builds.
AnalogJ adbbcb2
fixes - multiple builds. remove docker build caching.
AnalogJ be378bd
if attribute Id is unknown (and does not match anything in metadata) …
AnalogJ a5f65b3
Add steps to create systemd services
nithinphilips fd92740
Change paths from etc to opt
nithinphilips 64b4f97
Merge branch 'master' of github.com:nithinphilips/scrutiny into master
nithinphilips File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,31 +54,84 @@ 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 | ||
|
||
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 <<EOF | ||
[Unit] | ||
Description=Scrutiny disk health monitor | ||
After=network.target | ||
|
||
[Service] | ||
Type=idle | ||
User=scrutiny | ||
Group=scrutiny | ||
ExecStart=/opt/scrutiny/bin/scrutiny-web-linux-amd64 start --config /opt/scrutiny/config/scrutiny.yaml | ||
TimeoutStartSec=600 | ||
TimeoutStopSec=600 | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
EOF | ||
``` | ||
|
||
Finally, we start the Scrutiny webapp: | ||
Enable and start the service: | ||
|
||
``` | ||
/etc/scrutiny/bin/scrutiny-web-linux-amd64 start --config /etc/scrutiny/config/scrutiny.yaml | ||
systemctl daemon-reload | ||
systemctl enable scrutiny | ||
systemctl start scrutiny | ||
``` | ||
|
||
Check log for any issues: | ||
|
||
``` | ||
journalctl -u scrutiny | ||
``` | ||
|
||
### Start Scrutiny Webapp (non-systemd) | ||
|
||
If you are not using the systemd service, you can start the Scrutiny webapp in the | ||
foreground: | ||
|
||
``` | ||
/opt/scrutiny/bin/scrutiny-web-linux-amd64 start --config /opt/scrutiny/config/scrutiny.yaml | ||
``` | ||
|
||
The webapp listens for traffic on `http://0.0.0.0:8080` by default. | ||
|
@@ -105,7 +160,7 @@ So you'll need to install the v7+ version using one of the following commands: | |
Now let's create a directory structure to contain the Scrutiny collector binary. | ||
|
||
``` | ||
mkdir -p /etc/scrutiny/bin | ||
mkdir -p /opt/scrutiny/bin | ||
``` | ||
|
||
|
||
|
@@ -114,7 +169,7 @@ mkdir -p /etc/scrutiny/bin | |
Next, we'll download the Scrutiny collector binary from the [latest Github release](https://github.com/analogj/scrutiny/releases). | ||
The file you need to download is named: | ||
|
||
- **scrutiny-collector-metrics-linux-amd64** - save this file to `/etc/scrutiny/bin` | ||
- **scrutiny-collector-metrics-linux-amd64** - save this file to `/opt/scrutiny/bin` | ||
|
||
|
||
### Prepare Scrutiny | ||
|
@@ -123,18 +178,89 @@ Now that we have downloaded the required files, let's prepare the filesystem. | |
|
||
``` | ||
# Let's make sure the Scrutiny collector is executable. | ||
chmod +x /etc/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 | ||
chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 | ||
``` | ||
|
||
### Install Scrutiny Collector systemd service | ||
|
||
If you are using systemd, you may configure collector as a systemd service and | ||
create a timer to invoke it periodically: | ||
|
||
``` | ||
sudo cat > /etc/systemd/system/scrutiny-collector.service <<EOF | ||
[Unit] | ||
Description=Scrutiny disk health data collector | ||
|
||
[Service] | ||
Type=idle | ||
ExecStart=/opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 run --api-endpoint "http://localhost:8080" | ||
TimeoutStartSec=600 | ||
TimeoutStopSec=600 | ||
EOF | ||
``` | ||
|
||
Configure collector systemd timer: | ||
|
||
``` | ||
sudo cat > /etc/systemd/system/scrutiny-collector.timer <<EOF | ||
[Unit] | ||
Description=Scrutiny disk health data collector timer | ||
|
||
[Timer] | ||
OnCalendar=*:0/15 | ||
Unit=scrutiny-collector.service | ||
Persistent=true | ||
|
||
[Install] | ||
WantedBy=timers.target | ||
EOF | ||
``` | ||
|
||
Enable timer: | ||
|
||
``` | ||
systemctl daemon-reload | ||
systemctl enable scrutiny-collector.timer | ||
systemctl start scrutiny-collector.timer | ||
Comment on lines
+223
to
+224
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could shorten with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just added a type correction 🙂 |
||
``` | ||
|
||
Check timer: | ||
|
||
``` | ||
systemctl is-active scrutiny-collector.timer | ||
``` | ||
|
||
Should say `active` | ||
|
||
Check the next scheduled run: | ||
|
||
``` | ||
systemctl list-timers scrutiny* | ||
``` | ||
|
||
Manually run the first data collection: | ||
|
||
``` | ||
systemctl start scrutiny-collector.service | ||
``` | ||
|
||
Check log for any issues: | ||
|
||
``` | ||
journalctl -u scrutiny-collector.service | ||
``` | ||
|
||
### Non-systemd configuration | ||
|
||
### Start Scrutiny Collector, Populate Webapp | ||
#### Start Scrutiny Collector, Populate Webapp | ||
|
||
Next, we will manually trigger the collector, to populate the Scrutiny dashboard: | ||
|
||
``` | ||
/etc/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 run --api-endpoint "http://localhost:8080" | ||
/opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 run --api-endpoint "http://localhost:8080" | ||
``` | ||
|
||
### Schedule Collector with Cron | ||
#### Schedule Collector with Cron | ||
|
||
Finally you need to schedule the collector to run periodically. | ||
This may be different depending on your OS/environment, but it may look something like this: | ||
|
@@ -144,5 +270,5 @@ This may be different depending on your OS/environment, but it may look somethin | |
crontab -e | ||
|
||
# add a line for Scrutiny | ||
*/15 * * * * /etc/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 run --api-endpoint "http://localhost:8080" | ||
*/15 * * * * /opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 run --api-endpoint "http://localhost:8080" | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migt make sense to specify
lang
(use ```\sh) and then make it a long list with comments in there like