فهرست منبع

diags: add a mechanism to trigger the writing the flight data

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

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2799 fd59a12c-fef9-0310-b244-a6a79926bd2f
Angus Salkeld 16 سال پیش
والد
کامیت
bffca3a9ab
3فایلهای تغییر یافته به همراه92 افزوده شده و 4 حذف شده
  1. 53 4
      exec/main.c
  2. 4 0
      tools/Makefile.am
  3. 35 0
      tools/corosync-blackbox

+ 53 - 4
exec/main.c

@@ -206,11 +206,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)
@@ -1269,6 +1266,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;
@@ -1323,6 +1371,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 (

+ 4 - 0
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

+ 35 - 0
tools/corosync-blackbox

@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright (c) 2010 Red Hat, Inc.
+#
+# Authors: Angus Salkeld <asalkeld@redhat.com
+#
+# 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
+