Hi,
On Thu, 2009-07-16 at 20:28 +0900, Junko IKEDA wrote:
> Hi,
> 
> The new patch worked well!
> and the error message also disappeared.
> Thanks a lot!
> I will continue the test around snmp.
Okay. Attached the improved patch. If it's built only for openais
(configure --without-heartbeat-support), the uname and uuid information
will be got from openais rather than uname(2), which are precise.

-- 
Regards,
Yan Gao
China R&D Software Engineer
y...@novell.com

Novell, Inc.
Making IT Work As One?6?4
diff -r 56e1e8787452 snmp_subagent/Makefile.am
--- a/snmp_subagent/Makefile.am	Tue Jul 07 14:30:31 2009 +0800
+++ b/snmp_subagent/Makefile.am	Thu Jul 16 22:30:46 2009 +0800
@@ -69,7 +69,6 @@
 halibdir		= $(libdir)/@HB_PKG@
 
 # binary programs
-#if BUILD_HEARTBEAT_SUPPORT
 halib_PROGRAMS		= hbagent 
 
 hbagent_SOURCES		= $(hbagent_srces)
@@ -78,12 +77,14 @@
 			-lplumb -lcrmcommon -lcib -lpe_status \
 			$(CLUSTERLIBS) $(CURSESLIBS) $(GLIBLIB)
 
+if !BUILD_HEARTBEAT_SUPPORT
+hbagent_LDADD		+= -lcrmcluster
+endif
 hbagent_LDFLAGS		= @SNMPAGENTLIB@ 
 
 # test cases
 testdir			= $(HA_NOARCHDATAHBDIR)
 test_SCRIPTS		= $(test_scrs)
-#endif
 
 hadir                   = $(sysconfdir)/ha.d
 
diff -r 56e1e8787452 snmp_subagent/hbagent.c
--- a/snmp_subagent/hbagent.c	Tue Jul 07 14:30:31 2009 +0800
+++ b/snmp_subagent/hbagent.c	Thu Jul 16 22:30:46 2009 +0800
@@ -39,6 +39,8 @@
 #if SUPPORT_HEARTBEAT
 #include "hb_api.h"
 #include "heartbeat.h"
+#else
+#include <crm/common/cluster.h>
 #endif
 
 #include "clplumbing/cl_log.h"
@@ -77,6 +79,7 @@
 #include <sys/types.h> /* getpid() */
 #include <sys/stat.h> /* fstat() */
 #include <unistd.h>
+#include <sys/utsname.h>
 
 #include <errno.h>
 
@@ -85,11 +88,12 @@
 #endif
 #include "clplumbing/cl_uuid.h" /* UU_UNPARSE_SIZEOF */
 
+char * myid = NULL; /* my node id */
+char * myuuid = NULL; /* my node uuid */
+
 #if SUPPORT_HEARTBEAT
 static unsigned long hbInitialized = 0;
 static ll_cluster_t * hb = NULL; /* heartbeat handle */
-char * myid = NULL; /* my node id */
-char * myuuid = NULL; /* my node uuid */
 static SaClmHandleT clm = 0;
 static unsigned long clmInitialized = 0;
 
@@ -123,10 +127,11 @@
 int nodestatus_trap(const char * node, const char * status);
 int ifstatus_trap(const char * node, const char * lnk, const char * status);
 int membership_trap(const char * node, SaClmClusterChangesT status);
-int hbagent_trap(int online, const char * node);
 
 int ping_membership(int * mem_fd);
 #endif
+
+int hbagent_trap(int online, const char * node);
 
 /* LHAHeartbeatConfigInfo partial-mode */
 #define DEFAULT_REFRESH_TIMING  (0)
@@ -1214,60 +1219,6 @@
 }
 
 int 
-hbagent_trap(int online, const char * node)
-{
-    netsnmp_variable_list *notification_vars = NULL;
-
-    oid objid_snmptrap[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
-    size_t objid_snmptrap_len = OID_LENGTH(objid_snmptrap);
-
-    oid  nodename_oid[] = { 1, 3, 6, 1, 4, 1, 4682, 2, 1, 2 };
-    size_t nodename_oid_len = OID_LENGTH(nodename_oid);
-
-  /* this is the oid for the hbagent online trap */
-    oid  trap_oid[] = { 1, 3, 6, 1, 4, 1, 4682, 900, 7 };
-    size_t trap_oid_len = OID_LENGTH(trap_oid);
-
-    /* this is the oid for the offline trap */
-    if (!online) {
-	    trap_oid[trap_oid_len - 1] = 9;
-    }
-
-
-    snmp_varlist_add_variable(&notification_vars,
-                              /*
-                               * the snmpTrapOID.0 variable
-                               */
-                              objid_snmptrap, objid_snmptrap_len,
-                              /*
-                               * value type is an OID
-                               */
-                              ASN_OBJECT_ID,
-                              /*
-                               * value contents is our notification OID
-                               */
-                              (u_char *) trap_oid,
-                              /*
-                               * size in bytes = oid length * sizeof(oid)
-                               */
-                              trap_oid_len * sizeof(oid));
-
-    snmp_varlist_add_variable(&notification_vars,
-                              nodename_oid, 
-			      nodename_oid_len,
-                              ASN_OCTET_STR,
-                              (const u_char *) node,
-                              strlen(node)); /* do NOT use strlen() +1 */
-
-    cl_log(LOG_INFO, "sending hbagent trap. status:%d", online);
-    send_v2trap(notification_vars);
-    snmp_free_varbind(notification_vars);
-
-    return HA_OK;
-}
-
-
-int 
 membership_trap(const char * node, SaClmClusterChangesT status)
 {
     oid objid_snmptrap[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
@@ -1346,6 +1297,59 @@
   return 0;
 }
 #endif
+
+int 
+hbagent_trap(int online, const char * node)
+{
+    netsnmp_variable_list *notification_vars = NULL;
+
+    oid objid_snmptrap[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
+    size_t objid_snmptrap_len = OID_LENGTH(objid_snmptrap);
+
+    oid  nodename_oid[] = { 1, 3, 6, 1, 4, 1, 4682, 2, 1, 2 };
+    size_t nodename_oid_len = OID_LENGTH(nodename_oid);
+
+  /* this is the oid for the hbagent online trap */
+    oid  trap_oid[] = { 1, 3, 6, 1, 4, 1, 4682, 900, 7 };
+    size_t trap_oid_len = OID_LENGTH(trap_oid);
+
+    /* this is the oid for the offline trap */
+    if (!online) {
+	    trap_oid[trap_oid_len - 1] = 9;
+    }
+
+
+    snmp_varlist_add_variable(&notification_vars,
+                              /*
+                               * the snmpTrapOID.0 variable
+                               */
+                              objid_snmptrap, objid_snmptrap_len,
+                              /*
+                               * value type is an OID
+                               */
+                              ASN_OBJECT_ID,
+                              /*
+                               * value contents is our notification OID
+                               */
+                              (u_char *) trap_oid,
+                              /*
+                               * size in bytes = oid length * sizeof(oid)
+                               */
+                              trap_oid_len * sizeof(oid));
+
+    snmp_varlist_add_variable(&notification_vars,
+                              nodename_oid, 
+			      nodename_oid_len,
+                              ASN_OCTET_STR,
+                              (const u_char *) node,
+                              strlen(node)); /* do NOT use strlen() +1 */
+
+    cl_log(LOG_INFO, "sending hbagent trap. status:%d", online);
+    send_v2trap(notification_vars);
+    snmp_free_varbind(notification_vars);
+
+    return HA_OK;
+}
 
 static void
 usage(void)
@@ -1467,6 +1471,24 @@
 	}
 #endif
 
+#if SUPPORT_AIS
+	if (is_openais_cluster()) {
+#if SUPPORT_HEARTBEAT
+		struct utsname name;
+		if(uname(&name) < 0) {
+			cl_log(LOG_ERR, "uname(2) call failed: %s", strerror(errno));
+		} else {
+			myid = strdup(name.nodename);
+		}
+
+		if (myid != NULL) {
+			myuuid = strdup(myid);
+		}
+#else
+		crm_cluster_connect(&myid, &myuuid, NULL, NULL, NULL);
+#endif
+	}
+#endif
 	/*
 	if ((ret = init_membership() != HA_OK) ||
 		(mem_fd = get_membership_fd()) <= 0) {
@@ -1510,11 +1532,7 @@
 
 	snmp_log(LOG_INFO,"LHA-agent is up and running.\n");
 
-#if SUPPORT_HEARTBEAT
-	if (is_heartbeat_cluster()) {
-		hbagent_trap(1, myid);
-	}
-#endif
+	hbagent_trap(1, myid);
 
 	hbconfig_refresh_cnt = 0;
 
@@ -1655,25 +1673,22 @@
 
 	/* at shutdown time */
 	
-#if SUPPORT_HEARTBEAT
-	if (is_heartbeat_cluster()) {
-		hbagent_trap(0, myid);
-	}
-#endif
+	hbagent_trap(0, myid);
 	snmp_shutdown("LHA-agent");
 
 	free_hbagentv2();
+	if (myid != NULL) {
+		free(myid);
+	}
+	if (myuuid != NULL) {
+		free(myuuid);
+	}
+
 #if SUPPORT_HEARTBEAT
         if (is_heartbeat_cluster()) {
  		free_hbconfig();
-		free(myid);
-		free(myuuid);
 		free_storage();
-	}
-#endif
 
-#if SUPPORT_HEARTBEAT
-        if (is_heartbeat_cluster()) {
 		if (!hb_already_dead && hb->llc_ops->signoff(hb, TRUE) != HA_OK) {
 			cl_log(LOG_ERR, "Cannot sign off from heartbeat.");
 			cl_log(LOG_ERR, "REASON: %s", hb->llc_ops->errmsg(hb));
diff -r 56e1e8787452 snmp_subagent/hbagentv2.c
--- a/snmp_subagent/hbagentv2.c	Tue Jul 07 14:30:31 2009 +0800
+++ b/snmp_subagent/hbagentv2.c	Thu Jul 16 22:30:47 2009 +0800
@@ -353,16 +353,11 @@
             free_xml(diff);
             return;
         }
-
-#if SUPPORT_HEARTBEAT
-        if (is_heartbeat_cluster()) {
-            if (STRNCMP_CONST(node_id, myuuid) != 0) {
-                /* This change is not at my node */
-                free_xml(diff);
-                return;
-            }
+        if (myuuid != NULL && STRNCMP_CONST(node_id, myuuid) != 0) {
+            /* This change is not at my node */
+            free_xml(diff);
+            return;
         }
-#endif
 
         /* get the head pointer of <lrm_resource>  */
         lrm_rsc = find_xml_node(node_state, XML_CIB_TAG_LRM, FALSE);
_______________________________________________
Pacemaker mailing list
Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Reply via email to