%variable&meaning&default value &further details\\
\begin{itemize}
\item \texttt{MYSQL\_PASSWORD} -- root password of MySQL server (mandatory)
-\item \texttt{GLITE\_WMS\_LCGMON\_FILE} -- pathname of file where job state
-export data are written for use by lgcmon/R-GMA
-(default: \texttt{/var/glite/logging/status.log}). \emph{Note: This feature is now obsolete and only available in \LBver{1.x}.}
\item \texttt{GLITE\_LB\_EXPORT\_PURGE\_ARGS} -- purge timeouts (default: \texttt{--cleared 2d --aborted 15d --cancelled 15d --other 60d})
According to local retention policy you may want to use different purge timeouts (for example WLCG would need \texttt{--cleared 90d --aborted 90d --cancelled 90d --other 90d}).
(default: \texttt{heppc24.hep.ph.ic.ac.uk} machine certificate)
\item \texttt{GLITE\_LB\_SUPER\_USERS} -- additional super-users (default: empty)
\item \texttt{GLITE\_LB\_TYPE} -- type of the \LB service: server, proxy, both (default: autodetect, \LB node only: 'server', WMS node only: proxy, \LB and WMS: 'both')
-\item \texttt{GLITE\_LB\_HARVESTER\_ENABLED} -- set to \texttt{true} for sending notifications, used mainly for legacy export to MSG publish system (default: \texttt{false})
-\item \texttt{GLITE\_LB\_HARVESTER\_MSG\_OPTIONS} -- additional options for MSG publish (default: \texttt{--wlcg})
\item \texttt{GLITE\_LB\_INDEX\_OWNER} -- when specified, add (\texttt{true}) or drop (\texttt{false}) 'owner' index (default: 'owner' index not touched)
-\item \texttt{GLITE\_LB\_MSG\_BROKER} -- hostname and port of MSG broker, empty for disabling MSG notifications (default: empty)
+\item \texttt{GLITE\_LB\_MSG\_BROKER} -- URL of the MSG broker, 'auto' for looking in BDII, 'false' for disabling MSG notifications (default: auto)
+\item \texttt{GLITE\_LB\_MSG\_NETWORK} -- required network type when searching in BDII (default: PROD)
+\item \texttt{LCG\_GFAL\_INFOSYS} -- BDII servers (default: lcg-bdii.cern.ch:2170)
\end{itemize}
-Additional helper parameters for \LB:
+Additional helper or legacy parameters for \LB:
\begin{itemize}
\item \texttt{GLITE\_LB\_LOCATION} -- \LB prefix (default: /opt/glite or /usr)
\item \texttt{GLITE\_LB\_LOCATION\_ETC} -- system config directory (default: /opt/glite/etc or /etc)
\item \texttt{GLITE\_LB\_LOCATION\_VAR} -- gLite local state directory (default: /opt/glite/var or /var/glite)
\item \texttt{GLITE\_JP\_LOCATION} -- can be used when JP subsystem location differs from LB (default: empty)
+\item \texttt{GLITE\_LB\_HARVESTER\_ENABLED} -- set to \texttt{true} for sending notifications, used mainly for legacy export to MSG publish system (default: \texttt{false})
+\item \texttt{GLITE\_LB\_HARVESTER\_MSG\_OPTIONS} -- additional options for MSG publish (default: \texttt{--wlcg})
+\item \texttt{GLITE\_WMS\_LCGMON\_FILE} -- pathname of file where job state
+export data are written for use by lgcmon/R-GMA
+(default: \texttt{/var/glite/logging/status.log}). \emph{Note: This feature is now obsolete and only available in \LBver{1.x}.}
\end{itemize}
In addition to those, YAIM LB module uses following parameters:
--- /dev/null
+#!/usr/bin/perl
+#+##############################################################################
+# #
+# File: msg-brokers #
+# #
+# Description: manipulate messaging brokers information #
+# #
+#-##############################################################################
+
+#
+# modules
+#
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Net::LDAP;
+use Pod::Usage;
+use Time::HiRes qw();
+
+#
+# constants
+#
+
+use constant LDAP_TIMEOUT => 10;
+use constant STOMP_TIMEOUT => 5;
+
+#
+# global variables
+#
+
+our($Action, %Option);
+
+#
+# report a debugging message
+#
+
+sub debug ($$@) {
+ my($level, $format, @arguments) = @_;
+ my($message);
+
+ return unless $Option{debug} >= $level;
+ $message = sprintf($format, @arguments);
+ $message =~ s/\s+$//;
+ print(STDERR "# $message\n");
+}
+
+#
+# report a warning message
+#
+
+sub warning ($@) {
+ my($format, @arguments) = @_;
+ my($message);
+
+ return if $Option{quiet};
+ $message = sprintf($format, @arguments);
+ $message =~ s/\s+$//;
+ print(STDERR "* $message\n");
+}
+
+#
+# report a fatal error
+#
+
+sub fatal ($@) {
+ my($format, @arguments) = @_;
+ my($message);
+
+ $message = sprintf($format, @arguments);
+ $message =~ s/\s+$//;
+ die("msg-brokers: $message\n");
+}
+
+#
+# initialise everything
+#
+
+sub init () {
+ # defaults
+ $Option{bdii} = $ENV{LCG_GFAL_INFOSYS};
+ $Option{debug} = 0;
+ # options parsing
+ GetOptions(
+ "bdii=s" => \$Option{bdii},
+ "cache=s" => \$Option{cache},
+ "debug|d+" => \$Option{debug},
+ "help|h|?" => \$Option{help},
+ "manual|m" => \$Option{manual},
+ "network=s" => \$Option{network},
+ "quiet|q" => \$Option{quiet},
+ "sort|s" => \$Option{sort},
+ ) or pod2usage(2);
+ pod2usage(1) if $Option{help};
+ pod2usage(exitstatus => 0, verbose => 2) if $Option{manual};
+ # action parsing
+ pod2usage(2) unless @ARGV;
+ if ($ARGV[0] =~ /^(find|list)$/) {
+ $Action = shift(@ARGV);
+ pod2usage(2) if @ARGV;
+ } else {
+ warn("Unknown action: $ARGV[0]\n");
+ pod2usage(2);
+ }
+}
+
+#
+# connect to the BDII and return the corresponding Net::LDAP object
+#
+
+sub connect_bdii () {
+ my($bdii, @list, $ldap, $mesg);
+
+ $bdii = $Option{bdii};
+ fatal("unspecified BDII (use --bdii or set \$LCG_GFAL_INFOSYS)")
+ unless $bdii;
+ if ($bdii =~ /[\,\;]/) {
+ # list of BDIIs
+ @list = split(/[\,\;]+/, $bdii);
+ debug(1, "using BDII list %s", "@list");
+ } else {
+ # single BDII
+ @list = ($bdii);
+ debug(1, "using single BDII %s", $bdii);
+ }
+ foreach $bdii (@list) {
+ $ldap = Net::LDAP->new($bdii,
+ port => 2170,
+ timeout => LDAP_TIMEOUT,
+ async => 1,
+ );
+ last if $ldap;
+ if (@list == 1) {
+ fatal("could not connect to BDII %s: %s", $bdii, $@);
+ } else {
+ warning("could not connect to BDII %s: %s", $bdii, $@);
+ }
+ }
+ fatal("could not connect to any BDII") unless $ldap;
+ debug(1, "connected to BDII %s", $ldap->{net_ldap_uri});
+ $mesg = $ldap->bind(anonymous => 1);
+ fatal("could not bind to BDII %s: %s", $ldap->{net_ldap_uri}, $mesg->error())
+ if $mesg->code();
+ return($ldap);
+}
+
+#
+# search the BDII and return the corresponding results
+#
+
+sub search_bdii ($%) {
+ my($ldap, %option) = @_;
+ my($mesg);
+
+ $option{base} = "o=grid";
+ $option{timelimit} = LDAP_TIMEOUT;
+ $mesg = $ldap->search(%option);
+ fatal("could not search BDII %s: %s", $ldap->{net_ldap_uri}, $mesg->error())
+ if $mesg->code();
+ return($mesg->entries());
+}
+
+#
+# query the BDII and return the list of matching messaging broker URIs
+#
+
+sub list_brokers ($) {
+ my($ldap, %search, $endpoint, $match, $network, $value, @uris);
+ my($check) = @_;
+
+ $ldap = connect_bdii();
+ %search = (
+ filter => "(&(objectClass=GlueService)(GlueServiceType=msg.broker.openwire)",
+ attrs => [ qw(GlueServiceEndpoint GlueServiceUniqueID) ],
+ );
+ $search{filter} .= "(GlueServiceStatus=OK)" if ($check);
+ $search{filter} .= ")";
+ foreach $endpoint (search_bdii($ldap, %search)) {
+ $value = $endpoint->get_value("GlueServiceUniqueID");
+ debug(2, " found endpoint %s", $value);
+ %search = (
+ filter => "(&(GlueServiceDataKey=cluster)(GlueChunkKey=GlueServiceUniqueID=$value))",
+ attrs => [ qw(GlueServiceDataValue) ],
+ );
+ $match = 0;
+ foreach $network (search_bdii($ldap, %search)) {
+ $value = $network->get_value("GlueServiceDataValue");
+ debug(2, " found network %s", $value);
+ next if defined($Option{network}) and $Option{network} ne $value;
+ $match++;
+ }
+ $value = $endpoint->get_value("GlueServiceEndpoint");
+ if ($match) {
+ push(@uris, $value);
+ debug(2, " keep URI %s", $value);
+ } else {
+ debug(2, " skip URI %s", $value);
+ }
+ }
+ debug(1, "got %d broker URIs from BDII", scalar(@uris));
+ warning("got an empty brokers list from BDII") unless @uris;
+ return(@uris);
+}
+
+#
+# report the final list of messaging broker URIs
+#
+
+sub report_brokers (@) {
+ my(@list) = @_;
+ my($uri, $fh);
+
+ unless (defined($Option{cache})) {
+ # report only to STDOUT
+ foreach $uri (@list) {
+ print("$uri\n");
+ }
+ return;
+ }
+ unless (@list) {
+ # no brokers so no cache update
+ warning("no brokers found so cache file not updated");
+ return;
+ }
+ # update the cache file
+ open($fh, ">", $Option{cache})
+ or fatal("cannot open %s: %s", $Option{cache}, $!);
+ foreach $uri (@list) {
+ print($fh "$uri\n");
+ }
+ close($fh)
+ or fatal("cannot close %s: %s", $Option{cache}, $!);
+ debug(1, "cache %s updated with %d brokers", $Option{cache}, scalar(@list));
+}
+
+#
+# main part
+#
+
+sub main () {
+ my(@list);
+
+ if ($Action eq "list") {
+ @list = list_brokers(0);
+ } elsif ($Action eq "find") {
+ @list = list_brokers(1);
+ } else {
+ fatal("unexpected action: %s", $Action);
+ }
+ report_brokers(@list);
+}
+
+#
+# just do it
+#
+
+init();
+main();
+
+__END__
+
+=head1 NAME
+
+msg-brokers - manipulate messaging brokers information
+
+=head1 SYNOPSIS
+
+B<msg-brokers> [I<OPTIONS>] B<find>|B<list>
+
+=head1 DESCRIPTION
+
+B<msg-brokers> has three different modes of operation. In all cases,
+it manipulates information about messaging brokers and reports a
+(possibly empty) list of broker URIs, one per line.
+
+=over
+
+=item B<list>
+
+list all the URIs declared in the BDII, optionally filtered by network
+
+=item B<find>
+
+the B<list> functionality described above plus filter by GlueServiceStatus
+
+=back
+
+A fatal error (e.g. cannot contact the BDII) will halt the program.
+A warning (e.g. a given URI cannot be contacted) will be reported
+unless B<--quiet> is used. Both will be sent to STDERR.
+
+The exit status will be 0 on success (with or without warnings) or
+different from 0 in case of a fatal error.
+
+=head1 OPTIONS
+
+=over
+
+=item B<--bdii> I<string>
+
+specify the I<name> or I<name>:I<port> of the BDII to contact;
+this can also be a list, separated by commas or semicolons;
+if not set, it defaults to $LCG_GFAL_INFOSYS
+
+=item B<--cache> I<path>
+
+specify the path of a file to update with the list of URIs;
+if this is set, nothing will be printed on STDOUT;
+note: if the list is empty, the file will I<not> be updated
+
+=item B<--debug>, B<-d>
+
+report debugging information;
+can be used multiple times for increased verbosity
+
+=item B<--help>, B<-h>, B<-?>
+
+show some help
+
+=item B<--manual>, B<-m>
+
+show the complete man page
+
+=item B<--network> I<string>
+
+consider only the brokers for this network
+
+=item B<--quiet>, B<-q>
+
+supress the printing of warnings
+
+=item B<--sort>, B<-s>
+
+sort the brokers per elapsed time to perform the test
+
+=back
+
+=head1 SEE ALSO
+
+L<Net::STOMP::Client>
+
+=head1 AUTHOR
+
+Lionel Cons L<http://cern.ch/lionel.cons>