Skip to content

Commit

Permalink
General cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
barrycarey committed Sep 7, 2018
1 parent cffd4a6 commit ae72953
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -9,7 +9,7 @@ This is a tool for collecting some basic info about your Plex server and sending

Enter your desired information in config.ini and run plexcollector.py

**Please Note**: If you have authentication enable in InfluxDB the provided user must be able to run the show users command and create databases
**Please Note**: If you have authentication enable in InfluxDB the provided user must be an admin

## Configuration within config.ini

Expand All @@ -18,7 +18,6 @@ Enter your desired information in config.ini and run plexcollector.py
|:--------------|:-------------------------------------------------------------------------------------------------------------------|
|Delay |Delay between updating metrics |
|ReportCombined |When using multiple servers report total streams over all servers |
|Output |Write console output while tool is running |
#### INFLUXDB
|Key |Description |
|:--------------|:-------------------------------------------------------------------------------------------------------------------|
Expand All @@ -27,12 +26,15 @@ Enter your desired information in config.ini and run plexcollector.py
|Database |Database to write collected stats to |
|Username |User that has access to the database |
|Password |Password for above user |
|Verify_SSL |Disable SSL verification for InfluxDB Connection |
#### PLEX
|Key |Description |
|:--------------|:-------------------------------------------------------------------------------------------------------------------|
|Username |Plex username |
|Password |Plex Password |
|Servers |A comma separated list of servers you wish to pull data from. |
|HTTPS |Connect to server using HTTPS |
|Verify_SSL |Disable SSL verification (Use this if you have a self sign SSL) |
#### LOGGING
|Key |Description |
|:--------------|:-------------------------------------------------------------------------------------------------------------------|
Expand All @@ -49,5 +51,6 @@ Run `pip install -r requirements.txt`
Python Packages
* [influxdb](https://github.com/influxdata/influxdb-python)
* [plexapi](https://pypi.org/project/PlexAPI/)
* [requests](https://pypi.org/project/requests/)


5 changes: 3 additions & 2 deletions plexcollector/PlexInfluxdbCollector.py
Expand Up @@ -11,9 +11,10 @@
from plexapi.server import PlexServer
from requests import ConnectTimeout

from plexcollector.config import config, log

from plexcollector.common import log
from plexcollector.config import config

# TODO - Update readme for PMS SSL
class PlexInfluxdbCollector:

def __init__(self, single_run=False):
Expand Down
2 changes: 2 additions & 0 deletions plexcollector/common/__init__.py
@@ -0,0 +1,2 @@
from .utils import log

24 changes: 24 additions & 0 deletions plexcollector/common/utils.py
@@ -0,0 +1,24 @@
import logging
import sys

from plexcollector.common.logfilters import SingleLevelFilter
from plexcollector.config import config

log = logging.getLogger(__name__)
log.setLevel(config.logging_level)
formatter = logging.Formatter('%(asctime)s%(levelname)s:%(module)s:%(funcName)s:%(lineno)d: %(message)s')

general_handler = logging.StreamHandler(sys.stdout)
general_filter = SingleLevelFilter(logging.INFO, False)
general_handler.setFormatter(formatter)
general_handler.addFilter(general_filter)
log.addHandler(general_handler)

error_handler = logging.StreamHandler(sys.stderr)
error_filter = SingleLevelFilter(logging.WARNING)
error_handler.setFormatter(formatter)
error_handler.addFilter(error_filter)
log.addHandler(error_handler)

log.propagate = False

21 changes: 0 additions & 21 deletions plexcollector/config/__init__.py
@@ -1,8 +1,5 @@
import logging
import os
import sys

from plexcollector.common.logfilters import SingleLevelFilter
from plexcollector.config.configmanager import ConfigManager

if os.getenv('devconfig'):
Expand All @@ -12,21 +9,3 @@

config = ConfigManager(config)

log = logging.getLogger(__name__)
log.setLevel(config.logging_level)
formatter = logging.Formatter('%(asctime)s%(levelname)s:%(module)s:%(funcName)s:%(lineno)d: %(message)s')

general_handler = logging.StreamHandler(sys.stdout)
general_filter = SingleLevelFilter(logging.INFO, False)
general_handler.setFormatter(formatter)
general_handler.addFilter(general_filter)
log.addHandler(general_handler)

error_handler = logging.StreamHandler(sys.stderr)
error_filter = SingleLevelFilter(logging.WARNING)
error_handler.setFormatter(formatter)
error_handler.addFilter(error_filter)
log.addHandler(error_handler)

log.propagate = False

0 comments on commit ae72953

Please sign in to comment.