338
338
logger.info(u"Starting checker %r for %s",
339
339
command, self.name)
340
# We don't need to redirect stdout and stderr, since
341
# in normal mode, that is already done by daemon(),
342
# and in debug mode we don't want to. (Stdin is
343
# always replaced by /dev/null.)
340
344
self.checker = subprocess.Popen(command,
342
346
shell=True, cwd="/")
343
347
self.checker_callback_tag = gobject.child_watch_add\
344
348
(self.checker.pid,
345
349
self.checker_callback)
346
except subprocess.OSError, error:
350
except OSError, error:
347
351
logger.error(u"Failed to start subprocess: %s",
349
353
# Re-run this periodically if run by gobject.timeout_add
563
567
datetime.timedelta(1)
564
568
>>> string_to_delta(u'1w')
565
569
datetime.timedelta(7)
570
>>> string_to_delta('5m 30s')
571
datetime.timedelta(0, 330)
568
suffix=unicode(interval[-1])
569
value=int(interval[:-1])
571
delta = datetime.timedelta(value)
573
delta = datetime.timedelta(0, value)
575
delta = datetime.timedelta(0, 0, 0, 0, value)
577
delta = datetime.timedelta(0, 0, 0, 0, 0, value)
579
delta = datetime.timedelta(0, 0, 0, 0, 0, 0, value)
573
timevalue = datetime.timedelta(0)
574
for s in interval.split():
576
suffix=unicode(s[-1])
579
delta = datetime.timedelta(value)
581
delta = datetime.timedelta(0, value)
583
delta = datetime.timedelta(0, 0, 0, 0, value)
585
delta = datetime.timedelta(0, 0, 0, 0, 0, value)
587
delta = datetime.timedelta(0, 0, 0, 0, 0, 0, value)
590
except (ValueError, IndexError):
582
except (ValueError, IndexError):
587
596
def server_state_changed(state):
732
741
# Parse config file with clients
733
742
client_defaults = { "timeout": "1h",
734
743
"interval": "5m",
735
"checker": "fping -q -- %%(host)s",
744
"checker": "fping -q -- %(host)s",
737
747
client_config = ConfigParser.SafeConfigParser(client_defaults)
738
748
client_config.read(os.path.join(server_settings["configdir"],
772
782
logger.critical(u"No clients defined")
786
# Redirect stdin so all checkers get /dev/null
787
null = os.open(os.path.devnull, os.O_NOCTTY | os.O_RDWR)
788
os.dup2(null, sys.stdin.fileno())
776
793
logger.removeHandler(console)
794
# Close all input and output, do double fork, etc.
779
797
pidfilename = "/var/run/mandos/mandos.pid"