Browse Source

corosync-notifyd: Add option to disable DNS lookup

New configuration option -n is added.

Signed-off-by: dkutergin <dmytro.kutergin@harmonicinc.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
dkutergin 6 years ago
parent
commit
2183b9aa4a
2 changed files with 15 additions and 4 deletions
  1. 3 0
      man/corosync-notifyd.8
  2. 12 4
      tools/corosync-notifyd.c

+ 3 - 0
man/corosync-notifyd.8

@@ -57,6 +57,9 @@ Send SNMP traps on all events.
 .B -m
 Set the SNMP Manager IP address (defaults to localhost).
 .TP
+.B -n
+No reverse DNS lookup on cmap member change events.
+.TP
 .B -d
 Send DBUS signals on all events.
 .TP

+ 12 - 4
tools/corosync-notifyd.c

@@ -73,6 +73,7 @@ enum {
 	CS_NTF_SNMP,
 	CS_NTF_DBUS,
 	CS_NTF_FG,
+	CS_NTF_NODNS,
 	CS_NTF_MAX,
 };
 static int conf[CS_NTF_MAX];
@@ -278,11 +279,14 @@ static void _cs_cmap_members_key_changed (
 		return ;
 	}
 	*close_bracket = '\0';
-	res = _cs_ip_to_hostname(open_bracket, nodename);
-	if (res) {
+	if(conf[CS_NTF_NODNS]) {
 		strncpy(nodename, open_bracket, CS_MAX_NAME_LENGTH-1);
+	} else {
+		res = _cs_ip_to_hostname(open_bracket, nodename);
+		if (res) {
+			strncpy(nodename, open_bracket, CS_MAX_NAME_LENGTH-1);
+		}
 	}
-
 	_cs_node_membership_event(nodename, nodeid, (char *)new_value.data, open_bracket);
 	free(ip_str);
 }
@@ -1258,6 +1262,7 @@ _cs_usage(void)
 		"        -o     : Print events to stdout (turns on -l).\n"\
 		"        -s     : Send SNMP traps on all events.\n"\
 		"        -m     : Set the SNMP Manager IP address (defaults to localhost).\n"\
+		"        -n     : No reverse DNS lookup on cmap member change events.\n"\
 		"        -d     : Send DBUS signals on all events.\n"\
 		"        -h     : Print this help.\n\n");
 }
@@ -1273,7 +1278,7 @@ main(int argc, char *argv[])
 	conf[CS_NTF_SNMP] = QB_FALSE;
 	conf[CS_NTF_DBUS] = QB_FALSE;
 
-	while ((ch = getopt (argc, argv, "c:floshdm:")) != EOF) {
+	while ((ch = getopt (argc, argv, "c:floshdnm:")) != EOF) {
 		switch (ch) {
 			case 'c':
 				strncpy(snmp_community_buf, optarg, sizeof (snmp_community_buf));
@@ -1292,6 +1297,9 @@ main(int argc, char *argv[])
 				snmp_manager_buf[sizeof (snmp_manager_buf) - 1] = '\0';
 				snmp_manager = snmp_manager_buf;
 				break;
+			case 'n':
+				conf[CS_NTF_NODNS] = QB_TRUE;
+				break;
 			case 'o':
 				conf[CS_NTF_LOG] = QB_TRUE;
 				conf[CS_NTF_STDOUT] = QB_TRUE;