</refsect3>
</refsect2>
+ <refsect2>
+ <title>event run|status|script list|script enable|script disable</title>
+ <para>
+ This command is used to control event daemon and to inspect
+ status of various events.
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term>run <parameter>EVENT</parameter> <parameter>TIMEOUT</parameter> <optional><parameter>ARGUMENTS</parameter></optional> </term>
+ <listitem>
+ <para>
+ This command can be used to manually run specified EVENT
+ with optional ARGUMENTS. The event will be allowed to run
+ a maximum of TIMEOUT seconds. If TIMEOUT is 0, then there
+ is no time limit for running the event.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>status <optional><parameter>EVENT</parameter></optional> <optional>lastrun|lastpass|lastfail</optional></term>
+ <listitem>
+ <para>
+ This command displays the last execution status of the
+ specified EVENT. If no event is specified, then the status
+ of last executed monitor event will be displayed.
+ </para>
+ <para>
+ To see the last successful execution of the event, lastpass
+ can be specified. Similarly lastfail can be specified
+ to see the last unsuccessful execution of the event.
+ The optional lastrun can be specified to query the last
+ execution of the event.
+ </para>
+ <para>
+ The command will terminate with the exit status
+ corresponding to the overall status of event that is
+ displayed. If lastpass is specified, then the command will
+ always terminate with 0. If lastfail is specified then the
+ command will always terminate with non-zero exit status.
+ If lastrun is specified, then the command will terminate
+ with 0 or not depending on if the last execution of the
+ event was successful or not.
+ </para>
+ <para>
+ The output is the list of event scripts executed.
+ Each line shows the name, status, duration and start time
+ for each script.
+ </para>
+ <para>
+ Example output:
+ </para>
+ <screen>
+00.ctdb OK 0.014 Sat Dec 17 19:39:11 2016
+01.reclock OK 0.013 Sat Dec 17 19:39:11 2016
+05.system OK 0.029 Sat Dec 17 19:39:11 2016
+06.nfs OK 0.014 Sat Dec 17 19:39:11 2016
+10.external DISABLED
+10.interface OK 0.037 Sat Dec 17 19:39:11 2016
+11.natgw OK 0.011 Sat Dec 17 19:39:11 2016
+11.routing OK 0.007 Sat Dec 17 19:39:11 2016
+13.per_ip_routing OK 0.007 Sat Dec 17 19:39:11 2016
+20.multipathd OK 0.007 Sat Dec 17 19:39:11 2016
+31.clamd OK 0.007 Sat Dec 17 19:39:11 2016
+40.vsftpd OK 0.013 Sat Dec 17 19:39:11 2016
+41.httpd OK 0.018 Sat Dec 17 19:39:11 2016
+49.winbind OK 0.023 Sat Dec 17 19:39:11 2016
+50.samba OK 0.100 Sat Dec 17 19:39:12 2016
+60.nfs OK 0.376 Sat Dec 17 19:39:12 2016
+70.iscsi OK 0.009 Sat Dec 17 19:39:12 2016
+91.lvs OK 0.007 Sat Dec 17 19:39:12 2016
+99.timeout OK 0.007 Sat Dec 17 19:39:12 2016
+ </screen>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>script list</term>
+ <listitem>
+ <para>
+ List the available event scripts.
+ </para>
+ <para>
+ Example output:
+ </para>
+ <screen>
+00.ctdb
+01.reclock
+05.system
+06.nfs
+10.external DISABLED
+10.interface
+11.natgw
+11.routing
+13.per_ip_routing
+20.multipathd
+31.clamd
+40.vsftpd
+41.httpd
+49.winbind
+50.samba
+60.nfs
+70.iscsi
+91.lvs
+99.timeout
+ </screen>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>script enable <parameter>SCRIPT</parameter></term>
+ <listitem>
+ <para>
+ Enable the specified event SCRIPT. Only enabled scripts will be
+ executed when running any event.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>script disable <parameter>SCRIPT</parameter></term>
+ <listitem>
+ <para>
+ Disable the specified event SCRIPT. This will prevent the script
+ from executing when running any event.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect2>
+
<refsect2>
<title>scriptstatus</title>
<para>
#include "system/filesys.h"
#include "system/time.h"
#include "system/wait.h"
+#include "system/dir.h"
#include <ctype.h>
#include <popt.h>
}
}
+static int control_event(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
+ int argc, const char **argv)
+{
+ char *t, *event_helper = NULL;
+ char *eventd_socket = NULL;
+ const char **new_argv;
+ int i;
+
+ t = getenv("CTDB_EVENT_HELPER");
+ if (t != NULL) {
+ event_helper = talloc_strdup(mem_ctx, t);
+ } else {
+ event_helper = talloc_asprintf(mem_ctx, "%s/ctdb_event",
+ CTDB_HELPER_BINDIR);
+ }
+
+ if (event_helper == NULL) {
+ fprintf(stderr, "Unable to set event daemon helper\n");
+ return 1;
+ }
+
+ t = getenv("CTDB_SOCKET");
+ if (t != NULL) {
+ eventd_socket = talloc_asprintf(mem_ctx, "%s/eventd.sock",
+ dirname(t));
+ } else {
+ eventd_socket = talloc_asprintf(mem_ctx, "%s/eventd.sock",
+ CTDB_RUNDIR);
+ }
+
+ if (eventd_socket == NULL) {
+ fprintf(stderr, "Unable to set event daemon socket\n");
+ return 1;
+ }
+
+ new_argv = talloc_array(mem_ctx, const char *, argc + 1);
+ if (new_argv == NULL) {
+ fprintf(stderr, "Memory allocation error\n");
+ return 1;
+ }
+
+ new_argv[0] = eventd_socket;
+ for (i=0; i<argc; i++) {
+ new_argv[i+1] = argv[i];
+ }
+
+ return run_helper(mem_ctx, "event daemon helper", event_helper,
+ argc+1, new_argv);
+}
+
static int control_scriptstatus(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
int argc, const char **argv)
{
"wipe the contents of a database.", "<dbname|dbid>"},
{ "recmaster", control_recmaster, false, true,
"show the pnn for the recovery master", NULL },
+ { "event", control_event, true, false,
+ "event and event script commands", NULL },
{ "scriptstatus", control_scriptstatus, false, true,
"show event script status",
"[init|setup|startup|monitor|takeip|releaseip|ipreallocated]" },