data = ""
while True:
try:
- ready_to_read, _, in_error = select.select([self._sock], [], [], 15)
+ ready_to_read, _, in_error = select.select([self._sock], [], [], 5)
except Exception as e:
self.debug("SELECT", str(e))
self._disconnect()
buf = self._sock.recv(4096)
if len(buf) == 0 or buf is None: # handle server disconnect
break
- data += buf.decode()
+ data += buf.decode(errors='ignore')
if self._check_raw_data(data):
break
else:
self.unix_socket = str(self.configuration['socket'])
except (KeyError, TypeError):
self.debug("No unix socket specified. Trying TCP/IP socket.")
+ self.unix_socket = None
try:
self.host = str(self.configuration['host'])
except (KeyError, TypeError):
self.debug("No request specified. Using: '" + str(self.request) + "'")
self.request = self.request.encode()
+ def check(self):
+ self._parse_config()
+ return SimpleService.check(self)
+
class LogService(SimpleService):
def __init__(self, configuration=None, name=None):
self.command = str(self.configuration['command'])
except (KeyError, TypeError):
self.error("No command specified. Using: '" + self.command + "'")
- self.command = self.command.split(' ')
+ command = self.command.split(' ')
- for arg in self.command[1:]:
+ for arg in command[1:]:
if any(st in arg for st in self.bad_substrings):
self.error("Bad command argument:" + " ".join(self.command[1:]))
return False
# test command and search for it in /usr/sbin or /sbin when failed
- base = self.command[0].split('/')[-1]
+ base = command[0].split('/')[-1]
if self._get_raw_data() is None:
for prefix in ['/sbin/', '/usr/sbin/']:
- self.command[0] = prefix + base
- if os.path.isfile(self.command[0]):
+ command[0] = prefix + base
+ if os.path.isfile(command[0]):
break
-
+ self.command = command
if self._get_data() is None or len(self._get_data()) == 0:
self.error("Command", self.command, "returned no data")
return False