55class Config (object ):
66 options = ['INTERVAL' , 'PROMETHEUS' , 'DOCKER_SOCKETS' , 'MONITOR' , 'IGNORE' , 'LOG_LEVEL' , 'PROMETHEUS_ADDR' ,
77 'PROMETHEUS_PORT' , 'WEBHOOK_URLS' , 'REPO_USER' , 'REPO_PASS' , 'CLEANUP' , 'RUN_ONCE' , 'LATEST' ,
8- 'INFLUX_URL' , 'INFLUX_PORT' , 'INFLUX_USERNAME' , 'INFLUX_PASSWORD' , 'INFLUX_DATABASE' ,
9- 'INFLUX_SSL ' , 'INFLUX_VERIFY_SSL ' , 'DATA_EXPORT ' ]
8+ 'INFLUX_URL' , 'INFLUX_PORT' , 'INFLUX_USERNAME' , 'INFLUX_PASSWORD' , 'INFLUX_DATABASE' , 'INFLUX_SSL' ,
9+ 'INFLUX_VERIFY_SSL ' , 'DATA_EXPORT ' , 'PUSHOVER_TOKEN' , 'PUSHOVER_USER' , 'PUSHOVER_DEVICE ' ]
1010
1111 interval = 300
1212 docker_sockets = 'unix://var/run/docker.sock'
1313 monitor = []
1414 ignore = []
15- webhook_urls = []
16- webhook_type = 'slack'
1715 data_export = None
1816 log_level = 'info'
1917 latest = False
@@ -36,6 +34,12 @@ class Config(object):
3634 influx_password = 'root'
3735 influx_database = None
3836
37+ webhook_urls = []
38+
39+ pushover_token = None
40+ pushover_user = None
41+ pushover_device = None
42+
3943 def __init__ (self , environment_vars , cli_args ):
4044 self .cli_args = cli_args
4145 self .environment_vars = environment_vars
@@ -76,6 +80,12 @@ def parse(self):
7680 setattr (self , option .lower (), opt )
7781 except ValueError as e :
7882 print (e )
83+ elif option in ['LATEST' , 'CLEANUP' , 'RUN_ONCE' , 'INFLUX_SSL' , 'INFLUX_VERIFY_SSL' ]:
84+ if self .environment_vars [option ].lower () == 'true' :
85+ setattr (self , option .lower (), True )
86+ else :
87+ self .logger .error ('%s is not a valid option for %s. setting to false' ,
88+ self .environment_vars [option ], option )
7989 else :
8090 setattr (self , option .lower (), self .environment_vars [option ])
8191 elif vars (self .cli_args ).get (option ):
@@ -93,4 +103,16 @@ def parse(self):
93103 string_list = getattr (self , option )
94104 setattr (self , option , [string .strip (' ' ) for string in string_list .split (' ' )])
95105
106+ # Config sanity checks
107+ if self .data_export == 'influxdb' and not self .influx_database :
108+ self .logger .error ("You need to specify an influx database if you want to export to influxdb. Disabling "
109+ "influxdb data export." )
110+
111+ pushover_config = [self .pushover_token , self .pushover_device , self .pushover_user ]
112+ if any (pushover_config ) and not all (pushover_config ):
113+ self .logger .error ('You must specify a pushover user, token, and device to use pushover. Disabling '
114+ 'pushover notifications' )
115+ elif all (pushover_config ):
116+ self .webhook_urls .append ('https://api.pushover.net/1/messages.json' )
117+
96118 self .config_blacklist ()
0 commit comments