Skip to content

Commit

Permalink
Client Route Update (#115)
Browse files Browse the repository at this point in the history
* Add gaps and cron timers

* fix lint

* use terminal-notifier for macOS toasts

* update deps

* udpate go ver

* add more ui notifications

* update client route

* take more settings from the website

* general cleanup

* add max body for debug messages

* changes since we last spoke

* fix services logger, move menus

* minor fixes

* a bunch more changes

* re-do host uid

* do not need machineid anymore

* fix services log and docker platform

* updates

* missing file

* update modules

* fix plex type

* more fixes

* fix lint

* add session tracker

* use seconds instead of duration

* plex sessions tweaks

* add radarr import lists

* update plex version to  1.24.4.5081

* update vendors

* Add Tautulli integration

* fix lint

* readme updates.

* add sabnzbd support

* fix reload, fix more plex, allow username map in tautulli

* continue not return

* minor fixes

* updated docker builds

* add next/latest to deluge/qbit

* support getting all (non-local) disks for snapshot.

* fix build
  • Loading branch information
davidnewhall authored Oct 24, 2021
1 parent 9c77027 commit 05426f9
Show file tree
Hide file tree
Showing 57 changed files with 3,053 additions and 1,872 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ test: lint
go test -race -covermode=atomic ./...
lint:
# Checking lint.
$(shell go env GOPATH)/bin/golangci-lint version
GOOS=linux $(shell go env GOPATH)/bin/golangci-lint run $(GOLANGCI_LINT_ARGS)
GOOS=freebsd $(shell go env GOPATH)/bin/golangci-lint run $(GOLANGCI_LINT_ARGS)
GOOS=windows $(shell go env GOPATH)/bin/golangci-lint run $(GOLANGCI_LINT_ARGS)
Expand All @@ -376,6 +377,7 @@ generate: mockgen bindata

docker:
docker build -f init/docker/Dockerfile \
--no-cache --pull \
--build-arg "BUILD_DATE=$(DATE)" \
--build-arg "COMMIT=$(COMMIT)" \
--build-arg "VERSION=$(VERSION)-$(ITERATION)" \
Expand Down
148 changes: 94 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ docker logs <container id from docker run>
#### Docker Environment Variables

See below for more information about which environment variables are available.
You must set `--privileged` when `monitor_drives=true`.
You must set `--privileged` when `monitor drives` is enabled on the website.

```shell
docker pull golift/notifiarr
Expand All @@ -108,7 +108,6 @@ docker run -d --privileged \
-e "DN_API_KEY=abcdef-12345-bcfead-43312-bbbaaa-123" \
-e "DN_SONARR_0_URL=http://localhost:8989" \
-e "DN_SONARR_0_API_KEY=kjsdkasjdaksdj" \
-e "DN_SNAPSHOT_MONITOR_DRIVES=true" \
golift/notifiarr
docker logs <container id from docker run>
```
Expand All @@ -126,55 +125,104 @@ docker logs <container id from docker run>

|Config Name|Variable Name|Default / Note|
|---|---|---|
api_key|`DN_API_KEY`|**Required** / API Key from Notifiarr.com|
bind_addr|`DN_BIND_ADDR`|`0.0.0.0:5454` / The IP and port to listen on|
quiet|`DN_QUIET`|`false` / Turns off output. Set a log_file if this is true|
urlbase|`DN_URLBASE`|default: `/` Change the web root with this setting|
upstreams|`DN_UPSTREAMS_0`|List of upstream networks that can set X-Forwarded-For|
ssl_key_file|`DN_SSL_KEY_FILE`|Providing SSL files turns on the SSL listener|
ssl_cert_file|`DN_SSL_CERT_FILE`|Providing SSL files turns on the SSL listener|
log_file|`DN_LOG_FILE`|None by default. Optionally provide a file path to save app logs|
http_log|`DN_HTTP_LOG`|None by default. Provide a file path to save HTTP request logs|
log_file_mb|`DN_LOG_FILE_MB`|`100` / Max size of log files in megabytes|
log_files|`DN_LOG_FILES`|`10` / Log files to keep after rotating. `0` disables rotation|
send_dash|`DN_SEND_DASH`|`0` / How often to send dashboard state. `0` disables, `30m` = minimum|
timeout|`DN_TIMEOUT`|`60s` / Global API Timeouts (all apps default)|

#### Lidarr
|api_key|`DN_API_KEY`|**Required** / API Key from Notifiarr.com|
|auto_update|`DN_AUTO_UPDATE`|`off` / Set to `daily` to turn on automatic updates (windows only)|
|bind_addr|`DN_BIND_ADDR`|`0.0.0.0:5454` / The IP and port to listen on|
|quiet|`DN_QUIET`|`false` / Turns off output. Set a log_file if this is true|
|urlbase|`DN_URLBASE`|default: `/` Change the web root with this setting|
|upstreams|`DN_UPSTREAMS_0`|List of upstream networks that can set X-Forwarded-For|
|ssl_key_file|`DN_SSL_KEY_FILE`|Providing SSL files turns on the SSL listener|
|ssl_cert_file|`DN_SSL_CERT_FILE`|Providing SSL files turns on the SSL listener|
|log_file|`DN_LOG_FILE`|None by default. Optionally provide a file path to save app logs|
|http_log|`DN_HTTP_LOG`|None by default. Provide a file path to save HTTP request logs|
|log_file_mb|`DN_LOG_FILE_MB`|`100` / Max size of log files in megabytes|
|log_files|`DN_LOG_FILES`|`10` / Log files to keep after rotating. `0` disables rotation|
|file_mode|`DN_FILE_MODE`|`"0600"` / Unix octal filemode for new log files|
|timeout|`DN_TIMEOUT`|`60s` / Global API Timeouts (all apps default)|

All applications below (starr, downloaders, tautulli, plex) have a `timeout` setting.
If the configuration for an application is missing the timeout, the global timeout (above) is used.

### Secret Settings

Recommend not messing with these unless instructed to do so.

|Config Name|Variable Name|Default / Note|
|---|---|---|
|mode|`DN_MODE`|`production` / Change application mode: `development` or `production`|
|debug|`DN_DEBUG`|`false` / Adds payloads and other stuff to the log output; very verbose/noisy|
|debug_log|`DN_DEBUG_LOG`|`""` / Set a file system path to write debug logs to a dedicated file|
|max_body|`DN_MAX_BODY`|Unlimited, `0` / Maximum debug-log body size (integer) for payloads to and from notifiarr.com|

All Starr apps (below) also allow a `max_body` parameter. This parameter only controls debug output.
Debug-log payload sizes from each app can be controlled individually.

_Note: You may disable the GUI (menu item) on Windows by setting the env variable `USEGUI` to `false`._

### Lidarr

|Config Name|Variable Name|Note|
|---|---|---|
lidarr.name|`DN_LIDARR_0_NAME`|No Default. Setting a name enabled service checks.|
lidarr.name|`DN_LIDARR_0_NAME`|No Default. Setting a name enables service checks|
lidarr.url|`DN_LIDARR_0_URL`|No Default. Something like: `http://lidarr:8686`|
lidarr.api_key|`DN_LIDARR_0_API_KEY`|No Default. Provide URL and API key if you use Readarr|

#### Radarr
### Radarr

|Config Name|Variable Name|Note|
|---|---|---|
radarr.name|`DN_RADARR_0_NAME`|No Default. Setting a name enabled service checks.|
radarr.name|`DN_RADARR_0_NAME`|No Default. Setting a name enables service checks.|
radarr.url|`DN_RADARR_0_URL`|No Default. Something like: `http://localhost:7878`|
radarr.api_key|`DN_RADARR_0_API_KEY`|No Default. Provide URL and API key if you use Radarr|
radarr.disable_cf|`DN_RADARR_0_DISABLE_CF`|`false` / Setting true disables custom format sync.|

#### Readarr
### Readarr

|Config Name|Variable Name|Note|
|---|---|---|
readarr.name|`DN_READARR_0_NAME`|No Default. Setting a name enabled service checks.|
readarr.name|`DN_READARR_0_NAME`|No Default. Setting a name enables service checks|
readarr.url|`DN_READARR_0_URL`|No Default. Something like: `http://localhost:8787`|
readarr.api_key|`DN_READARR_0_API_KEY`|No Default. Provide URL and API key if you use Readarr|

#### Sonarr
### Sonarr

|Config Name|Variable Name|Note|
|---|---|---|
sonarr.name|`DN_SONARR_0_NAME`|No Default. Setting a name enabled service checks.|
sonarr.name|`DN_SONARR_0_NAME`|No Default. Setting a name enables service checks|
sonarr.url|`DN_SONARR_0_URL`|No Default. Something like: `http://localhost:8989`|
sonarr.api_key|`DN_SONARR_0_API_KEY`|No Default. Provide URL and API key if you use Sonarr|
sonarr.disable_cf|`DN_SONARR_0_DISABLE_CF`|`false` / Setting true disables release profile sync.|

#### Plex
### Downloaders

You can add supported downloaders so they show up on the dashboard integration.
You may easily add service checks to these downloaders by adding a name.
Any number of downloaders of any type may be configured.

#### QbitTorrent

|Config Name|Variable Name|Note|
|---|---|---|
qbit.name|`DN_QBIT_0_NAME`|No Default. Setting a name enables service checks|
qbit.url|`DN_QBIT_0_URL`|No Default. Something like: `http://localhost:8080`|
qbit.user|`DN_QBIT_0_USER`|No Default. Provide URL, user and pass if you use Qbit|
qbit.pass|`DN_QBIT_0_PASS`|No Default. Provide URL, user and pass if you use Qbit|

#### SABnzbd

|Config Name|Variable Name|Note|
|---|---|---|
sabnzbd.name|`DN_SABNZBD_0_NAME`|No Default. Setting a name enables service checks|
sabnzbd.url|`DN_SABNZBD_0_URL`|No Default. Something like: `http://localhost:8080/sabnzbd`|
sabnzbd.api_key|`DN_SABNZBD_0_API_KEY`|No Default. Provide URL and API key if you use SABnzbd|

#### Deluge

|Config Name|Variable Name|Note|
|---|---|---|
deluge.name|`DN_DELUGE_0_NAME`|No Default. Setting a name enables service checks|
deluge.url|`DN_DELUGE_0_URL`|No Default. Something like: `http://localhost:8080`|
deluge.password|`DN_DELUGE_0_PASSWORD`|No Default. Provide URL and password key if you use Deluge|

### Plex

This application can also send Plex sessions to Notfiarr so you can receive
notifications when users interact with your server. This has three different features:
Expand All @@ -184,9 +232,7 @@ notifications when users interact with your server. This has three different fea
- Notify on session change (Plex Webhook) ie. pause/resume.

You [must provide Plex Token](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/)
for this to work. Setting `movies_percent_complete` or `series_percent_complete` to a number above 0 will cause this
application to poll Plex once per minute looking for sessions nearing completion. If Plex goes down
this will cause a lot of log spam. You may also need to add a webhook to Plex so it sends notices to this application.
for this to work. You may also need to add a webhook to Plex so it sends notices to this application.

- In Plex Media Server, add this URL to webhooks:
- `http://localhost:5454/plex?token=plex-token-here`
Expand All @@ -198,13 +244,19 @@ this will cause a lot of log spam. You may also need to add a webhook to Plex so
|---|---|---|
plex.url|`DN_PLEX_URL`|`http://localhost:32400` / local URL to your plex server|
plex.token|`DN_PLEX_TOKEN`|Required. [Must provide Plex Token](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/) for this to work.|
plex.interval|`DN_PLEX_INTERVAL`|`30m`, How often to notify on all session data (cron)|
plex.cooldown|`DN_PLEX_COOLDOWN`|`10s`, Maximum rate of notifications is 1 every cooldown interval|
plex.account_map|`DN_PLEX_ACCOUNT_MAP`|map an email to a name, ex: `"[email protected],Name|[email protected],name"`|
plex.movies_percent_complete|`DN_PLEX_MOVIES_PERCENT_COMPLETE`|Send complete notice when a movie reaches this percent.|
plex.series_percent_complete|`DN_PLEX_SERIES_PERCENT_COMPLETE`|Send complete notice when a show reaches this percent.|

#### System Snapshot
### Tautulli

Only 1 Tautulli instance may be configured per client. Providing Tautulli allows Notifiarr
to use the "Friendly Name" for your Plex users and it allows you to easily enable a service check.

|Config Name|Variable Name|Note|
|---|---|---|
tautulli.name|`DN_TAUTULLI_NAME`|No Default. Setting a name enables service checks of Tautulli|
tautulli.url|`DN_TAUTULLI_URL`|No Default. Something like: `http://localhost:8181`|
tautulli.api_key|`DN_TAUTULLI_API_KEY`|No Default. Provide URL and API key if you want name maps from Tautulli|

### System Snapshot

This application can also take a snapshot of your system at an interval and send
you a notification. Snapshot means system health like cpu, memory, disk, raid, users, etc.
Expand All @@ -219,7 +271,7 @@ notifiarr ALL=(root) NOPASSWD:/usr/sbin/smartctl *
notifiarr ALL=(root) NOPASSWD:/usr/sbin/MegaCli64 -LDInfo -Lall -aALL
```

###### Snapshot Packages
#### Snapshot Packages

- **Windows**: `smartmontools` - get it here https://sourceforge.net/projects/smartmontools/
- **Linux**: Debian/Ubuntu: `apt install smartmontools`, RedHat/CentOS: `yum install smartmontools`
Expand All @@ -228,24 +280,11 @@ notifiarr ALL=(root) NOPASSWD:/usr/sbin/MegaCli64 -LDInfo -Lall -aALL
- Entware (synology): https://github.com/Entware/Entware-ng/wiki/Install-on-Synology-NAS
- Entware Package List: https://github.com/Entware/Entware-ng/wiki/Install-on-Synology-NAS

###### Snapshot Configuration

|Config Name|Variable Name|Note|
|---|---|---|
snapshot.interval|`DN_SNAPSHOT_INTERVAL`|`30m`, How often to send a snapshot (cron)|
snapshot.timeout|`DN_SNAPSHOT_TIMEOUT`|`10s`, How long to wait for a reply from Notifiarr.com|
snapshot.monitor_raid|`DN_SNAPSHOT_MONITOR_RAID`|Set `true` to report `mdadm` and `megacli`|
snapshot.monitor_drives|`DN_SNAPSHOT_MONITOR_DRIVES`|Set `true` to report SMART on drives|
snapshot.monitor_space|`DN_SNAPSHOT_MONITOR_SPACE`|Set `true` to report drive volume usage|
snapshot.monitor_uptime|`DN_SNAPSHOT_MONITOR_UPTIME`|Set `true` to report Local Host Information|
snapshot.monitor_cpuMemory|`DN_SNAPSHOT_MONITOR_CPUMEMORY`|Set `true` to report CPU and Memory usage|
snapshot.monitor_cpuTemp|`DN_SNAPSHOT_MONITOR_CPUTEMP`|Set `true` to report CPU temperatures|
snapshot.zfs_pools|`DN_SNAPSHOT_ZFS_POOL_0`|Provide a list of zfs pools to monitor, ie. `data`|
snapshot.use_sudo|`DN_SNAPSHOT_USE_SUDO`|Set `true` if `monitor_drives=true` or you use `megacli` on Linux|
#### Snapshot Configuration

- _Notes: Not all systems can report CPU temperatures._
Snapshot configuration is now found on the [website](https://notifiarr.com). - 9/14/2021

#### Service Checks
### Service Checks

The Notifiarr client can also check URLs for health. If you set names on your
Starr apps they will be automatically checked and reports sent to Notifiarr.
Expand All @@ -255,7 +294,7 @@ to the app log nor to console stdout.
|Config Name|Variable Name|Note|
|---|---|---|
services.log_file|`DN_SERVICES_LOG_FILE`|If a file path is provided, service check logs write there|
services.interval|`DN_SERVICES_INTERVAL`|`10m`, How often to check service health; minimum: `5m`|
services.interval|`DN_SERVICES_INTERVAL`|`10m`, How often to send service states to Notifiarr; minimum: `5m`|
services.parallel|`DN_SERVICES_PARALLE`|`1`, How many services can be checked at once; 1 is plenty|

You can also create ad-hoc service checks for things like Bazarr.
Expand All @@ -267,6 +306,7 @@ service.type|`DN_SERVICE_0_TYPE`|Type must be one of `http`, `tcp`|
service.check|`DN_SERVICE_0_CHECK`|The `URL`, or `host/ip:port` to check|
service.expect|`DN_SERVICE_0_EXPECT`|`200`, For HTTP, the return code to expect|
service.timeout|`DN_SERVICE_0_TIMEOUT`|`15s`, How long to wait for service response|
service.interval|`DN_SERVICE_0_INTERVAL`|`5m`, How often to check the service|

## Reverse Proxy

Expand Down
84 changes: 29 additions & 55 deletions examples/notifiarr.conf.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################
# Notifiarr Client Example Configuration File #
# Created by Notifiarr v0.1.15 @ 213108T0935 #
# Created by Notifiarr v0.2.0 @ 211810T0106 #
###############################################

# This API key must be copied from your notifiarr.com account.
Expand Down Expand Up @@ -54,13 +54,9 @@ log_file_mb = 100
log_files = 0
##
## Unix file mode for new log files. Umask also affects this.
## Missing or 0 uses default of 0600. Permissive is 0644. Ignored by Windows.
## Missing, blank or 0 uses default of 0600. Permissive is 0644. Ignored by Windows.
file_mode = "0600"

## How often to send current application states for the dashboard.
##
send_dash = "0s"

## Web server and application timeouts.
##
timeout = "1m0s"
Expand All @@ -77,30 +73,24 @@ timeout = "1m0s"
##
## Examples follow. UNCOMMENT (REMOVE #), AT MINIMUM: [[header]], url, api_key
#[[lidarr]]
#name = "" # Set a name to enable checks of your service.
#url = "http://lidarr:8989/"
#api_key = ""
#check_q = 0 # Check for items stuck in queue. 0 = no repeat, 1 to repeat every hour, 2 for every 2 hours, etc.
#name = "" # Set a name to enable checks of your service.
#url = "http://lidarr:8989/"
#api_key = "".

#[[radarr]]
#name = "" # Set a name to enable checks of your service.
#url = "http://127.0.0.1:7878/radarr"
#api_key = ""
#disable_cf = true # Disable custom format sync.
#check_q = 0 # Check for items stuck in queue. 0 = no repeat, 1 to repeat every hour, 2 for every 2 hours, etc.
#name = "" # Set a name to enable checks of your service.
#url = "http://127.0.0.1:7878/radarr"
#api_key = ""

#[[readarr]]
#name = "" # Set a name to enable checks of your service.
#url = "http://127.0.0.1:8787/readarr"
#api_key = ""
#check_q = 0 # Check for items stuck in queue. 0 = no repeat, 1 to repeat every hour, 2 for every 2 hours, etc.
#name = "" # Set a name to enable checks of your service.
#url = "http://127.0.0.1:8787/readarr"
#api_key = ""

#[[sonarr]]
#name = "" # Set a name to enable checks of your service.
#url = "http://sonarr:8989/"
#api_key = ""
#disable_cf = true # Disable release profile sync.
#check_q = 0 # Check for items stuck in queue. 0 = no repeat, 1 to repeat every hour, 2 for every 2 hours, etc.
#name = "" # Set a name to enable checks of your service.
#url = "http://sonarr:8989/"
#api_key = ""


# Download Client Configs (below) are used for dashboard state and service checks.
Expand All @@ -118,49 +108,33 @@ timeout = "1m0s"
#pass = ""


#[[sabnzbd]]
#name = "" # Set a name to enable checks of this application.
#url = "http://sabnzbd:8080/"
#api_key = ""


#################
# Plex Settings #
#################

## Find your token: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
##
[plex]
url = "http://localhost:32400" # Your plex URL
token = "" # your plex token; get this from a web inspector
interval = "30m0s" # how often to send session data, 0 = off
cooldown = "15s" # how often plex webhooks may trigger session hooks
account_map = "" # shared plex servers: map an email to a name, ex: "[email protected],Name|[email protected],name"
movies_percent_complete = 0 # 0, 70-99, send notifications when a movie session is this % complete.
series_percent_complete = 0 # 0, 70-99, send notifications when an episode session is this % complete.

url = "http://localhost:32400" # Your plex URL
token = "" # your plex token; get this from a web inspector

#####################
# Snapshot Settings #
# Tautulli Settings #
#####################

## Install package(s)
## - Windows: smartmontools - https://sourceforge.net/projects/smartmontools/
## - Linux: apt install smartmontools || yum install smartmontools
## - Docker: Already Included. Run in --privileged mode.
## - Synology: opkg install smartmontools
## - Entware: https://github.com/Entware/Entware-ng/wiki/Install-on-Synology-NAS
## - Entware Package List: https://github.com/Entware/Entware-ng/wiki/Install-on-Synology-NAS
##
[snapshot]
interval = "30m0s" # how often to send a snapshot, 0 = off, 30m - 2h recommended
timeout = "30s" # how long a snapshot may take
monitor_raid = false # mdadm / megacli
monitor_drives = false # smartctl: age, temp, health
monitor_space = false # disk usage for all partitions
monitor_uptime = false # system data, users, hostname, uptime, os, build
monitor_cpuMemory = false # literally cpu usage, load averages, and memory
monitor_cpuTemp = false # cpu temperatures, not available on all platforms
zfs_pools = [] # list of zfs pools, ex: zfs_pools=["data", "data2"]
use_sudo = false # sudo is needed on unix when monitor_drives=true or for megacli.
## Example sudoers entries follow; these go in /etc/sudoers.d. Fix the paths to smartctl and MegaCli.
## notifiarr ALL=(root) NOPASSWD:/usr/sbin/smartctl *
## notifiarr ALL=(root) NOPASSWD:/usr/sbin/MegaCli64 -LDInfo -Lall -aALL
# Enables email=>username map. Set a name to enable service checks.
# Must uncomment [tautulli], 'api_key' and 'url' at a minimum.

#[tautulli]
# name = "" # only set a name if you want to enable service checks.
# url = "http://localhost:8181" # Your Tautulli URL
# api_key = "" # your tautulli api key; get this from settings

##################
# Service Checks #
Expand Down
Loading

0 comments on commit 05426f9

Please sign in to comment.