Skip to content

Commit

Permalink
use global_timeout value if timeout undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
satterly committed Jul 9, 2013
1 parent 30b3f5c commit faad5b4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
3 changes: 2 additions & 1 deletion alerta/checker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
from alerta.common import severity_code
from alerta.common.api import ApiClient

Version = '2.0.1'
Version = '2.0.2'

LOG = logging.getLogger(__name__)
CONF = config.CONF


class CheckerClient(object):

def main(self):

if CONF.heartbeat:
Expand Down
2 changes: 1 addition & 1 deletion alerta/common/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, resource, event, correlate=None, group='Misc', value=None, st
self.threshold_info = threshold_info
self.summary = summary or '%s - %s %s is %s on %s %s' % (
','.join(self.environment), self.severity.capitalize(), self.event, self.value, ','.join(self.service), self.resource)
self.timeout = timeout or CONF.timeout
self.timeout = timeout or CONF.global_timeout
self.alertid = alertid or str(uuid4())
if last_receive_id:
self.last_receive_id = last_receive_id
Expand Down
2 changes: 1 addition & 1 deletion alerta/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def parse_args(argv, prog=None, version='unknown', cli_parser=None, daemon=True)
'user_id': 'alerta',
'server_threads': 4,
'disable_flag': '/var/run/alerta/%s.disable' % prog,
'timeout': 86400, # seconds
'global_timeout': 86400, # seconds
'parser_dir': '/etc/alerta/parsers',
'loop_every': 30, # seconds

Expand Down
15 changes: 7 additions & 8 deletions alerta/sender/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from alerta.common.heartbeat import Heartbeat
from alerta.common.api import ApiClient

Version = '2.0.3'
Version = '2.0.4'

LOG = logging.getLogger(__name__)
CONF = config.CONF
Expand All @@ -25,15 +25,14 @@ def main(self):

heartbeat = Heartbeat(
origin=CONF.origin,
version=vtag or Version
version=vtag or Version,
timeout=CONF.timeout
)
if CONF.dry_run:
print heartbeat
else:
LOG.debug(repr(heartbeat))

api = ApiClient()
api.send(heartbeat)
LOG.debug(repr(heartbeat))

api = ApiClient()
api.send(heartbeat, dry_run=CONF.dry_run)

return heartbeat.get_id()

Expand Down
9 changes: 2 additions & 7 deletions bin/alert-checker
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,8 @@ def main(argv):
if not CONF.event:
parser.error("Must supply event name using -e or --event")

if not CONF.environment:
parser.error("Must supply one or more environments using -E or --environment")
else:
CONF.environment = [x.upper() for x in CONF.environment]

if not CONF.service:
parser.error("Must supply one or more service using -S or --service")
if not CONF.timeout:
CONF.timeout = CONF.global_timeout

checker = CheckerClient()
msg_id = checker.main()
Expand Down
4 changes: 4 additions & 0 deletions bin/alert-sender
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CONF = config.CONF


def main(argv):

try:
parser = argparse.ArgumentParser(
add_help=False,
Expand Down Expand Up @@ -166,6 +167,9 @@ def main(argv):
if CONF.correlate and CONF.event not in CONF.correlate:
CONF.correlate.append(CONF.event)

if not CONF.timeout:
CONF.timeout = CONF.global_timeout

sender = SenderClient()
msg_id = sender.main()

Expand Down

0 comments on commit faad5b4

Please sign in to comment.