diff --git a/etc/uplink.json.example b/etc/uplink.json.example index 5861722..5fadaf4 100644 --- a/etc/uplink.json.example +++ b/etc/uplink.json.example @@ -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" diff --git a/uplink/configuration.py b/uplink/configuration.py index 5a1840c..c136790 100644 --- a/uplink/configuration.py +++ b/uplink/configuration.py @@ -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 diff --git a/uplink/notification.py b/uplink/notification.py index b1e2e4a..808dcde 100644 --- a/uplink/notification.py +++ b/uplink/notification.py @@ -40,4 +40,4 @@ class Notification: # "SMSC": {"Location": 1}, #} #self.__state_machine.SendSMS(message) - logger.error(status) + logger.info(status) diff --git a/uplink/uplink.py b/uplink/uplink.py index 7956701..861bc07 100644 --- a/uplink/uplink.py +++ b/uplink/uplink.py @@ -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))