Re: Link status in multi-homed setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
Here is a quick patch extending corosync-cfgtool -s allowing
 Detection of faults on a single interface
 Exit return code
 
I hope you'll find it useful
Also, supporting <interface name> and <ring id> would be nice (currently, it uses corosync-cfgtool -i <interface static ip> -s, as in normal -s)
 
Best,
Oren
 
> Date: Thu, 19 Jan 2012 12:51:11 -0700
> From: sdake@xxxxxxxxxx
> To: theoren28@xxxxxxxxxxx
> CC: discuss@xxxxxxxxxxxx
> Subject: Re: Link status in multi-homed setup
>
> On 01/19/2012 09:45 AM, Oren Nechushtan wrote:
> > Hi,
> > I have a corosync API question, more techniquely: cman+pacemaker+corosync.
> >
> > Is there an analogue command to heartbeat cl_status command?
> > This command was used for testing if a specific interface is working
> > properly or not.
> > The use case is to detect if one of the interfaces used by corosync
> > (multi-homed configuration) is not working properly
> > - display warning
> > - trigger a pacemaker resource exception handling: resource changes
> > interface if another interface is working fine
> >
> > There are many ways to test this externally, but I currently failed to
> > find a specific corosync command for doing this.
> > This should catch:
> > - ifconfig down on either nodes
> > - Link down on either nodes
> >
> > The configuration is
> > Two nodes
> > Two sync interfaces
> > Cross cables
> >
>
> There is a very poorly designed API called
>
> cs_error_t
> corosync_cfg_ring_status_get (
> corosync_cfg_handle_t cfg_handle,
> char ***interface_names,
> char ***status,
> unsigned int *interface_count)
>
> You can see how to use this in
> tools/corosync-cfgtool.c:79 (in master)
>
> Regards
> -steve
>
>
> > Just for the record I am familiar with heartbeat and started using
> > corosync several month ago.
> >
> > Versions:
> > Linux 1 2.6.32-220.2.1.el6.i686 #1 SMP Thu Dec 22 18:50:52 GMT 2011 i686
> > i686 i386 GNU/Linux
> >
> > corosync-1.4.1-4.el6.i686
> > corosynclib-1.4.1-4.el6.i686
> > pacemaker-1.1.6-3.el6.i686
> > pacemaker-libs-1.1.6-3.el6.i686
> > pacemaker-cluster-libs-1.1.6-3.el6.i686
> > pacemaker-cli-1.1.6-3.el6.i686
> > cman-3.0.12.1-23.el6.i686
> >
> > Thanks in advance,
> > Oren
> >
> >
> > _______________________________________________
> > discuss mailing list
> > discuss@xxxxxxxxxxxx
> > http://lists.corosync.org/mailman/listinfo/discuss
>

--- corosync-1.4.1/tools/corosync-cfgtool.c.orig	2012-01-24 15:53:07.206763691 +0200
+++ corosync-1.4.1/tools/corosync-cfgtool.c	2012-01-24 15:52:25.069596909 +0200
@@ -51,7 +51,7 @@
 #include <corosync/totem/totem.h>
 #include <corosync/cfg.h>
 
-static void ringstatusget_do (void)
+static int ringstatusget_do (char* interface_name)
 {
 	cs_error_t result;
 	corosync_cfg_handle_t handle;
@@ -60,6 +60,7 @@
 	char **interface_status;
 	unsigned int i;
 	unsigned int nodeid;
+	int rc=0;
 
 	printf ("Printing ring status.\n");
 	result = corosync_cfg_initialize (&handle, NULL);
@@ -84,12 +85,19 @@
 		printf ("Could not get the ring status, the error is: %d\n", result);
 	} else {
 		for (i = 0; i < interface_count; i++) {
-			printf ("RING ID %d\n", i);
-			printf ("\tid\t= %s\n", interface_names[i]);
-			printf ("\tstatus\t= %s\n", interface_status[i]);
+			if ( (interface_name && 
+			     	(interface_name[0]=='\0' || 
+				strcasecmp(interface_name,interface_names[i])==0)) ||
+			     !interface_name ) {
+				printf ("RING ID %d\n", i);
+				printf ("\tid\t= %s\n", interface_names[i]);
+				printf ("\tstatus\t= %s\n", interface_status[i]);
+				if (strstr(interface_status[i], "FAULTY")) rc=1;
+			}
 		}
 	}
 	(void)corosync_cfg_finalize (handle);
+	return rc;
 }
 
 static void ringreenable_do (void)
@@ -254,7 +262,7 @@
 
 static void usage_do (void)
 {
-	printf ("corosync-cfgtool [-s] [-r] [-l] [-u] [-H] [service_name] [-v] [version] [-k] [nodeid] [-a] [nodeid]\n\n");
+	printf ("corosync-cfgtool [[-i <interface ip>] -s] [-r] [-l] [-u] [-H] [service_name] [-v] [version] [-k] [nodeid] [-a] [nodeid]\n\n");
 	printf ("A tool for displaying and configuring active parameters within corosync.\n");
 	printf ("options:\n");
 	printf ("\t-s\tDisplays the status of the current rings on this node.\n");
@@ -280,21 +288,26 @@
 }
 
 int main (int argc, char *argv[]) {
-	const char *options = "srl:u:v:k:a:c:hH";
+	const char *options = "i:srl:u:v:k:a:c:hH";
 	int opt;
 	int service_load = 0;
 	unsigned int nodeid;
 	int service_unload = 0;
 	char *service = NULL;
 	unsigned int version = 0;
+	char interface_name[128] = "";
+	int rc=0;
 
 	if (argc == 1) {
 		usage_do ();
 	}
 	while ( (opt = getopt(argc, argv, options)) != -1 ) {
 		switch (opt) {
+		case 'i':
+			strncpy(interface_name, optarg, sizeof(interface_name));
+			break;
 		case 's':
-			ringstatusget_do ();
+			rc = ringstatusget_do (interface_name);
 			break;
 		case 'r':
 			ringreenable_do ();
@@ -336,5 +349,5 @@
 		service_unload_do (service, version);
 	}
 
-	return (0);
+	return (rc);
 }
_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss

[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux