Просмотр исходного кода

corosync-notifyd: make SNMP work again

rrp_faulty_fn in notify_callbacks no longer exists, and now become
link_faulty_fn, and also link_faulty_fn needs 5 arguments while
rrp_faulty_fn needs 4.

Signed-off-by: Bin Liu <bliu@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Bin Liu 8 лет назад
Родитель
Сommit
edca042229
2 измененных файлов с 34 добавлено и 22 удалено
  1. 18 9
      conf/COROSYNC-MIB.txt
  2. 16 13
      tools/corosync-notifyd.c

+ 18 - 9
conf/COROSYNC-MIB.txt

@@ -13,10 +13,12 @@ IMPORTS
 ;
 
 corosync MODULE-IDENTITY
-    LAST-UPDATED    "201101211300Z"
+    LAST-UPDATED    "201801121241Z"
     ORGANIZATION    "www.corosync.org"
     CONTACT-INFO    "name:  Yuki Sato
                      email: users@clusterlabs.org"
+    DESCRIPTION     "*RRP* related staff has changed to *Link* staff"
+    REVISION        "201801121241Z"
     DESCRIPTION     "Add cluster quorum traps, fix smilint errors, and fix notification block ID"
     REVISION        "201101211300Z"
     DESCRIPTION     "MIB objects for Corosync"
@@ -70,6 +72,12 @@ corosyncObjectsNodeAddress OBJECT-TYPE
     DESCRIPTION "The address of the node."
 ::= { corosyncObjects 4 }
 
+corosyncObjectsLocalNodeID OBJECT-TYPE
+    SYNTAX      Unsigned32
+    MAX-ACCESS  accessible-for-notify
+    STATUS      current
+    DESCRIPTION "The unique integer of local node."
+::= { corosyncObjects 5 }
 
 --
 -- Quorum Information
@@ -94,7 +102,7 @@ corosyncObjectsQuorumStatus OBJECT-TYPE
 ::= { corosyncObjects 21 }
 
 --
--- RRP Information
+-- Link Information
 ---
 
 corosyncObjectsIfaceNo OBJECT-TYPE
@@ -104,12 +112,12 @@ corosyncObjectsIfaceNo OBJECT-TYPE
     DESCRIPTION "The integer of interface."
 ::= { corosyncObjects 60 }
 
-corosyncObjectsRRPStatus OBJECT-TYPE
+corosyncObjectsLinkStatus OBJECT-TYPE
     SYNTAX	OCTET STRING
     MAX-ACCESS  accessible-for-notify
     STATUS      current
     DESCRIPTION
-	"RRP Status"
+	"Link Status"
 ::= { corosyncObjects 61 }
 
 --
@@ -174,14 +182,15 @@ corosyncNoticesAppStatus NOTIFICATION-TYPE
        name and the new state (either 'connected' or 'disconnected')."
 ::= { corosyncNotices 3 }
 
-corosyncNoticesRRPStatus NOTIFICATION-TYPE
+corosyncNoticesLinkStatus NOTIFICATION-TYPE
     OBJECTS	{ corosyncObjectsNodeName,
+		  corosyncObjectsLocalNodeID,
 		  corosyncObjectsNodeID,
 		  corosyncObjectsIfaceNo,
-		  corosyncObjectsRRPStatus }
+		  corosyncObjectsLinkStatus }
     STATUS  current
     DESCRIPTION
-      "Produced when the interface of RRP is marked failed or operational.
+      "Produced when the interface of Link is marked failed or operational.
 
        The notification also includes the node name, nodeid, iface number
        and the new state (either 'failed' or 'operational')."
@@ -211,7 +220,7 @@ corosyncObjectGroup OBJECT-GROUP
 	      corosyncObjectsAppName,
 	      corosyncObjectsAppStatus,
 	      corosyncObjectsIfaceNo,
-	      corosyncObjectsRRPStatus
+	      corosyncObjectsLinkStatus
             }
     STATUS      current
     DESCRIPTION "Corosync Object Conformance Group"
@@ -221,7 +230,7 @@ corosyncNotificationGroup NOTIFICATION-GROUP
     NOTIFICATIONS { corosyncNoticesNodeStatus,
                     corosyncNoticesQuorumStatus,
 		    corosyncNoticesAppStatus,
-		    corosyncNoticesRRPStatus
+		    corosyncNoticesLinkStatus
                   }
     STATUS      current
     DESCRIPTION "Corosync Notification Conformance Group"

+ 16 - 13
tools/corosync-notifyd.c

@@ -146,6 +146,7 @@ enum snmp_node_status {
 #define SNMP_OID_OBJECT_NODE_ID		SNMP_OID_OBJECT_ROOT ".2"
 #define SNMP_OID_OBJECT_NODE_STATUS	SNMP_OID_OBJECT_ROOT ".3"
 #define SNMP_OID_OBJECT_NODE_ADDR	SNMP_OID_OBJECT_ROOT ".4"
+#define SNMP_OID_OBJECT_LOCAL_NODE_ID		SNMP_OID_OBJECT_ROOT ".5"
 
 #define SNMP_OID_OBJECT_RINGSEQ		SNMP_OID_OBJECT_ROOT ".20"
 #define SNMP_OID_OBJECT_QUORUM		SNMP_OID_OBJECT_ROOT ".21"
@@ -153,14 +154,14 @@ enum snmp_node_status {
 #define SNMP_OID_OBJECT_APP_NAME	SNMP_OID_OBJECT_ROOT ".40"
 #define SNMP_OID_OBJECT_APP_STATUS	SNMP_OID_OBJECT_ROOT ".41"
 
-#define SNMP_OID_OBJECT_RRP_IFACE_NO	SNMP_OID_OBJECT_ROOT ".60"
-#define SNMP_OID_OBJECT_RRP_STATUS	SNMP_OID_OBJECT_ROOT ".61"
+#define SNMP_OID_OBJECT_LINK_IFACE_NO	SNMP_OID_OBJECT_ROOT ".60"
+#define SNMP_OID_OBJECT_LINK_STATUS	SNMP_OID_OBJECT_ROOT ".61"
 
 #define SNMP_OID_TRAPS_ROOT		SNMP_OID_COROSYNC ".0"
 #define SNMP_OID_TRAPS_NODE		SNMP_OID_TRAPS_ROOT ".1"
 #define SNMP_OID_TRAPS_QUORUM		SNMP_OID_TRAPS_ROOT ".2"
 #define SNMP_OID_TRAPS_APP		SNMP_OID_TRAPS_ROOT ".3"
-#define SNMP_OID_TRAPS_RRP		SNMP_OID_TRAPS_ROOT ".4"
+#define SNMP_OID_TRAPS_LINK		SNMP_OID_TRAPS_ROOT ".4"
 
 #define CS_TIMESTAMP_STR_LEN 20
 static const char *local_host = "localhost";
@@ -634,7 +635,7 @@ out_free:
 }
 
 static void
-_cs_dbus_link_faulty_event(char *nodename, uint32_t nodeid, uint32_t iface_no, const char *state)
+_cs_dbus_link_faulty_event(char *nodename, uint32_t local_nodeid, uint32_t nodeid, uint32_t iface_no, const char *state)
 {
 	DBusMessage *msg = NULL;
 
@@ -665,11 +666,12 @@ _cs_dbus_link_faulty_event(char *nodename, uint32_t nodeid, uint32_t iface_no, c
 
 	if (!dbus_message_append_args(msg,
 			DBUS_TYPE_STRING, &nodename,
+			DBUS_TYPE_UINT32, &local_nodeid,
 			DBUS_TYPE_UINT32, &nodeid,
 			DBUS_TYPE_UINT32, &iface_no,
 			DBUS_TYPE_STRING, &state,
 			DBUS_TYPE_INVALID)) {
-		qb_log(LOG_ERR, "error adding args to rrp signal");
+		qb_log(LOG_ERR, "error adding args to link signal");
 		goto out_unlock;
 	}
 
@@ -710,8 +712,8 @@ _cs_dbus_init(void)
 		_cs_dbus_node_quorum_event;
 	notifiers[num_notifiers].application_connection_fn =
 		_cs_dbus_application_connection_event;
-	notifiers[num_notifiers].rrp_faulty_fn =
-		_cs_dbus_rrp_faulty_event;
+	notifiers[num_notifiers].link_faulty_fn =
+		_cs_dbus_link_faulty_event;
 
 	num_notifiers++;
 }
@@ -858,7 +860,7 @@ _cs_snmp_node_quorum_event(char *nodename, uint32_t nodeid,
 }
 
 static void
-_cs_snmp_rrp_faulty_event(char *nodename, uint32_t nodeid,
+_cs_snmp_link_faulty_event(char *nodename, uint32_t local_nodeid, uint32_t nodeid,
 		uint32_t iface_no, const char *state)
 {
 	int ret;
@@ -883,13 +885,14 @@ _cs_snmp_rrp_faulty_event(char *nodename, uint32_t nodeid,
 	/* send uptime */
 	sprintf (csysuptime, "%ld", now);
 	snmp_add_var (trap_pdu, sysuptime_oid, sizeof (sysuptime_oid) / sizeof (oid), 't', csysuptime);
-	snmp_add_var (trap_pdu, snmptrap_oid, sizeof (snmptrap_oid) / sizeof (oid), 'o', SNMP_OID_TRAPS_RRP);
+	snmp_add_var (trap_pdu, snmptrap_oid, sizeof (snmptrap_oid) / sizeof (oid), 'o', SNMP_OID_TRAPS_LINK);
 
 	/* Add extries to the trap */
 	add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_NAME, (void*)nodename, strlen (nodename));
+	add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_LOCAL_NODE_ID, (void*)&local_nodeid, sizeof (local_nodeid));
 	add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_NODE_ID, (void*)&nodeid, sizeof (nodeid));
-	add_field (trap_pdu, ASN_INTEGER, SNMP_OID_OBJECT_RRP_IFACE_NO, (void*)&iface_no, sizeof (iface_no));
-	add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_RRP_STATUS, (void*)state, strlen (state));
+	add_field (trap_pdu, ASN_INTEGER, SNMP_OID_OBJECT_LINK_IFACE_NO, (void*)&iface_no, sizeof (iface_no));
+	add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_LINK_STATUS, (void*)state, strlen (state));
 
 	/* Send and cleanup */
 	ret = snmp_send (session, trap_pdu);
@@ -912,8 +915,8 @@ _cs_snmp_init(void)
 	notifiers[num_notifiers].node_quorum_fn =
 		_cs_snmp_node_quorum_event;
 	notifiers[num_notifiers].application_connection_fn = NULL;
-	notifiers[num_notifiers].rrp_faulty_fn =
-		_cs_snmp_rrp_faulty_event;
+	notifiers[num_notifiers].link_faulty_fn =
+		_cs_snmp_link_faulty_event;
 	num_notifiers++;
 }