Skip to content

Commit

Permalink
Merge pull request ganglia#103 from vvuksan/master
Browse files Browse the repository at this point in the history
Move gzip output into tcp_accept_channel and better conf file documentation
  • Loading branch information
vvuksan committed Apr 30, 2013
2 parents 8ff4bb3 + 8a8d9d7 commit f832366
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
17 changes: 0 additions & 17 deletions gmond/cmdline.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const char *gengetopt_args_info_help[] = {
" -b, --bandwidth Calculate minimum bandwidth use for configuration \n (default=off)",
" -r, --convert=STRING Convert a 2.5.x configuration file to the new 3.x \n format",
" -p, --pid-file=STRING Write process-id to file",
" -z, --gzip-output Compress output with gzip before sending \n (default=off)",
0
};

Expand Down Expand Up @@ -80,7 +79,6 @@ void clear_given (struct gengetopt_args_info *args_info)
args_info->bandwidth_given = 0 ;
args_info->convert_given = 0 ;
args_info->pid_file_given = 0 ;
args_info->gzip_output_given = 0 ;
}

static
Expand All @@ -101,7 +99,6 @@ void clear_args (struct gengetopt_args_info *args_info)
args_info->convert_orig = NULL;
args_info->pid_file_arg = NULL;
args_info->pid_file_orig = NULL;
args_info->gzip_output_flag = 0;

}

Expand All @@ -121,7 +118,6 @@ void init_args_info(struct gengetopt_args_info *args_info)
args_info->bandwidth_help = gengetopt_args_info_help[8] ;
args_info->convert_help = gengetopt_args_info_help[9] ;
args_info->pid_file_help = gengetopt_args_info_help[10] ;
args_info->gzip_output_help = gengetopt_args_info_help[11] ;

}

Expand Down Expand Up @@ -263,8 +259,6 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
write_into_file(outfile, "convert", args_info->convert_orig, 0);
if (args_info->pid_file_given)
write_into_file(outfile, "pid-file", args_info->pid_file_orig, 0);
if (args_info->gzip_output_given)
write_into_file(outfile, "gzip-output", 0, 0 );


i = EXIT_SUCCESS;
Expand Down Expand Up @@ -530,7 +524,6 @@ cmdline_parser_internal (
{ "bandwidth", 0, NULL, 'b' },
{ "convert", 1, NULL, 'r' },
{ "pid-file", 1, NULL, 'p' },
{ "gzip-output", 0, NULL, 'z' },
{ 0, 0, 0, 0 }
};

Expand Down Expand Up @@ -650,16 +643,6 @@ cmdline_parser_internal (
goto failure;

break;
case 'z': /* Compress output with gzip before sending. */


if (update_arg((void *)&(args_info->gzip_output_flag), 0, &(args_info->gzip_output_given),
&(local_args_info.gzip_output_given), optarg, 0, 0, ARG_FLAG,
check_ambiguity, override, 1, 0, "gzip-output", 'z',
additional_error))
goto failure;

break;

case 0: /* Long option with no short option */
case '?': /* Invalid option. */
Expand Down
2 changes: 0 additions & 2 deletions gmond/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ struct gengetopt_args_info
char * pid_file_arg; /**< @brief Write process-id to file. */
char * pid_file_orig; /**< @brief Write process-id to file original value given at command line. */
const char *pid_file_help; /**< @brief Write process-id to file help description. */
unsigned int gzip_output_flag; /**< @brief Compress output with gzip before sending (default=off). */
const char *gzip_output_help; /**< @brief Compress output with gzip before sending help description. */

unsigned int help_given ; /**< @brief Whether help was given. */
unsigned int version_given ; /**< @brief Whether version was given. */
Expand Down
21 changes: 13 additions & 8 deletions gmond/gmond.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ struct Ganglia_channel {
Ganglia_channel_types type;
Ganglia_acl *acl;
int timeout;
int gzip_output;
};
typedef struct Ganglia_channel Ganglia_channel;

Expand Down Expand Up @@ -858,7 +859,7 @@ setup_listen_channels_pollset( void )
{
cfg_t *tcp_accept_channel = cfg_getnsec( config_file, "tcp_accept_channel", i);
char *bindaddr, *interface, *family;
int port, timeout;
int port, timeout, gzip_output;
apr_socket_t *socket = NULL;
apr_pollfd_t socket_pollfd;
apr_pool_t *pool = NULL;
Expand All @@ -869,9 +870,10 @@ setup_listen_channels_pollset( void )
interface = cfg_getstr( tcp_accept_channel, "interface");
timeout = cfg_getint( tcp_accept_channel, "timeout");
family = cfg_getstr( tcp_accept_channel, "family");
gzip_output = cfg_getbool( tcp_accept_channel, "gzip_output");

debug_msg("tcp_accept_channel bind=%s port=%d",
bindaddr? bindaddr: "NULL", port);
debug_msg("tcp_accept_channel bind=%s port=%d gzip_output=%d",
bindaddr? bindaddr: "NULL", port, gzip_output);

/* Create a subpool context */
apr_pool_create(&pool, global_context);
Expand All @@ -880,7 +882,7 @@ setup_listen_channels_pollset( void )

/* Create the socket for the channel, blocking w/timeout */
socket = create_tcp_server(pool, sock_family, port, bindaddr,
interface, 1);
interface, 1, gzip_output);
if(!socket)
{
err_msg("Unable to create tcp_accept_channel. Exiting.\n");
Expand All @@ -906,6 +908,9 @@ setup_listen_channels_pollset( void )
/* Save the timeout for this socket */
channel->timeout = timeout;

// Does channel support gzip
channel->gzip_output = gzip_output;

/* Save the ACL information */
channel->acl = Ganglia_acl_create( tcp_accept_channel, pool );

Expand Down Expand Up @@ -1614,7 +1619,7 @@ zstream_new()
}

static apr_status_t
socket_flush( apr_socket_t *client )
socket_flush( apr_socket_t *client, int gzip_output )
{
char outputbuffer[2048];
const int outputlen = sizeof(outputbuffer);
Expand All @@ -1623,7 +1628,7 @@ socket_flush( apr_socket_t *client )
apr_size_t wlen;
z_stream *strm;

if (!args_info.gzip_output_flag)
if ( !gzip_output )
{
return APR_SUCCESS;
}
Expand Down Expand Up @@ -1972,7 +1977,7 @@ process_tcp_accept_channel(const apr_pollfd_t *desc, apr_time_t now)
if(Ganglia_acl_action( channel->acl, remotesa ) != GANGLIA_ACCESS_ALLOW)
goto close_accept_socket;

if (args_info.gzip_output_flag)
if ( channel->gzip_output )
{
z_stream *strm = zstream_new();
if (strm == NULL)
Expand Down Expand Up @@ -2053,7 +2058,7 @@ process_tcp_accept_channel(const apr_pollfd_t *desc, apr_time_t now)
/* Close the CLUSTER and GANGLIA_XML tags */
print_xml_footer(client);

status = socket_flush( client );
status = socket_flush( client, channel->gzip_output );
if (status != APR_SUCCESS)
{
debug_msg("failed to finish compressing stream; returned '%d'",status);
Expand Down
2 changes: 1 addition & 1 deletion lib/apr_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ create_udp_server(apr_pool_t *context, int32_t family, apr_port_t port,

apr_socket_t *
create_tcp_server(apr_pool_t *context, int32_t family, apr_port_t port,
char *bind_addr, char *interface, int blocking)
char *bind_addr, char *interface, int blocking, int32_t gzip_output)
{
apr_socket_t *sock = create_net_server(context, family, SOCK_STREAM, port,
bind_addr, blocking);
Expand Down
2 changes: 1 addition & 1 deletion lib/apr_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ create_mcast_server(apr_pool_t *context, int32_t family, char *mcast_ip, apr_por

apr_socket_t *
create_tcp_server(apr_pool_t *context, int32_t family, apr_port_t port, char
*bind, char *interface, int blocking);
*bind, char *interface, int blocking, int32_t gzip_output);

#endif
11 changes: 11 additions & 0 deletions lib/default_conf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ globals {\n\
host_tmax = 20 /*secs */\n\
cleanup_threshold = 300 /*secs */\n\
gexec = no\n\
# By default gmond will use reverse DNS resolution when displaying your hostname\n\
# Uncommeting following value will override that value.\n\
# override_hostname = \"mywebserver.domain.com\"\n\
# If you are not using multicast this value should be set to something other than 0.\n\
# Otherwise if you restart aggregator gmond you will get empty graphs. 60 seconds is reasonable\n\
send_metadata_interval = 0 /*secs */\n\
\n\
}\n\
\n\
/*\n\
Expand Down Expand Up @@ -64,12 +70,17 @@ udp_recv_channel {\n\
port = 8649\n\
bind = 239.2.11.71\n\
retry_bind = true\n\
# Size of the UDP buffer. If you are handling lots of metrics you really\n\
# should bump it up to e.g. 10MB or even higher.\n\
# buffer = 10485760\n\
}\n\
\n\
/* You can specify as many tcp_accept_channels as you like to share\n\
an xml description of the state of the cluster */\n\
tcp_accept_channel {\n\
port = 8649\n\
# If you want to gzip XML output\n\
gzip_output = no\n\
}\n\
\n\
"
Expand Down
1 change: 1 addition & 0 deletions lib/libgmond.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static cfg_opt_t tcp_accept_channel_opts[] = {
CFG_SEC("acl", acl_opts, CFGF_NONE),
CFG_INT("timeout", -1, CFGF_NONE),
CFG_STR("family", "inet4", CFGF_NONE),
CFG_BOOL("gzip_output", 0, CFGF_NONE),
CFG_END()
};

Expand Down

0 comments on commit f832366

Please sign in to comment.