-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option for suspend before starting. Add support multiple riemann … #23
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ | |
# Add cwd-relative lib to path | ||
import os | ||
import sys | ||
sys.path.append("lib") | ||
|
||
dirname = os.path.dirname(os.path.dirname(__file__)) | ||
sys.path.append(os.path.join(dirname, 'lib')) | ||
|
||
# Misc standard library imports | ||
import time | ||
|
@@ -51,6 +53,7 @@ parser.add_option("--log-dir", dest="log_directory", default="/var/log", help="D | |
parser.add_option("--config-dir", dest="config_directory", default="/etc/sumd", help="Root path where tasks.d and tags.d can be found") | ||
parser.add_option("--run-dir", dest="run_directory", default="/var/run", help="Directory for where pidfiles should be placed") | ||
parser.add_option("--foreground", dest="foreground", action='store_true', default=False, help="Don't daemonize.") | ||
parser.add_option("--suspend", dest="suspend", default=0, help="Suspend time before task starting.") | ||
parser.add_option("--debug", dest="debug", action='store_true', default=False, help="Increase logger verbosity") | ||
parser.add_option("--client-key-file", dest="client_key_file", help="Path to client SSL key file") | ||
parser.add_option("--client-cert-file", dest="client_cert_file", help="Path to client SSL cert file") | ||
|
@@ -128,18 +131,22 @@ def load_configs(schedule): | |
schedule.add(task) | ||
|
||
def riemann_client(): | ||
if options.client_key_file != None and options.client_cert_file != None: | ||
riemann = bernhard.SSLClient( | ||
host=options.riemann_host, | ||
port=options.riemann_port, | ||
keyfile=options.client_key_file, | ||
certfile=options.client_cert_file, | ||
ca_certs=options.ca_certs_file) | ||
else: | ||
riemann = bernhard.Client( | ||
host=options.riemann_host, | ||
port=options.riemann_port, | ||
transport=bernhard.UDPTransport) | ||
riemann = [] | ||
if type(options.riemann_host) not in (list, tuple): | ||
options.riemann_host = [options.riemann_host] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting over 'options.riemann_host' feels a bit weird here, because it comes from the argparser. Does it make sense to assign to a new variable? |
||
for h in options.riemann_host: | ||
if options.client_key_file != None and options.client_cert_file != None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This option is generally host-specific, and would require the Riemann servers to be configured very similarly (from a client ssl perspective) to work, because this is still a single option in the configuration. Perhaps I could help suggest some improvements here, but I don't think I fully understand the use case yet. Can you expand on your architecture and goal here? |
||
riemann.append(bernhard.SSLClient( | ||
host=h, | ||
port=options.riemann_port, | ||
keyfile=options.client_key_file, | ||
certfile=options.client_cert_file, | ||
ca_certs=options.ca_certs_file)) | ||
else: | ||
riemann.append(bernhard.Client( | ||
host=h, | ||
port=options.riemann_port, | ||
transport=bernhard.UDPTransport)) | ||
|
||
return riemann | ||
|
||
|
@@ -163,6 +170,11 @@ def main(): | |
if not options.foreground: | ||
log.info("Creating pidfile with PID: %s" % (pidfile(create=True))) | ||
|
||
if options.suspend: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you share some context about the problem this is trying to solve? I don't necessarily object to this change, but I don't yet understand the use case. For example, in the default configuration of sumd, and our Riemann config, the TTLs are set such that a delay here could cause you to fall 'outside' that TTLs and the event to expire. I also believe (but would have to doublecheck) that events are scheduled for now+interval on startup, so that does provide some natural delay already. |
||
log.info("Suspend tasks for {}s".format(options.suspend)) | ||
time.sleep(float(options.suspend)) | ||
log.info("Continue to start.") | ||
|
||
# Create scheduler | ||
schedule = scheduler.TaskSchedule() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'host' option here is for setting the host field of the event (ie, source), not the destination Riemann server.