Skip to content

Commit

Permalink
Add sentry.io for monitoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
erunks committed Oct 21, 2021
1 parent 6ce192e commit 5576853
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ MODEM_USERNAME = "admin"
PI_EMAIL = "[email protected]"
PI_EMAIL_PASSWORD = "pi_email_password"
PING_COUNT = 5
SENTRY_DSN = "https://[email protected]/0"
SMTP_PORT = 587
SMTP_SERVER = "smtp.gmail.com"
10 changes: 10 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import asyncio
import sentry_sdk
from dotenv import load_dotenv, find_dotenv
from os import getenv
from src.InternetStatusReporter import InternetStatusReporter

load_dotenv(find_dotenv())

sentry_sdk.init(
getenv('SENTRY_DSN'),
traces_sample_rate=1.0,
)

if __name__ == "__main__":
isr = InternetStatusReporter()
loop = asyncio.get_event_loop()
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ MechanicalSoup
mysql.connector
pingparsing
python-dotenv
sentry-sdk
tcp-latency
3 changes: 0 additions & 3 deletions src/DatabaseInteractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

class DatabaseInteractor(MailLogger):
def __init__(self):
from dotenv import load_dotenv, find_dotenv

super().__init__()
load_dotenv(find_dotenv())

self.connection = None

def __del__(self):
Expand Down
3 changes: 0 additions & 3 deletions src/InternetStatusReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@

class InternetStatusReporter(DatabaseInteractor):
def __init__(self):
from dotenv import load_dotenv, find_dotenv
from src.utils import get_addresses

super().__init__()

load_dotenv(find_dotenv())

self.NETWORK_STATUS = {
'NORMAL': 0,
'DEGRADED': 1,
Expand Down
3 changes: 0 additions & 3 deletions src/MailLogger.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
class MailLogger:
def __init__(self):
from dotenv import load_dotenv, find_dotenv
from logging import ERROR, INFO, basicConfig, getLogger, Formatter
from src.MailHandler import MailHandler
from os import getenv

load_dotenv(find_dotenv())

logFormat = '%(asctime)s - %(levelname)s: %(message)s'
basicConfig(
filename=getenv('LOG_FILE'),
Expand Down
3 changes: 0 additions & 3 deletions src/ModemReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

class ModemReporter(DatabaseInteractor):
def __init__(self):
from dotenv import load_dotenv, find_dotenv
from os import getenv

super().__init__()

load_dotenv(find_dotenv())

MODEM_ADDRESS = getenv('MODEM_ADDRESS')

self.__setup_browser()
Expand Down

0 comments on commit 5576853

Please sign in to comment.