Skip to content

Commit

Permalink
v1.4 Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtycajunrice authored Dec 19, 2018
2 parents 79ba26f + 2a51056 commit 3fb63da
Show file tree
Hide file tree
Showing 18 changed files with 792 additions and 357 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ GeoLite2-City.mmdb
GeoLite2-City.tar.gz
data/varken.ini
.idea/
Legacy/configuration.py
varken-venv/
logs/
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# Change Log

## [v1.4](https://github.com/Boerderij/Varken/tree/v1.4) (2018-12-18)
[Full Changelog](https://github.com/Boerderij/Varken/compare/v1.3-nightly...v1.4)

**Implemented enhancements:**

- \[Feature Request\] Add tautulli request for library stats [\#64](https://github.com/Boerderij/Varken/issues/64)

**Fixed bugs:**

- \[BUG\] Ombi all requests missing half of "pending" option [\#63](https://github.com/Boerderij/Varken/issues/63)
- \[BUG\] asa bug with checking for apikey [\#62](https://github.com/Boerderij/Varken/issues/62)

**Merged pull requests:**

- v1.4 Merge [\#65](https://github.com/Boerderij/Varken/pull/65) ([DirtyCajunRice](https://github.com/DirtyCajunRice))

## [v1.3-nightly](https://github.com/Boerderij/Varken/tree/v1.3-nightly) (2018-12-18)
[Full Changelog](https://github.com/Boerderij/Varken/compare/v1.2-nightly...v1.3-nightly)

**Implemented enhancements:**

- Create randomized 12-24 hour checks to update GeoLite DB after the first wednesday of the month [\#60](https://github.com/Boerderij/Varken/issues/60)

**Fixed bugs:**

- \[BUG\] Add Catchall to ombi requests [\#59](https://github.com/Boerderij/Varken/issues/59)

**Closed issues:**

- Unify naming and cleanup duplication in iniparser [\#61](https://github.com/Boerderij/Varken/issues/61)

## [v1.2-nightly](https://github.com/Boerderij/Varken/tree/v1.2-nightly) (2018-12-16)
[Full Changelog](https://github.com/Boerderij/Varken/compare/v1.1...v1.2-nightly)

**Implemented enhancements:**

- \[Feature Request\]: Pull list of requests \(instead of just counts\) [\#58](https://github.com/Boerderij/Varken/issues/58)
- Feature Request , Add Sickchill [\#48](https://github.com/Boerderij/Varken/issues/48)

## [v1.1](https://github.com/Boerderij/Varken/tree/v1.1) (2018-12-11)
[Full Changelog](https://github.com/Boerderij/Varken/compare/v1.0...v1.1)

Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM lsiobase/alpine.python3

LABEL maintainer="dirtycajunrice"

ENV DEBUG="False"

COPY / /app

RUN \
Expand All @@ -12,4 +14,4 @@ RUN \

CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config

VOLUME /config
VOLUME /config
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,36 @@ frontend
Requirements:
* Python3.6+
* Python3-pip
* InfluxDB
* [InfluxDB](https://www.influxdata.com/)

<p align="center">
<img width="800" src="https://i.imgur.com/av8e0HP.png">
Example Dashboard

<img width="800" src="https://nickflix.io/sharex/firefox_NxdrqisVLF.png">
</p>

Supported Modules:
* [Sonarr](https://sonarr.tv/) - Smart PVR for newsgroup and bittorrent users.
* [SickChill](https://sickchill.github.io/) - SickChill is an automatic Video Library Manager for TV Shows.
* [Radarr](https://radarr.video/) - A fork of Sonarr to work with movies à la Couchpotato.
* [Tautulli](https://tautulli.com/) - A Python based monitoring and tracking tool for Plex Media Server.
* [Ombi](https://ombi.io/) - Want a Movie or TV Show on Plex or Emby? Use Ombi!
* Cisco ASA

Key features:
* Multiple server support for all modules
* Geolocation mapping from [GeoLite2](https://dev.maxmind.com/geoip/geoip2/geolite2/)
* Grafana [Worldmap Panel](https://grafana.com/plugins/grafana-worldmap-panel/installation) support


## Quick Setup (Git Clone)
```
# Clone the repository
git clone https://github.com/Boerderij/Varken.git /opt/Varken
# Follow the systemd install instructions located in varken.systemd
nano /opt/Varken/varken.systemd
cp /opt/Varken/varken.systemd /etc/systemd/system/varken.service
nano /etc/systemd/system/varken.service
# Create venv in project
/usr/bin/python3 -m venv /opt/Varken/varken-venv
Expand All @@ -48,8 +64,8 @@ systemctl enable varken
```
### Docker

[![Docker-Layers](https://images.microbadger.com/badges/image/boerderij/varken.svg)](https://microbadger.com/images/boerderij/varken")
[![Docker-Version](https://images.microbadger.com/badges/version/boerderij/varken.svg)](https://microbadger.com/images/boerderij/varken")
[![Docker-Layers](https://images.microbadger.com/badges/image/boerderij/varken.svg)](https://microbadger.com/images/boerderij/varken)
[![Docker-Version](https://images.microbadger.com/badges/version/boerderij/varken.svg)](https://microbadger.com/images/boerderij/varken)
[![Docker Pulls](https://img.shields.io/docker/pulls/boerderij/varken.svg)](https://hub.docker.com/r/boerderij/varken/)
[![Docker Stars](https://img.shields.io/docker/stars/boerderij/varken.svg)](https://hub.docker.com/r/boerderij/varken/)
<details><summary>Example</summary>
Expand All @@ -59,7 +75,8 @@ systemctl enable varken
docker run -d \
--name=varken \
-v <path to data>:/config \
-e PGID=<gid> -e PUID=<uid> \
-e PGID=<gid> -e PUID=<uid> \
-e TZ=America/Chicago \
boerderij/varken
```
</p>
Expand Down Expand Up @@ -91,4 +108,4 @@ named `varken`
Grafana is used in our examples but not required, nor packaged as part of
Varken. Panel example pictures are pinned in the grafana-panels channel of
discord. Future releases may contain a json-generator, but it does not exist
as varken stands today.
as varken stands today.
88 changes: 58 additions & 30 deletions Varken.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import sys

# Check for python3.6 or newer to resolve erroneous typing.NamedTuple issues
if sys.version_info < (3, 6):
exit('Varken requires python3.6 or newer')

import schedule
import threading
import platform
import distro
import schedule

from sys import exit
from time import sleep
from os import access, R_OK
from sys import version
from threading import Thread
from os import access, R_OK, getenv
from distro import linux_distribution
from os.path import isdir, abspath, dirname, join
from argparse import ArgumentParser, RawTextHelpFormatter
from logging import getLogger, StreamHandler, Formatter, DEBUG

from varken.iniparser import INIParser
from varken.sonarr import SonarrAPI
from varken.tautulli import TautulliAPI
from varken.radarr import RadarrAPI
from varken.ombi import OmbiAPI
from varken.cisco import CiscoAPI
from varken import VERSION, BRANCH
from varken.sonarr import SonarrAPI
from varken.radarr import RadarrAPI
from varken.iniparser import INIParser
from varken.dbmanager import DBManager
from varken.helpers import GeoIPHandler
from varken.tautulli import TautulliAPI
from varken.sickchill import SickChillAPI
from varken.varkenlogger import VarkenLogger

PLATFORM_LINUX_DISTRO = ' '.join(x for x in distro.linux_distribution() if x)

PLATFORM_LINUX_DISTRO = ' '.join(x for x in linux_distribution() if x)


def threaded(job):
thread = threading.Thread(target=job)
thread = Thread(target=job)
thread.start()


Expand All @@ -44,27 +43,45 @@ def threaded(job):

DATA_FOLDER = abspath(join(dirname(__file__), 'data'))

templogger = getLogger('temp')
templogger.setLevel(DEBUG)
tempch = StreamHandler()
tempformatter = Formatter('%(asctime)s : %(levelname)s : %(module)s : %(message)s', '%Y-%m-%d %H:%M:%S')
tempch.setFormatter(tempformatter)
templogger.addHandler(tempch)

if opts.data_folder:
ARG_FOLDER = opts.data_folder

if isdir(ARG_FOLDER):
DATA_FOLDER = ARG_FOLDER
if not access(ARG_FOLDER, R_OK):
exit("Read permission error for {}".format(ARG_FOLDER))
if not access(DATA_FOLDER, R_OK):
templogger.error("Read permission error for %s", DATA_FOLDER)
exit(1)
else:
exit("{} does not exist".format(ARG_FOLDER))
templogger.error("%s does not exist", ARG_FOLDER)
exit(1)

# Set Debug to True if DEBUG env is set
enable_opts = ['True', 'true', 'yes']
debug_opts = ['debug', 'Debug', 'DEBUG']

if not opts.debug:
opts.debug = True if any([getenv(string, False) for true in enable_opts
for string in debug_opts if getenv(string, False) == true]) else False

# Initiate the logger
vl = VarkenLogger(data_folder=DATA_FOLDER, debug=opts.debug)
vl.logger.info('Starting Varken...')

vl.logger.info('Data folder is "%s"', DATA_FOLDER)

vl.logger.info(u"{} {} ({}{})".format(
platform.system(), platform.release(), platform.version(),
' - {}'.format(PLATFORM_LINUX_DISTRO) if PLATFORM_LINUX_DISTRO else ''
))
vl.logger.info(u"Python {}".format(sys.version))
vl.logger.info(u"%s %s (%s%s)", platform.system(), platform.release(), platform.version(),
f' - {PLATFORM_LINUX_DISTRO}' if PLATFORM_LINUX_DISTRO else '')

vl.logger.info(u"Python %s", version)

vl.logger.info("Varken v%s-%s", VERSION, BRANCH)

CONFIG = INIParser(DATA_FOLDER)
DBMANAGER = DBManager(CONFIG.influx_server)
Expand All @@ -80,10 +97,14 @@ def threaded(job):
schedule.every(server.future_days_run_seconds).seconds.do(threaded, SONARR.get_future)

if CONFIG.tautulli_enabled:
GEOIPHANDLER = GeoIPHandler(DATA_FOLDER)
schedule.every(12).to(24).hours.do(threaded, GEOIPHANDLER.update)
for server in CONFIG.tautulli_servers:
TAUTULLI = TautulliAPI(server, DBMANAGER, DATA_FOLDER)
TAUTULLI = TautulliAPI(server, DBMANAGER, GEOIPHANDLER)
if server.get_activity:
schedule.every(server.get_activity_run_seconds).seconds.do(threaded, TAUTULLI.get_activity)
if server.get_stats:
schedule.every(server.get_stats_run_seconds).seconds.do(threaded, TAUTULLI.get_stats)

if CONFIG.radarr_enabled:
for server in CONFIG.radarr_servers:
Expand All @@ -99,18 +120,25 @@ def threaded(job):
if server.request_type_counts:
schedule.every(server.request_type_run_seconds).seconds.do(threaded, OMBI.get_request_counts)
if server.request_total_counts:
schedule.every(server.request_total_run_seconds).seconds.do(threaded, OMBI.get_total_requests)
schedule.every(server.request_total_run_seconds).seconds.do(threaded, OMBI.get_all_requests)

if CONFIG.sickchill_enabled:
for server in CONFIG.sickchill_servers:
SICKCHILL = SickChillAPI(server, DBMANAGER)
if server.get_missing:
schedule.every(server.get_missing_run_seconds).seconds.do(threaded, SICKCHILL.get_missing)

if CONFIG.ciscoasa_enabled:
for firewall in CONFIG.ciscoasa_firewalls:
for firewall in CONFIG.ciscoasa_servers:
ASA = CiscoAPI(firewall, DBMANAGER)
schedule.every(firewall.get_bandwidth_run_seconds).seconds.do(threaded, ASA.get_bandwidth)

# Run all on startup
SERVICES_ENABLED = [CONFIG.ombi_enabled, CONFIG.radarr_enabled, CONFIG.tautulli_enabled,
CONFIG.sonarr_enabled, CONFIG.ciscoasa_enabled]
CONFIG.sonarr_enabled, CONFIG.ciscoasa_enabled, CONFIG.sickchill_enabled]
if not [enabled for enabled in SERVICES_ENABLED if enabled]:
exit("All services disabled. Exiting")
vl.logger.error("All services disabled. Exiting")
exit(1)
schedule.run_all()

while True:
Expand Down
33 changes: 23 additions & 10 deletions data/varken.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ radarr_server_ids = 1,2
tautulli_server_ids = 1
ombi_server_ids = 1
ciscoasa_firewall_ids = false
sickchill_server_ids = false

[influxdb]
url = influxdb.domain.tld
Expand All @@ -19,19 +20,21 @@ username =
password =

[tautulli-1]
url = tautulli.domain.tld
url = tautulli.domain.tld:8181
fallback_ip = 0.0.0.0
apikey = xxxxxxxxxxxxxxxx
ssl = false
verify_ssl = true
verify_ssl = false
get_activity = true
get_activity_run_seconds = 30
get_stats = true
get_stats_run_seconds = 3600

[sonarr-1]
url = sonarr1.domain.tld
url = sonarr1.domain.tld:8989
apikey = xxxxxxxxxxxxxxxx
ssl = false
verify_ssl = true
verify_ssl = false
missing_days = 7
missing_days_run_seconds = 300
future_days = 1
Expand All @@ -40,10 +43,10 @@ queue = true
queue_run_seconds = 300

[sonarr-2]
url = sonarr2.domain.tld
url = sonarr2.domain.tld:8989
apikey = yyyyyyyyyyyyyyyy
ssl = false
verify_ssl = true
verify_ssl = false
missing_days = 7
missing_days_run_seconds = 300
future_days = 1
Expand All @@ -55,7 +58,7 @@ queue_run_seconds = 300
url = radarr1.domain.tld
apikey = xxxxxxxxxxxxxxxx
ssl = false
verify_ssl = true
verify_ssl = false
queue = true
queue_run_seconds = 300
get_missing = true
Expand All @@ -65,7 +68,7 @@ get_missing_run_seconds = 300
url = radarr2.domain.tld
apikey = yyyyyyyyyyyyyyyy
ssl = false
verify_ssl = true
verify_ssl = false
queue = true
queue_run_seconds = 300
get_missing = true
Expand All @@ -75,17 +78,27 @@ get_missing_run_seconds = 300
url = ombi.domain.tld
apikey = xxxxxxxxxxxxxxxx
ssl = false
verify_ssl = true
verify_ssl = false
get_request_type_counts = true
request_type_run_seconds = 300
get_request_total_counts = true
request_total_run_seconds = 300

[sickchill-1]
url = sickchill.domain.tld:8081
apikey = xxxxxxxxxxxxxxxx
ssl = false
verify_ssl = false
get_missing = true
get_missing_run_seconds = 300



[ciscoasa-1]
url = firewall.domain.tld
username = cisco
password = cisco
outside_interface = WAN
ssl = false
verify_ssl = true
verify_ssl = false
get_bandwidth_run_seconds = 300
3 changes: 2 additions & 1 deletion varken/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VERSION = 1.1
VERSION = 1.4
BRANCH = 'master'
Loading

0 comments on commit 3fb63da

Please sign in to comment.