Skip to content

Commit

Permalink
make alert timeout configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
satterly committed Jul 8, 2013
1 parent 3957253 commit a0313be
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
3 changes: 2 additions & 1 deletion alerta/common/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@


class Alert(object):

def __init__(self, resource, event, correlate=None, group='Misc', value=None, status=status_code.UNKNOWN,
severity=severity_code.NORMAL, previous_severity=severity_code.UNKNOWN, environment=None, service=None,
text=None, event_type='exceptionAlert', tags=None, origin=None, repeat=False, duplicate_count=0,
Expand Down Expand Up @@ -90,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 86400 # FIXME(nsatterl) - should be CONF.alert_timeout
self.timeout = timeout or CONF.timeout
self.alertid = alertid or str(uuid4())
if last_receive_id:
self.last_receive_id = last_receive_id
Expand Down
10 changes: 5 additions & 5 deletions alerta/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def parse_args(argv, prog=None, version='unknown', cli_parser=None, daemon=True)
prog = os.path.basename(sys.argv[0])

OPTION_DEFAULTS = {
'config': '/etc/alerta/alerta.conf',
'conf_file': '/etc/alerta/alerta.conf',
'version': 'unknown',
'debug': False,
'verbose': False,
Expand Down 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,
'alert_timeout': 86400, # seconds
'timeout': 86400, # seconds
'parser_dir': '/etc/alerta/parsers',
'loop_every': 30, # seconds

Expand Down Expand Up @@ -108,7 +108,7 @@ def parse_args(argv, prog=None, version='unknown', cli_parser=None, daemon=True)
'pagerduty_endpoint': 'https://events.pagerduty.com/generic/2010-04-15/create_event.json',
'pagerduty_api_key': '',

'dynect_customer': 'theguardian',
'dynect_customer': '',
'dynect_username': '',
'dynect_password': '',

Expand Down Expand Up @@ -136,9 +136,9 @@ def parse_args(argv, prog=None, version='unknown', cli_parser=None, daemon=True)
)
cfg_parser.add_argument(
'-c', '--conf-file',
help="Specify config file (default: %s)" % OPTION_DEFAULTS['config'],
help="Specify config file (default: %s)" % OPTION_DEFAULTS['conf_file'],
metavar="FILE",
default=OPTION_DEFAULTS['config']
default=OPTION_DEFAULTS['conf_file']
)
args, argv_left = cfg_parser.parse_known_args(argv)

Expand Down
1 change: 0 additions & 1 deletion bin/alert-checker
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def main(argv):
'-o',
'--timeout',
type=int,
default=86400,
help='Timeout in seconds that OPEN alert will persist in webapp.'
)
parser.add_argument(
Expand Down
3 changes: 0 additions & 3 deletions bin/alert-sender
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ from alerta.sender.client import SenderClient, Version
LOG = logging.getLogger('alerta.sender')
CONF = config.CONF

_DEFAULT_TIMEOUT = 86400 # TODO(nsatterl): should be CONF.alert_timeout


def main(argv):
try:
Expand Down Expand Up @@ -117,7 +115,6 @@ def main(argv):
'-o',
'--timeout',
type=int,
default=_DEFAULT_TIMEOUT,
help='Timeout in seconds that OPEN alert will persist in webapp.'
)
parser.add_argument(
Expand Down
12 changes: 4 additions & 8 deletions bin/alert-snmptrap
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
########################################

"""
Usage:
Usage: /etc/snmp/snmptrapd.conf
/etc/snmp/snmptrapd.conf
authCommunity log,execute,net public
format execute $a %a\n$A %A\n$s %s\n$b %b\n$B %B\n$x %#y-%#02m-%#02l\n$X %#02.2h:%#02.2j:%#02.2k\n$N %N\n$q %q\n$P %P\n$t %t\n$T %T\n$w %w\n$W %W\n%V~\%~%v\n
traphandle default alert-snmptrap --debug
authCommunity log,execute,net public
format execute $a %a\n$A %A\n$s %s\n$b %b\n$B %B\n$x %#y-%#02m-%#02l\n$X %#02.2h:%#02.2j:%#02.2k\n$N %N\n$q %q\n$P %P\n$t %t\n$T %T\n$w %w\n$W %W\n%V~\%~%v\n
traphandle default alert-snmptrap --debug
"""

import os
Expand All @@ -28,8 +26,6 @@ from alerta.common import config
from alerta.common import log as logging
from alerta.snmptrap.handler import SnmpTrapHandler, Version

DEFAULT_TIMEOUT = 86400

LOG = logging.getLogger('alerta.snmptrap')
CONF = config.CONF

Expand Down

0 comments on commit a0313be

Please sign in to comment.