good for merge regards -steve
On Tue, 2010-05-04 at 07:49 +1000, Angus Salkeld wrote: > (with makefile changes too) > > trigger the dumping of flight data using: > corosync-objctl -w runtime.blackbox.dump_flight_data=anything > trigger the dumping of state using: > corosync-objctl -w runtime.blackbox.dump_state=anything > > then read the flight data as usual: > corosync-fplay > > This patch includes a wrapper script called: > corosync-blackbox > > Signed-off-by: Angus Salkeld <[email protected]> > --- > exec/main.c | 57 +++++++++++++++++++++++++++++++++++++++++++--- > tools/Makefile.am | 4 +++ > tools/corosync-blackbox | 35 ++++++++++++++++++++++++++++ > 3 files changed, 92 insertions(+), 4 deletions(-) > create mode 100755 tools/corosync-blackbox > > diff --git a/exec/main.c b/exec/main.c > index c8fda30..1ba994d 100644 > --- a/exec/main.c > +++ b/exec/main.c > @@ -187,11 +187,8 @@ static void *corosync_exit_thread_handler (void *arg) > > static void sigusr2_handler (int num) > { > - /* > - * TODO remove this from sigusr2 handler and access via cfg service > - * engine api - corosync-cfgtool > - */ > corosync_state_dump (); > + logsys_log_rec_store (LOCALSTATEDIR "/lib/corosync/fdata"); > } > > static void sigterm_handler (int num) > @@ -1254,6 +1251,57 @@ static void corosync_setscheduler (void) > #endif > } > > +static void fplay_key_change_notify_fn ( > + object_change_type_t change_type, > + hdb_handle_t parent_object_handle, > + hdb_handle_t object_handle, > + const void *object_name_pt, size_t object_name_len, > + const void *key_name_pt, size_t key_len, > + const void *key_value_pt, size_t key_value_len, > + void *priv_data_pt) > +{ > + if (key_len == strlen ("dump_flight_data") && > + memcmp ("dump_flight_data", key_name_pt, key_len) == 0) { > + logsys_log_rec_store (LOCALSTATEDIR "/lib/corosync/fdata"); > + } > + if (key_len == strlen ("dump_state") && > + memcmp ("dump_state", key_name_pt, key_len) == 0) { > + corosync_state_dump (); > + } > +} > + > +static void corosync_fplay_control_init (void) > +{ > + hdb_handle_t object_find_handle; > + hdb_handle_t object_runtime_handle; > + hdb_handle_t object_blackbox_handle; > + > + objdb->object_find_create (OBJECT_PARENT_HANDLE, > + "runtime", strlen ("runtime"), > + &object_find_handle); > + > + if (objdb->object_find_next (object_find_handle, > + &object_runtime_handle) != 0) { > + return; > + } > + > + objdb->object_create (object_runtime_handle, > + &object_blackbox_handle, > + "blackbox", strlen ("blackbox")); > + > + objdb->object_key_create_typed (object_blackbox_handle, > + "dump_flight_data", "no", strlen("no"), > + OBJDB_VALUETYPE_STRING); > + objdb->object_key_create_typed (object_blackbox_handle, > + "dump_state", "no", strlen("no"), > + OBJDB_VALUETYPE_STRING); > + > + objdb->object_track_start (object_blackbox_handle, > + OBJECT_TRACK_DEPTH_RECURSIVE, > + fplay_key_change_notify_fn, > + NULL, NULL, NULL, NULL); > +} > + > static void corosync_stats_init (void) > { > hdb_handle_t object_find_handle; > @@ -1297,6 +1345,7 @@ static void main_service_ready (void) > evil_init (api); > corosync_stats_init (); > corosync_totem_stats_init (); > + corosync_fplay_control_init (); > if (minimum_sync_mode == CS_SYNC_V2) { > log_printf (LOGSYS_LEVEL_NOTICE, "Compatibility mode set to > none. Using V2 of the synchronization engine.\n"); > sync_v2_init ( > diff --git a/tools/Makefile.am b/tools/Makefile.am > index 1118345..3a52f4a 100644 > --- a/tools/Makefile.am > +++ b/tools/Makefile.am > @@ -36,6 +36,10 @@ sbin_PROGRAMS = corosync-fplay > corosync-cfgtool \ > corosync-keygen corosync-objctl \ > corosync-pload corosync-cpgtool corosync-quorumtool > > +bin_SCRIPTS = corosync-blackbox > + > +EXTRA_DIST = $(bin_SCRIPTS) > + > corosync_pload_LDADD = -lpload -lcoroipcc > corosync_pload_LDFLAGS = -L../lib > corosync_objctl_LDADD = -lconfdb ../lcr/liblcr.a -lcoroipcc > diff --git a/tools/corosync-blackbox b/tools/corosync-blackbox > new file mode 100755 > index 0000000..b1c27ec > --- /dev/null > +++ b/tools/corosync-blackbox > @@ -0,0 +1,35 @@ > +#!/bin/sh > +# Copyright (c) 2010 Red Hat, Inc. > +# > +# Authors: Angus Salkeld <[email protected] > +# > +# This software licensed under BSD license, the text of which follows: > +# > +# Redistribution and use in source and binary forms, with or without > +# modification, are permitted provided that the following conditions are met: > +# > +# - Redistributions of source code must retain the above copyright notice, > +# this list of conditions and the following disclaimer. > +# - Redistributions in binary form must reproduce the above copyright notice, > +# this list of conditions and the following disclaimer in the documentation > +# and/or other materials provided with the distribution. > +# - Neither the name of the MontaVista Software, Inc. nor the names of its > +# contributors may be used to endorse or promote products derived from this > +# software without specific prior written permission. > +# > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" > +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE > +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS > +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) > +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF > +# THE POSSIBILITY OF SUCH DAMAGE. > + > +corosync-objctl -w runtime.blackbox.dump_state=$(date +%s) > +corosync-objctl -w runtime.blackbox.dump_flight_data=$(date +%s) > +corosync-fplay > + _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
