Skip to content
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

v1.1 Merge #57

Merged
merged 36 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
181925e
final v1.0
dirtycajunrice Dec 10, 2018
1dc8201
passed data folder to tautulli for helper functions. Fixes #46
dirtycajunrice Dec 10, 2018
15bd7b5
changed Missing available to 0/1 for grafana colorization
dirtycajunrice Dec 10, 2018
8a0cae4
Handle invalid config better and log it
samwiseg0 Dec 10, 2018
af40463
Handle invalid config better and log it
samwiseg0 Dec 10, 2018
8115a9f
Added titleSlug to radarrEnhancement for #50
samwiseg0 Dec 10, 2018
a4fa388
Merge branch 'nightly' of https://github.com/DirtyCajunRice/grafana-s…
samwiseg0 Dec 10, 2018
11e0b29
Handle exceptions in a differnt place
samwiseg0 Dec 11, 2018
e7705d7
Add extra_type to Tautulli structures
samwiseg0 Dec 11, 2018
273706d
Convert missing available to True False
samwiseg0 Dec 11, 2018
1aa3ee2
Revert "Convert missing available to True False"
dirtycajunrice Dec 11, 2018
8fff81b
Add logs to gitignore
samwiseg0 Dec 11, 2018
6bef586
Travis-CI Dockerbuild test
dirtycajunrice Dec 11, 2018
8d43d1e
Merge remote-tracking branch 'origin/nightly' into nightly
dirtycajunrice Dec 11, 2018
bc6865a
Added logging to the GeoLite2 downloader
samwiseg0 Dec 11, 2018
534c457
Add logging to geo_lookup.
samwiseg0 Dec 11, 2018
0b1ef7d
Merge branch 'nightly' of https://github.com/DirtyCajunRice/grafana-s…
samwiseg0 Dec 11, 2018
f8a1582
Log data folder on start
samwiseg0 Dec 11, 2018
6079188
updated readme + travis. Also addresses #53
dirtycajunrice Dec 11, 2018
940ff41
Merge remote-tracking branch 'origin/nightly' into nightly
dirtycajunrice Dec 11, 2018
3ce2069
sigh... spaces and such
dirtycajunrice Dec 11, 2018
c99020e
sigh... spaces and such
dirtycajunrice Dec 11, 2018
abed6f2
sigh... spaces and such
dirtycajunrice Dec 11, 2018
13d369c
split out stages for travis
dirtycajunrice Dec 11, 2018
efa50f0
split out stages for travis
dirtycajunrice Dec 11, 2018
cbed1e5
added licence
dirtycajunrice Dec 11, 2018
ccc1c0c
Update issue templates
dirtycajunrice Dec 11, 2018
9489c2b
test travis
dirtycajunrice Dec 11, 2018
001a650
test2
dirtycajunrice Dec 11, 2018
110aab2
test3?
dirtycajunrice Dec 11, 2018
b9b7d71
made time local to the function. Fixes #56
dirtycajunrice Dec 11, 2018
41332c4
test for cibuild
dirtycajunrice Dec 11, 2018
0596c9a
test4
dirtycajunrice Dec 11, 2018
8ffa4a8
test5
dirtycajunrice Dec 11, 2018
c47c756
Changelog + Version bump
dirtycajunrice Dec 11, 2018
6cc941b
remove need for branches
dirtycajunrice Dec 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: awaiting-approval
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. ...
2. ...
3. ...
4. ...

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
- OS: [e.g. Ubuntu 18.04.1 or Docker:Tag]
- Version [e.g. v1.1]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature Request]"
labels: awaiting-approval
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ data/varken.ini
.idea/
Legacy/configuration.py
varken-venv/
logs/
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
- docker

jobs:
include:
- stage: "Build and Push"
script:
- docker build -t boerderij/varken:$TRAVIS_BRANCH .
- docker images
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker push boerderij/varken:$TRAVIS_BRANCH

env:
global:
- secure: c91+zQXN28Anr2q94vhJAzN36teKovgniNmUI0MaejYfwcShN8TVeojkxbP+AxZuvGh1AfvB26LQeuPqAAntoNxvtPg3PLxv93rRSkAf0jk9apm9biYDAJNAM3OSiqCGfzfNhtUHmPmybRy2UmRXpHc6ZU1GmOdX2yyXCC2S6wjJOGabRpCA2Lw1vNnQuSJMDZ78amybZNmqAkK+rxe9hH2TGwcSImW8dlW2Ryt8H4a2s9VW9rbebQF+PzY4pw+OlIarpVUXZzUyEq8PS2EmJTuhrNA+RtZWJ4yRZ33jK4UqZRJzfC4FniZzSqtV/P3YGgSFNzhM87y5VhNiauX6QmtIDfLUV6c86cWCy24O41SrAJQOi4CLszJVkYfyggVFoRFegNS2+njN+f2Bbbx3rHtmNds0cDSfFuK3XhtTe0EhNgHLXOCX4IyAGzYWO+afmbqm/8S+m/QjCT28+0GgxYSqD2qO3FuPRA7woWucrKl2xa/tYikkurkDif0yBHxPac8mB8KLPLrjGzHlBG6SYYpTlpjWJrddbYhm0EZVmMkkFHRHLcOK8AOHKQipQBHmP+wvTGouwaZ8Uv5+uDNZ76st4BZR1tfXCtZ6A0RLRspo0wJ5EKlrNr8OIQGdj1G4TJ0H029mycqkAQ5yFPlvF/wAZ0shVFb/uMejpQw+2ks=
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
# Change Log

## [v1.0](https://github.com/Boerderij/Varken/tree/v1.0) (2018-12-09)
## [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)

**Implemented enhancements:**

- Convert missing available to True False [\#54](https://github.com/Boerderij/Varken/issues/54)
- Handle invalid config better and log it [\#51](https://github.com/Boerderij/Varken/issues/51)
- Feature Request - Include value from Radarr [\#50](https://github.com/Boerderij/Varken/issues/50)
- Change true/false to 0/1 for missing movies [\#47](https://github.com/Boerderij/Varken/issues/47)

**Fixed bugs:**

- \[BUG\] Time does not update from "today" [\#56](https://github.com/Boerderij/Varken/issues/56)
- geoip\_download does not account for moving data folder [\#46](https://github.com/Boerderij/Varken/issues/46)

**Closed issues:**

- Initial startup requires admin access to InfluxDB [\#53](https://github.com/Boerderij/Varken/issues/53)
- Ability to add custom tautulli port [\#49](https://github.com/Boerderij/Varken/issues/49)

**Merged pull requests:**

- v1.1 Merge [\#57](https://github.com/Boerderij/Varken/pull/57) ([DirtyCajunRice](https://github.com/DirtyCajunRice))
- Update issue templates [\#55](https://github.com/Boerderij/Varken/pull/55) ([DirtyCajunRice](https://github.com/DirtyCajunRice))

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

**Implemented enhancements:**

- Add cisco asa from legacy [\#44](https://github.com/Boerderij/Varken/issues/44)
- Add server ID to ombi to differenciate [\#43](https://github.com/Boerderij/Varken/issues/43)

**Merged pull requests:**

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

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

Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM lsiobase/alpine.python3

LABEL maintainer="dirtycajunrice"

COPY / /app

RUN \
python3 -m pip install -r /app/requirements.txt && \
chown -R abc:abc \
/config \
/app

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

VOLUME /config
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Boerderij

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
78 changes: 62 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Varken
[![Build Status](https://travis-ci.org/Boerderij/Varken.svg?branch=master)](https://travis-ci.org/Boerderij/Varken)
[![Discord](https://img.shields.io/badge/Discord-Varken-7289DA.svg?logo=discord&style=flat-square)](https://discord.gg/AGTG44H)
[![BuyMeACoffee](https://img.shields.io/badge/BuyMeACoffee-Donate-ff813f.svg?logo=CoffeeScript&style=flat-square)](https://www.buymeacoffee.com/varken)
[![Docker Pulls](https://img.shields.io/docker/pulls/boerderij/varken.svg?style=flat-square)](https://hub.docker.com/r/boerderij/varken/)

Dutch for PIG. PIG is an Acronym for Plex/InfluxDB/Grafana

Expand All @@ -12,28 +12,46 @@ frontend
Requirements:
* Python3.6+
* Python3-pip
* InfluxDB

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

## Quick Setup
1. Clone the repository `sudo git clone https://github.com/Boerderij/Varken.git /opt/Varken`
1. Follow the systemd install instructions located in `varken.systemd`
1. Create venv in project `cd /opt/Varken && /usr/bin/python3 -m venv varken-venv`
1. Install requirements `/opt/Varken/varken-venv/bin/python -m pip install -r requirements.txt`
1. Make a copy of `varken.example.ini` to `varken.ini` in the `data` folder
`cp /opt/Varken/data/varken.example.ini /opt/Varken/data/varken.ini`
1. Make the appropriate changes to `varken.ini`
ie.`nano /opt/Varken/data/varken.ini`
1. Make sure all the files have the appropriate permissions `sudo chown varken:varken -R /opt/Varken`
1. After completing the [getting started](http://docs.grafana.org/guides/getting_started/) portion of grafana, create your datasource for influxdb.
1. Install `grafana-cli plugins install grafana-worldmap-panel`
## Quick Setup (Git Clone)
```
# Clone the repository
git clone https://github.com/Boerderij/Varken.git /opt/Varken

### Docker
# Follow the systemd install instructions located in varken.systemd
nano /opt/Varken/varken.systemd
cp /opt/Varken/varken.systemd /etc/systemd/system/varken.service

# Create venv in project
/usr/bin/python3 -m venv /opt/Varken/varken-venv

# Install requirements
/opt/Varken/varken-venv/bin/python -m pip install -r requirements.txt

Repo is included in [Boerderij/docker-Varken](https://github.com/Boerderij/docker-Varken)
# Make a copy of varken.example.ini to varken.ini in the data folder
cp /opt/Varken/data/varken.example.ini /opt/Varken/data/varken.ini

# Make the appropriate changes to varken.ini
nano /opt/Varken/data/varken.ini

# Make sure all the files have the appropriate permissions
chown $USER:$USER -R /opt/Varken

# Start the service and enable it
systemctl start varken
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 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>
<p>

Expand All @@ -42,7 +60,35 @@ docker run -d \
--name=varken \
-v <path to data>:/config \
-e PGID=<gid> -e PUID=<uid> \
boerderij/varken:nightly
boerderij/varken
```
</p>
</details>

#### Tags
* **latest**
* **nightly**
* **release-tag** e.g. v1.0

#### Upgrading with docker
```sh
docker stop varken
docker rm varken
# Run deploy command above
```

### InfluxDB
[InfluxDB Installation Documentation](https://docs.influxdata.com/influxdb/v1.7/introduction/installation/)

Influxdb is required but not packaged as part of Varken. Varken will create
its database on its own. If you choose to give varken user permissions that
do not include database creation, please ensure you create an influx database
named `varken`

### Grafana
[Grafana Installation Documentation](http://docs.grafana.org/installation/)

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.
4 changes: 3 additions & 1 deletion Varken.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def threaded(job):
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 ''
Expand All @@ -79,7 +81,7 @@ def threaded(job):

if CONFIG.tautulli_enabled:
for server in CONFIG.tautulli_servers:
TAUTULLI = TautulliAPI(server, DBMANAGER)
TAUTULLI = TautulliAPI(server, DBMANAGER, DATA_FOLDER)
if server.get_activity:
schedule.every(server.get_activity_run_seconds).seconds.do(threaded, TAUTULLI.get_activity)

Expand Down
2 changes: 1 addition & 1 deletion varken/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = 1.0
VERSION = 1.1
1 change: 0 additions & 1 deletion varken/cisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def get_bandwidth(self):
return

req = self.session.prepare_request(Request('GET', self.firewall.url + endpoint))
print(req.headers)
get = connection_handler(self.session, req, self.firewall.verify_ssl)

if not get:
Expand Down
31 changes: 24 additions & 7 deletions varken/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,48 @@
logger = logging.getLogger('varken')


def geoip_download():
tar_dbfile = abspath(join('.', 'data', 'GeoLite2-City.tar.gz'))
def geoip_download(data_folder):
datafolder = data_folder

tar_dbfile = abspath(join(datafolder, 'GeoLite2-City.tar.gz'))

url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz'
logger.info('Downloading GeoLite2 from %s', url)
urlretrieve(url, tar_dbfile)

tar = tarfile.open(tar_dbfile, 'r:gz')
logging.debug('Opening GeoLite2 tar file : %s', tar_dbfile)

for files in tar.getmembers():
if 'GeoLite2-City.mmdb' in files.name:
logging.debug('"GeoLite2-City.mmdb" FOUND in tar file')
files.name = os.path.basename(files.name)
tar.extract(files, abspath(join('.', 'data')))

tar.extract(files, datafolder)
logging.debug('%s has been extracted to %s', files, datafolder)

os.remove(tar_dbfile)


def geo_lookup(ipaddress):
def geo_lookup(ipaddress, data_folder):
datafolder = data_folder
logging.debug('Reading GeoLite2 from %s', datafolder)

dbfile = abspath(join('.', 'data', 'GeoLite2-City.mmdb'))
dbfile = abspath(join(datafolder, 'GeoLite2-City.mmdb'))
now = time.time()

try:
dbinfo = os.stat(dbfile)
db_age = now - dbinfo.st_ctime
if db_age > (35 * 86400):
logging.info('GeoLite2 DB is older than 35 days. Attempting to re-download...')

os.remove(dbfile)
geoip_download()

geoip_download(datafolder)
except FileNotFoundError:
geoip_download()
logging.error('GeoLite2 DB not found. Attempting to download...')
geoip_download(datafolder)

reader = geoip2.database.Reader(dbfile)

Expand Down
17 changes: 10 additions & 7 deletions varken/iniparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ def __init__(self, data_folder):

def enable_check(self, server_type=None):
t = server_type
global_server_ids = self.config.get('global', t)
if global_server_ids.lower() in ['false', 'no', '0']:
logger.info('%s disabled.', t.upper())
return False
else:
sids = self.clean_check(global_server_ids, t)
return sids
try:
global_server_ids = self.config.get('global', t)
if global_server_ids.lower() in ['false', 'no', '0']:
logger.info('%s disabled.', t.upper())
return False
else:
sids = self.clean_check(global_server_ids, t)
return sids
except configparser.NoOptionError as e:
logger.error(e)

@staticmethod
def clean_check(server_id_list, server_type=None):
Expand Down
Loading