diff --git a/README.md b/README.md index 9db402e..987968f 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,10 @@ You can setup env through `.env` file or environment variables with defined as d ## Changelog +### Version 0.4.0 + +Higher timeout while getting WAN traffic info + ### Version 0.3.0 Use proper method to compute WAN traffic diff --git a/opnsense_exporter/opnsense_api.py b/opnsense_exporter/opnsense_api.py index c67b76a..fd61843 100644 --- a/opnsense_exporter/opnsense_api.py +++ b/opnsense_exporter/opnsense_api.py @@ -19,11 +19,11 @@ class OPNSenseAPI: def prepare_url(self, path): return f"https://{self.host}{path}" - def get(self, path): + def get(self, path, timeout=2): response = requests.get( self.prepare_url(path), auth=(self.login, self.password), - timeout=0.5, + timeout=timeout, # # as today I'm using the opnsense selfsigned certificat # # but we should avoid this instead trust any certificat verify=False, @@ -54,7 +54,7 @@ class OPNSenseAPI: def get_wan_trafic(self): try: - data = self.get("/api/diagnostics/traffic/top/wan") + data = self.get("/api/diagnostics/traffic/top/wan", timeout=15) except RequestException as ex: logger.error( "Get diagnostics traffic on WAN interface for %s host failed with the following error %r",