Explorar o código

added dryrun check

Tony Fernandez hai 7 meses
pai
achega
8edb40a8e9
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      borgmatic/hooks/zabbix.py

+ 3 - 2
borgmatic/hooks/zabbix.py

@@ -66,8 +66,9 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev
         
         
     elif username and password is not None:
     elif username and password is not None:
         logger.info(f'{config_filename}: Using user/pass auth with user {username} for Zabbix')
         logger.info(f'{config_filename}: Using user/pass auth with user {username} for Zabbix')
-        response = requests.post(base_url, headers=headers, data='{"jsonrpc":"2.0","method":"user.login","params":{"username":"'+username+'","password":"'+password+'"},"id":1}')
-        data['auth'] = response.json().get('result')
+        if not dry_run:
+            response = requests.post(base_url, headers=headers, data='{"jsonrpc":"2.0","method":"user.login","params":{"username":"'+username+'","password":"'+password+'"},"id":1}')
+            data['auth'] = response.json().get('result')
 
 
     elif username is not None:
     elif username is not None:
         logger.warning( f'{config_filename}: Password missing for Zabbix authentication' )
         logger.warning( f'{config_filename}: Password missing for Zabbix authentication' )