From 823b6c26367885823a6d67dc63da36bdad6ff6f0 Mon Sep 17 00:00:00 2001 From: Babak Farrokhi Date: Wed, 11 May 2016 11:22:07 +0430 Subject: [PATCH] minor improvements - increase read timeout to 50 seconds - ignore read failures to prevent app from crashing - change default host to ipv4 127.0.0.1 instead of localhost --- m2g-poller.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) mode change 100755 => 100644 m2g-poller.py diff --git a/m2g-poller.py b/m2g-poller.py old mode 100755 new mode 100644 index 9ea4e6c..39c8963 --- a/m2g-poller.py +++ b/m2g-poller.py @@ -79,7 +79,7 @@ class Munin(): """Initial connection to Munin host.""" try: self._sock = socket.create_connection((self.hostname, self.port), 10) - self._sock.settimeout(30) + self._sock.settimeout(50) except socket.error: logger.exception("Thread %s: Unable to connect to Munin host %s, port: %s", self.thread.name, self.hostname, self.port) @@ -232,7 +232,10 @@ class Munin(): self.plugins_config[current_plugin] = self.get_config(current_plugin) logger.debug("Thread %s: Plugin Config: %s", self.thread.name, self.plugins_config[current_plugin]) - plugin_data = self.fetch(current_plugin) + try: + plugin_data = self.fetch(current_plugin) + except: + continue logger.debug("Thread %s: Plugin Data: %s", self.thread.name, plugin_data) if self.args.carbon: for multigraph in self.plugins_config[current_plugin]: @@ -342,7 +345,7 @@ def parse_args(): help="Configuration file with list of hosts and their plugins to fetch.") parser.add_argument("--host", action="store", - default="localhost", + default="127.0.0.1", help="Munin host to query for stats. You can specify indirect node after ':', " "i.e. --host localhost:remotenode. Default: %(default)s") parser.add_argument("--displayname",