← Back to team overview

nagios-charmers team mailing list archive

[Merge] ~afreiberger/nagios-charm:check_timeout into nagios-charm:master

 

Drew Freiberger has proposed merging ~afreiberger/nagios-charm:check_timeout into nagios-charm:master.

Requested reviews:
  Nagios Charm developers (nagios-charmers)

For more details, see:
https://code.launchpad.net/~afreiberger/nagios-charm/+git/nagios-charm/+merge/353461
-- 
Your team Nagios Charm developers is requested to review the proposed merge of ~afreiberger/nagios-charm:check_timeout into nagios-charm:master.
diff --git a/config.yaml b/config.yaml
index eca8add..1a8d74c 100644
--- a/config.yaml
+++ b/config.yaml
@@ -177,3 +177,10 @@ options:
             A string to use for the service_notification_options in the
             pagerduty contact configuration.  Remove w to avoid paging for
             warning events.
+    check_timeout:
+        default: 10
+        type: int
+        Description: |
+            A number of seconds before nrpe checks timeout from not being able
+            to connect to the client or finish execution of the command.
+            Raise this value to combat 'CHECK_NRPE Socket timeout alerts'
diff --git a/hooks/common.py b/hooks/common.py
index 620c22e..65718f4 100644
--- a/hooks/common.py
+++ b/hooks/common.py
@@ -12,6 +12,7 @@ from charmhelpers.core.hookenv import (
     network_get,
     network_get_primary_address,
     unit_get,
+    config,
 )
 
 from pynag import Model
@@ -176,6 +177,9 @@ def customize_http(service, name, extra):
         cmd_args.extend(('-I', '$HOSTADDRESS$'))
     else:
         cmd_args.extend(('-H', '$HOSTADDRESS$'))
+    check_timeout = config('check_timeout')
+    if check_timeout is not None:
+        cmd_args.extend(('-t', check_timeout))
     check_command = _make_check_command(cmd_args)
     cmd = '%s!%s' % (check_command, '!'.join([str(x) for x in args]))
     service.set_attribute('check_command', cmd)
@@ -190,6 +194,9 @@ def customize_mysql(service, name, extra):
         _extend_args(args, cmd_args, '-u', extra['user'])
     if 'password' in extra:
         _extend_args(args, cmd_args, '-p', extra['password'])
+    check_timeout = config('check_timeout')
+    if check_timeout is not None:
+        cmd_args.extend(('-t', check_timeout))
     check_command = _make_check_command(cmd_args)
     cmd = '%s!%s' % (check_command, '!'.join([str(x) for x in args]))
     service.set_attribute('check_command', cmd)
@@ -200,6 +207,9 @@ def customize_pgsql(service, name, extra):
     plugin = os.path.join(PLUGIN_PATH, 'check_pgsql')
     args = []
     cmd_args = [plugin, '-H', '$HOSTADDRESS$']
+    check_timeout = config('check_timeout')
+    if check_timeout is not None:
+        cmd_args.extend(('-t', check_timeout))
     check_command = _make_check_command(cmd_args)
     cmd = '%s!%s' % (check_command, '!'.join([str(x) for x in args]))
     service.set_attribute('check_command', cmd)
@@ -216,6 +226,9 @@ def customize_nrpe(service, name, extra):
         cmd_args.extend(('-c', extra['command']))
     else:
         cmd_args.extend(('-c', extra))
+    check_timeout = config('check_timeout')
+    if check_timeout is not None:
+        cmd_args.extend(('-t', check_timeout))
     check_command = _make_check_command(cmd_args)
     cmd = '%s!%s' % (check_command, '!'.join([str(x) for x in args]))
     service.set_attribute('check_command', cmd)
@@ -256,6 +269,9 @@ def customize_tcp(service, name, extra):
       cmd_args.extend(('-c', extra['critical']))
     if 'timeout' in extra:
       cmd_args.extend(('-t', extra['timeout']))
+    check_timeout = config('check_timeout')
+    if check_timeout is not None:
+        cmd_args.extend(('-t', check_timeout))
 
     check_command = _make_check_command(cmd_args)
     cmd = '%s!%s' % (check_command, '!'.join([str(x) for x in args]))

Follow ups