sock = BaseSocket(url)
self.log.debug('Sending data to Telegraf at %s', sock.address)
now = self.now()
- with sock as s:
- try:
+ try:
+ with sock as s:
for measurement in self.gather_measurements():
self.log.debug(measurement)
line = Line(measurement['measurement'],
measurement['tags'], now)
self.log.debug(line.to_line_protocol())
s.send(line.to_line_protocol())
- except (socket.error, RuntimeError, IOError, OSError):
- self.log.exception('Failed to send statistics to Telegraf:')
+ except (socket.error, RuntimeError, IOError, OSError):
+ self.log.exception('Failed to send statistics to Telegraf:')
+ except FileNotFoundError:
+ self.log.exception('Failed to open Telegraf at: %s', url.geturl())
def shutdown(self):
self.log.info('Stopping Telegraf module')