Sfoglia il codice sorgente

Make node state a string (not an integer)

Ryan noticed this inconsistency, all other status's
are string so this should be too.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Seven Dake <sdake@redhat.com>
Reviewed-by: Ryan O'Hara <rohara@redhat.com>
Angus Salkeld 15 anni fa
parent
commit
8699ed2309
2 ha cambiato i file con 2 aggiunte e 15 eliminazioni
  1. 1 5
      conf/COROSYNC-MIB.txt
  2. 1 10
      tools/corosync-notifyd.c

+ 1 - 5
conf/COROSYNC-MIB.txt

@@ -56,11 +56,7 @@ corosyncObjectsNodeID OBJECT-TYPE
 ::= { corosyncObjects 2 }
 
 corosyncObjectsNodeStatus OBJECT-TYPE
-    SYNTAX      INTEGER {
-		  unknown (0),
-		  joined  (1),
-		  left    (2)
-		}
+    SYNTAX	OCTET STRING
     MAX-ACCESS  accessible-for-notify
     STATUS      current
     DESCRIPTION

+ 1 - 10
tools/corosync-notifyd.c

@@ -690,7 +690,6 @@ _cs_snmp_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 	static oid snmptrap_oid[]  = { 1,3,6,1,6,3,1,1,4,1,0 };
 	static oid sysuptime_oid[] = { 1,3,6,1,2,1,1,3,0 };
 	time_t now = time (NULL);
-	int node_status;
 
 	netsnmp_pdu *trap_pdu;
 	netsnmp_session *session = snmp_init (snmp_manager);
@@ -705,14 +704,6 @@ _cs_snmp_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 		return ;
 	}
 
-	if (strcmp(state, "joined") == 0) {
-		node_status = SNMP_NODE_STATUS_JOINED;
-	} else if (strcmp(state, "left") == 0) {
-		node_status = SNMP_NODE_STATUS_LEFT;
-	} else {
-		node_status = SNMP_NODE_STATUS_UNKNOWN;
-	}
-
 	/* send uptime */
 	snprintf (csysuptime, CS_TIMESTAMP_STR_LEN, "%ld", now);
 	snmp_add_var (trap_pdu, sysuptime_oid, sizeof (sysuptime_oid) / sizeof (oid), 't', csysuptime);
@@ -722,7 +713,7 @@ _cs_snmp_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 	add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_NAME, (void*)nodename, strlen (nodename));
 	add_field (trap_pdu, ASN_INTEGER, SNMP_OID_OBJECT_NODE_ID, (void*)&nodeid, sizeof (nodeid));
 	add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_ADDR, (void*)ip, strlen (ip));
-	add_field (trap_pdu, ASN_INTEGER, SNMP_OID_OBJECT_NODE_STATUS, (void*)&node_status, sizeof (node_status));
+	add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_STATUS, (void*)state, strlen (state));
 
 	/* Send and cleanup */
 	ret = snmp_send (session, trap_pdu);