ctdb-daemon: Provide a default location for the notification script
authorMartin Schwenke <martin@meltin.net>
Thu, 29 Mar 2018 03:58:49 +0000 (14:58 +1100)
committerMartin Schwenke <martins@samba.org>
Tue, 1 May 2018 11:31:18 +0000 (13:31 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/notify.d.README
ctdb/config/notify.sh
ctdb/doc/ctdb.7.xml
ctdb/doc/ctdbd.1.xml
ctdb/doc/ctdbd.conf.5.xml
ctdb/server/ctdbd.c

index ffce7fab2fb0faf51b74c7935e9d90d3f3d1fb39..de56417159f0b6493ef860144179a9f766df64bb 100755 (executable)
@@ -4,12 +4,6 @@ the event, which is one of:
 
   init, setup, startup, unhealthy, healthy
 
-To use notifications with this directory then you need to set:
-
-  CTDB_NOTIFY_SCRIPT=/etc/ctdb/notify.sh
-
-in your CTDB configuration file.
-
 An example script that sends SNMP traps for unhealthy/healthy might
 look like this:
 
index d98f04660a147b8e9e6de7562fc6dfe20e7150f7..9f947c771fc5657dd237677c4ceabf32829d6602 100755 (executable)
@@ -1,8 +1,5 @@
 #!/bin/sh
 
-# This script is activated by setting CTDB_NOTIFY_SCRIPT=/etc/ctdb/notify.sh
-# in /etc/sysconfig/ctdb
-
 # This is script is invoked from ctdb when certain events happen.  See
 # /etc/ctdb/notify.d/README for more details.
 
index 079b34d8a085744e7f404891545c415cb016b3f4..876d8df3be7a235cd2064e8c2c5d7b05fe32c71d 100644 (file)
@@ -958,24 +958,28 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1
   </refsect1>
 
   <refsect1>
-    <title>NOTIFICATION SCRIPT</title>
+    <title>NOTIFICATIONS</title>
 
     <para>
       When certain state changes occur in CTDB, it can be configured
-      to perform arbitrary actions via a notification script.  For
-      example, sending SNMP traps or emails when a node becomes
-      unhealthy or similar.
+      to perform arbitrary actions via notifications.  For example,
+      sending SNMP traps or emails when a node becomes unhealthy or
+      similar.
     </para>
+
     <para>
-      This is activated by setting the
-      <varname>CTDB_NOTIFY_SCRIPT</varname> configuration variable.
-      The specified script must be executable.  
+      The default notification script is
+      <filename>/usr/local/etc/ctdb/notify.sh</filename>.  It executes
+      files in <filename>/usr/local/etc/ctdb/notify.d/</filename>,
+      which must be executable.
     </para>
+
     <para>
-      Use of the provided <filename>/usr/local/etc/ctdb/notify.sh</filename>
-      script is recommended.  It executes files in
-      <filename>/usr/local/etc/ctdb/notify.d/</filename>.
+      This notification script can be changed via the
+      <varname>CTDB_NOTIFY_SCRIPT</varname> configuration variable.
+      The specified script must be executable.
     </para>
+
     <para>
       CTDB currently generates notifications after CTDB changes to
       these states:
index 6d20f595e6ed7bd78455a8b57af2e4066da744c0..05379cfec2a15d42353cc6460b2353ab96f48814 100644 (file)
            certain state changes occur.
          </para>
          <para>
-           This file is usually
+           The default is
            <filename>/usr/local/etc/ctdb/notify.sh</filename>.
          </para>
          <para>
-           Please see the <citetitle>NOTIFICATION SCRIPT</citetitle>
+           Please see the <citetitle>NOTIFICATIONS</citetitle>
            section in <citerefentry><refentrytitle>ctdb</refentrytitle>
            <manvolnum>7</manvolnum></citerefentry> for more
            information.
index 8aa132ba9ee9e008284b170a140702e64aef1271..f36495e34c230df573476e65b4f0a2f87e7cb385 100644 (file)
        <term>CTDB_NOTIFY_SCRIPT=<parameter>FILENAME</parameter></term>
        <listitem>
          <para>
-           No default, usually
+           Default is
            <filename>/usr/local/etc/ctdb/notify.sh</filename>.  Corresponds to
            <option>--notification-script</option>.
          </para>
index 4a3c5f65b305d66e1ca0e0f444f35e8c00ec507a..ff89a73c812a5673dea8ca9adc867d02aa1b9513 100644 (file)
@@ -315,10 +315,14 @@ int main(int argc, const char *argv[])
        if (options.notification_script != NULL) {
                ctdb->notification_script = talloc_strdup(
                                ctdb, options.notification_script);
-               if (ctdb->notification_script == NULL) {
-                       D_ERR("Unable to set notification script\n");
-                       exit(1);
-               }
+       } else {
+               ctdb->notification_script = talloc_asprintf(ctdb,
+                                                           "%s/notify.sh",
+                                                           ctdb_base);
+       }
+       if (ctdb->notification_script == NULL) {
+               D_ERR("Unable to set notification script\n");
+               exit(1);
        }
 
        ctdb->valgrinding = (options.valgrinding == 1);