From: Martin Schwenke Date: Thu, 29 Mar 2018 03:58:49 +0000 (+1100) Subject: ctdb-daemon: Provide a default location for the notification script X-Git-Tag: ldb-1.4.0~492 X-Git-Url: http://git.samba.org/samba.git/?a=commitdiff_plain;h=ed80fc13444b317a8e783d82cf49e03e680ec1e8;p=gd%2Fsamba-autobuild%2F.git ctdb-daemon: Provide a default location for the notification script Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/notify.d.README b/ctdb/config/notify.d.README index ffce7fab2fb..de56417159f 100755 --- a/ctdb/config/notify.d.README +++ b/ctdb/config/notify.d.README @@ -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: diff --git a/ctdb/config/notify.sh b/ctdb/config/notify.sh index d98f04660a1..9f947c771fc 100755 --- a/ctdb/config/notify.sh +++ b/ctdb/config/notify.sh @@ -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. diff --git a/ctdb/doc/ctdb.7.xml b/ctdb/doc/ctdb.7.xml index 079b34d8a08..876d8df3be7 100644 --- a/ctdb/doc/ctdb.7.xml +++ b/ctdb/doc/ctdb.7.xml @@ -958,24 +958,28 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1 - NOTIFICATION SCRIPT + NOTIFICATIONS 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. + - This is activated by setting the - CTDB_NOTIFY_SCRIPT configuration variable. - The specified script must be executable. + The default notification script is + /usr/local/etc/ctdb/notify.sh. It executes + files in /usr/local/etc/ctdb/notify.d/, + which must be executable. + - Use of the provided /usr/local/etc/ctdb/notify.sh - script is recommended. It executes files in - /usr/local/etc/ctdb/notify.d/. + This notification script can be changed via the + CTDB_NOTIFY_SCRIPT configuration variable. + The specified script must be executable. + CTDB currently generates notifications after CTDB changes to these states: diff --git a/ctdb/doc/ctdbd.1.xml b/ctdb/doc/ctdbd.1.xml index 6d20f595e6e..05379cfec2a 100644 --- a/ctdb/doc/ctdbd.1.xml +++ b/ctdb/doc/ctdbd.1.xml @@ -308,11 +308,11 @@ certain state changes occur. - This file is usually + The default is /usr/local/etc/ctdb/notify.sh. - Please see the NOTIFICATION SCRIPT + Please see the NOTIFICATIONS section in ctdb 7 for more information. diff --git a/ctdb/doc/ctdbd.conf.5.xml b/ctdb/doc/ctdbd.conf.5.xml index 8aa132ba9ee..f36495e34c2 100644 --- a/ctdb/doc/ctdbd.conf.5.xml +++ b/ctdb/doc/ctdbd.conf.5.xml @@ -349,7 +349,7 @@ CTDB_NOTIFY_SCRIPT=FILENAME - No default, usually + Default is /usr/local/etc/ctdb/notify.sh. Corresponds to . diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 4a3c5f65b30..ff89a73c812 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -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);