Notification stuff and bug fixes.
This commit is contained in:
parent
8b6718f5e2
commit
95f5f1a351
4 changed files with 21 additions and 6 deletions
|
|
@ -22,14 +22,14 @@
|
|||
"speedtest_url": "https://go.microsoft.com/fwlink/?Linkid=850641",
|
||||
"uplinks": [
|
||||
{
|
||||
"identifier": "vodafone",
|
||||
"identifier": "cable",
|
||||
"primary": true,
|
||||
"ip": "192.168.0.1",,
|
||||
"password": "PASSWORD",
|
||||
"provider": "Cable Provider"
|
||||
},
|
||||
{
|
||||
"identifier": "telekom",
|
||||
"identifier": "dsl",
|
||||
"ip": "192.168.1.1",
|
||||
"password": "PASSWORD",
|
||||
"provider": "DSL Provider"
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class Configuration:
|
|||
self.__notification_gammu = False
|
||||
self.__notification_gammu_configuration = None
|
||||
self.__notification_gammu_receiver = None
|
||||
self.__notification_gammu_repeat = 30
|
||||
self.__pid_file = '/tmp/uplink.pid'
|
||||
self.__run_mode = 'cron'
|
||||
self.__speedtest = False
|
||||
|
|
@ -115,6 +116,9 @@ class Configuration:
|
|||
'notification_gammu' in self.__configuration:
|
||||
raise Exception('notification_gammu_receiver required!')
|
||||
|
||||
if 'notification_gammu_repeat' in self.__configuration:
|
||||
self.__notification_gammu_repeat = self.__configuration['notification_gammu_repeat']
|
||||
|
||||
if 'pid_file' in self.__configuration:
|
||||
self.__pid_file = self.__configuration['pid_file']
|
||||
|
||||
|
|
@ -193,6 +197,9 @@ class Configuration:
|
|||
def get_notification_gammu_receiver(self):
|
||||
return self.__notification_gammu_receiver
|
||||
|
||||
def get_notification_gammu_repeat(self):
|
||||
return self.__notification_gammu_repeat
|
||||
|
||||
def get_pid_file(self):
|
||||
return self.__pid_file
|
||||
|
||||
|
|
|
|||
|
|
@ -40,4 +40,4 @@ class Notification:
|
|||
# "SMSC": {"Location": 1},
|
||||
#}
|
||||
#self.__state_machine.SendSMS(message)
|
||||
logger.error(status)
|
||||
logger.info(status)
|
||||
|
|
|
|||
|
|
@ -114,9 +114,17 @@ class Uplink(Daemon):
|
|||
status = 'DOWN'
|
||||
|
||||
if self.__configuration.get_notification_gammu() is True:
|
||||
from uplink.notification import Notification
|
||||
notification = Notification(self.__configuration)
|
||||
notification.send('STATUS: ' + status)
|
||||
notification_gammu_repeat = self.__configuration.get_notification_gammu_repeat()
|
||||
|
||||
"""
|
||||
send notification on first occurrence and on
|
||||
(fail_count % notification_gammu_repeat == 0) which is
|
||||
(notification_gammu_repeat * interval) in seconds.
|
||||
"""
|
||||
if fail_count == 1 or fail_count % notification_gammu_repeat == 0:
|
||||
from uplink.notification import Notification
|
||||
notification = Notification(self.__configuration)
|
||||
notification.send('[' + uplink['provider'] + '] ' + status)
|
||||
|
||||
logger.info(str(uplink['provider'] + ' (IP: ' + fritz_connection.external_ip + ') ' +
|
||||
status))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue