Will anything bad happen if no community is specified? Ie. If we pass in NULL.
On Wed, Apr 7, 2010 at 1:37 PM, Jonathan Süssemilch Poulain <jonathan.sussemilch.poul...@liu.se> wrote: > # HG changeset patch > # User Jonathan Süssemilch Poulain <jonathan.sussemilch.poul...@liu.se> > # Date 1270636707 -7200 > # Branch stable-1.0 > # Node ID 85f52c5f6b667758a8c884048f01ebdd4ad08861 > # Parent 620bc9a36a0e410ebe4411ae56d5c6f25b5df524 > Enable specification of community for SNMP traps > > diff -r 620bc9a36a0e -r 85f52c5f6b66 tools/crm_mon.c > --- a/tools/crm_mon.c Thu Apr 01 14:51:34 2010 +0200 > +++ b/tools/crm_mon.c Wed Apr 07 12:38:27 2010 +0200 > @@ -56,6 +56,7 @@ > char *as_html_file = NULL; > char *pid_file = NULL; > char *snmp_target = NULL; > +char *snmp_community = NULL; > > gboolean as_console = TRUE;; > gboolean simple_status = FALSE; > @@ -244,6 +245,7 @@ > {"web-cgi", 0, 0, 'w', "\tWeb mode with output suitable for cgi"}, > {"simple-status", 0, 0, 's', "Display the cluster status once as a > simple one line output (suitable for nagios)"}, > {"snmp-traps", 1, 0, 'S', "Send SNMP traps to this station", > !ENABLE_SNMP}, > + {"snmp-community", 1, 0, 'C', "Specify community for SNMP > traps(default is NULL)", !ENABLE_SNMP}, > {"mail-to", 1, 0, 'T', "Send Mail alerts to this user. See also > --mail-from, --mail-host, --mail-prefix", !ENABLE_ESMTP}, > > {"-spacer-", 1, 0, '-', "\nDisplay Options:"}, > @@ -297,7 +299,7 @@ > pid_file = crm_strdup("/tmp/ClusterMon.pid"); > crm_log_init(basename(argv[0]), LOG_CRIT, FALSE, FALSE, 0, NULL); > > - crm_set_options("V?$i:nrh:dp:s1wx:oftNS:T:F:H:P:E:e:", "mode [options]", > long_options, > + crm_set_options("V?$i:nrh:dp:s1wx:oftNS:C:T:F:H:P:E:e:", "mode > [options]", long_options, > "Provides a summary of cluster's current state." > "\n\nOutputs varying levels of detail in a number of > different formats.\n"); > > @@ -389,6 +391,9 @@ > case 'N': > as_console = FALSE; > break; > + case 'C': > + snmp_community = optarg; > + break; > case '$': > case '?': > crm_help(flag, LSB_EXIT_OK); > @@ -1191,7 +1196,7 @@ > return 1; > } > > -static netsnmp_session *crm_snmp_init(const char *target) > +static netsnmp_session *crm_snmp_init(const char *target, char *community) > { > static netsnmp_session *session = NULL; > #ifdef NETSNMPV53 > @@ -1218,6 +1223,8 @@ > session->version = SNMP_VERSION_2c; > session->callback = snmp_input; > session->callback_magic = NULL; > + session->community_len = strnlen(community, INT_MAX); > + session->community = (unsigned char*)community; > > session = snmp_add(session, > #ifdef NETSNMPV53 > @@ -1245,7 +1252,7 @@ > static oid sysuptime_oid[] = { 1,3,6,1,2,1,1,3,0 }; > > netsnmp_pdu *trap_pdu; > - netsnmp_session *session = crm_snmp_init(snmp_target); > + netsnmp_session *session = crm_snmp_init(snmp_target, snmp_community); > > trap_pdu = snmp_pdu_create(SNMP_MSG_TRAP2); > if ( !trap_pdu ) { > @@ -1779,7 +1786,7 @@ > void clean_up(int rc) > { > #if ENABLE_SNMP > - netsnmp_session *session = crm_snmp_init(NULL); > + netsnmp_session *session = crm_snmp_init(NULL, NULL); > if(session) { > snmp_close(session); > snmp_shutdown("snmpapp"); > _______________________________________________ > Pacemaker mailing list > Pacemaker@oss.clusterlabs.org > http://oss.clusterlabs.org/mailman/listinfo/pacemaker > _______________________________________________ Pacemaker mailing list Pacemaker@oss.clusterlabs.org http://oss.clusterlabs.org/mailman/listinfo/pacemaker