Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ncm-gmond: cleanup and support new configuration options #1136

Merged
merged 2 commits into from Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 0 additions & 17 deletions ncm-gmond/src/main/pan/components/gmond/config-common.pan

This file was deleted.

21 changes: 0 additions & 21 deletions ncm-gmond/src/main/pan/components/gmond/config-rpm.pan

This file was deleted.

11 changes: 2 additions & 9 deletions ncm-gmond/src/main/pan/components/gmond/config.pan
@@ -1,9 +1,2 @@
# ${license-info}
# ${developer-info}
# ${author-info}
# ${build-info}

unique template components/${project.artifactId}/config;

include 'components/${project.artifactId}/config-common';
include 'components/${project.artifactId}/config-rpm';
${componentconfignospma}
"dependencies/pre" ?= list("spma", "accounts");
100 changes: 58 additions & 42 deletions ncm-gmond/src/main/pan/components/gmond/schema.pan 100755 → 100644
@@ -1,107 +1,123 @@
# ${license-info}
# ${developer-info}
# ${author-info}
${componentschema}

declaration template components/gmond/schema;
include 'quattor/types/component';
include 'pan/types';

include 'quattor/schema';

type structure_component_gmond_acl_access = {
type gmond_acl_access = {
"ip" : type_ip
"mask" : long
"action" : string with match(SELF, "allow|deny")
"mask" : long(0..32)
"action" : string with match(SELF, "^(allow|deny)$")
};

type structure_component_gmond_acl = {
"default" : string with match(SELF, "allow|deny")
"access" : structure_component_gmond_acl_access
type gmond_acl = {
"default" : string with match(SELF, "^(allow|deny)$")
"access" : gmond_acl_access
};

type structure_component_gmond_cluster = {
type gmond_cluster = {
"name" ? string = "unspecified"
"owner" ? string = "unspecified"
"latlong" ? string = "unspecified"
"url" ? type_absoluteURI
};

type structure_component_gmond_host = {
type gmond_host = {
"location" : string = "unspecified"
};

type structure_component_gmond_globals = {
type gmond_globals = {
"daemonize" ? boolean = true
"setuid" ? boolean = true
"user" ? string = "nobody"
"debug_level" ? long = 0
"mute" ? boolean = false
"deaf" ? boolean = false
"host_dmax" ? long(0..) = 0
"host_tmax" ? long(0..) = 0
"cleanup_threshold" ? long(0..) = 0
"gexec" ? boolean = false
"send_metadata_interval" ? long(0..) = 0
"module_dir" ? string
"allow_extra_data" ? boolean
"max_udp_msg_len" ? long(0..65536)
};

type structure_component_gmond_udp_send_channel = {
type gmond_udp_send_channel = {
"mcast_join" ? type_ipv4
"mcast_if" ? string
"host" ? type_hostname
"port" : type_port
"ttl" ? long(1..)
"bind" ? type_ipv4
"bind_hostname" ? boolean
} with {
if (is_defined(SELF['bind']) && is_defined(SELF['bind_hostname'])) {
error('bind and bind_hostname are mutually exclusive');
};
true;
};

type structure_component_gmond_udp_recv_channel = {
type gmond_udp_recv_channel = {
"mcast_join" ? type_ipv4
"bind" ? type_ip
"mcast_if" ? string
"port" : type_port
"family" ? string = "inet4" with match(SELF, "inet[46]")
"acl" ? structure_component_gmond_acl
"family" ? string = "inet4" with match(SELF, "^inet[46]$")
"acl" ? gmond_acl
};

type structure_component_gmond_tcp_accept_channel = {
type gmond_tcp_accept_channel = {
"bind" ? type_ip
"port" : type_port
"family" ? string = "inet4" with match(SELF, "inet[46]")
"timeout" ? long = 1000000 # micro seconds
# "interface" ? string # defined but not implemented
"acl" ? structure_component_gmond_acl
"family" ? string = "inet4" with match(SELF, "^inet[46]$")
@{timeout in micro seconds}
"timeout" ? long = 1000000
"acl" ? gmond_acl
};

type structure_component_gmond_metric = {
type gmond_metric = {
"name" : string
"value_threshold" ? double
"title" ? string
};

type structure_component_gmond_collection_group = {
type gmond_collection_group = {
"collect_once" ? boolean
"collect_every" ? long(1..)
"time_threshold" ? long(1..) = 3600
"metric" : structure_component_gmond_metric[]
"metric" : gmond_metric[]
};

type structure_component_gmond_module = {
type gmond_module = {
"name" : string
"language" ? string
"path" ? string
"params" ? string
"param" ? dict
};

type structure_component_gmond = {
type ${project.artifactId}_component = {
include structure_component
"cluster" ? structure_component_gmond_cluster
"host" ? structure_component_gmond_host
"globals" : structure_component_gmond_globals
"udp_send_channel" : structure_component_gmond_udp_send_channel[]
"udp_recv_channel" : structure_component_gmond_udp_recv_channel[]
"tcp_accept_channel": structure_component_gmond_tcp_accept_channel[]
"collection_group" : structure_component_gmond_collection_group[]
"module" ? structure_component_gmond_module[]
"include" ? string[]
"file" : string # location of the configuration file
# differs between Ganglia 3.0 and 3.1
@{Cluster configuration}
"cluster" ? gmond_cluster
@{Host configuration}
"host" ? gmond_host
@{Configuration of gmond}
"globals" : gmond_globals
@{List of UDP channels to send information to.}
"udp_send_channel" : gmond_udp_send_channel[]
@{List of UDP channels to receive information from.}
"udp_recv_channel" : gmond_udp_recv_channel[]
@{List of TCP channels from which information is accepted.}
"tcp_accept_channel": gmond_tcp_accept_channel[]
@{List of collection groups}
"collection_group" : gmond_collection_group[]
@{List of modules}
"module" ? gmond_module[]
@{Optional list of additional files to include.}
"include" ? absolute_file_path[]
@{The location of the configuration file. The correct value differs between
Ganglia 3.0 (/etc/gmond.conf) and 3.1 (/etc/ganglia/gmond.conf).
There is no default value.}
"file" : absolute_file_path
};

bind "/software/components/gmond" = structure_component_gmond;
82 changes: 48 additions & 34 deletions ncm-gmond/src/main/perl/gmond.pm
@@ -1,4 +1,12 @@
#${PMpre} NCM::Component::gmond${PMpost}
#${PMcomponent}

=head1 DESCRIPTION

The I<gmond> component manages Ganglia's gmond daemon.
This daemon collects information at a node and uses multicast to distribute it
over the network.

=cut

use CAF::FileWriter;
use CAF::Service;
Expand All @@ -24,10 +32,10 @@ sub print_acl

for my $i ( @{$cfg->{access}} ) {
print $fh " access {\n",
" ip = $i->{ip}\n",
" mask = $i->{mask}\n",
" action = \"$i->{action}\"\n",
" }\n";
" ip = $i->{ip}\n",
" mask = $i->{mask}\n",
" action = \"$i->{action}\"\n",
" }\n";
}

print $fh " }\n";
Expand Down Expand Up @@ -57,6 +65,8 @@ sub print_host
{
my ($self, $fh, $cfg) = @_;

return unless ($cfg);

print $fh "host {\n location = \"$cfg->{location}\"\n}\n\n";
}

Expand All @@ -65,17 +75,20 @@ sub print_globals
my ($self, $fh, $cfg) = @_;

print $fh "globals {\n";
print $fh " daemonize = ".boolstr($cfg->{daemonize})."\n" if ( $cfg->{daemonize} );
print $fh " setuid = ".boolstr($cfg->{setuid})."\n" if ( $cfg->{setuid} );
print $fh " daemonize = ".boolstr($cfg->{daemonize})."\n" if ( defined $cfg->{daemonize} );
print $fh " setuid = ".boolstr($cfg->{setuid})."\n" if ( defined $cfg->{setuid} );
print $fh " user = $cfg->{user}\n" if ( $cfg->{user} );
print $fh " debug_level = $cfg->{debug_level}\n" if ( $cfg->{debug_level} );
print $fh " mute = ".boolstr($cfg->{mute})."\n" if ( $cfg->{mute} );
print $fh " deaf = ".boolstr($cfg->{deaf})."\n" if ( $cfg->{deaf} );
print $fh " mute = ".boolstr($cfg->{mute})."\n" if ( defined $cfg->{mute} );
print $fh " deaf = ".boolstr($cfg->{deaf})."\n" if ( defined $cfg->{deaf} );
print $fh " host_dmax = $cfg->{host_dmax}\n" if ( $cfg->{host_dmax} );
print $fh " host_tmax = $cfg->{host_tmax}\n" if ( $cfg->{host_tmax} );
print $fh " cleanup_threshold = $cfg->{cleanup_threshold}\n" if ( $cfg->{cleanup_threshold} );
print $fh " gexec = ".boolstr($cfg->{gexec})."\n" if ( $cfg->{gexec} );
print $fh " gexec = ".boolstr($cfg->{gexec})."\n" if ( defined $cfg->{gexec} );
print $fh " send_metadata_interval = $cfg->{send_metadata_interval}\n" if ( $cfg->{send_metadata_interval} );
print $fh " module_dir = $cfg->{module_dir}\n" if ( $cfg->{module_dir} );
print $fh " allow_extra_data = ".boolstr($cfg->{allow_extra_data})."\n" if ( defined $cfg->{allow_extra_data} );
print $fh " max_udp_msg_len = $cfg->{max_udp_msg_len}\n" if ( $cfg->{max_udp_msg_len} );

print $fh "}\n\n";
}
Expand All @@ -89,7 +102,9 @@ sub print_udp_send_channel
print $fh " mcast_join = $i->{mcast_join}\n" if ( $i->{mcast_join} );
print $fh " mcast_if = $i->{mcast_if}\n" if ( $i->{mcast_if} );
print $fh " host = $i->{host}\n" if ( $i->{host} );
print $fh " ttl = $i->{ttl}\n" if ( $i->{ttl} );
print $fh " ttl = $i->{ttl}\n" if ( defined $i->{ttl} );
print $fh " bind = $i->{bind}\n" if ( $i->{bind} );
print $fh " bind_hostname = ".boolstr($i->{bind_hostname})."\n" if ( defined $i->{bind_hostname} );
print $fh "}\n\n";
}
}
Expand Down Expand Up @@ -142,7 +157,7 @@ sub print_collection_group

for my $i ( @{$cfg} ) {
print $fh "collection_group {\n";
print $fh " collect_once = ".boolstr($i->{collect_once})."\n" if ( $i->{collect_once} );
print $fh " collect_once = ".boolstr($i->{collect_once})."\n" if ( defined $i->{collect_once} );
print $fh " collect_every = $i->{collect_every}\n" if ( $i->{collect_every} );
print $fh " time_threshold = $i->{time_threshold}\n" if ( $i->{time_threshold} );

Expand Down Expand Up @@ -185,29 +200,28 @@ sub Configure

# daemon configuration
my $st = $config->getTree($self->prefix());
if ( defined($st) ) {

# Location of the configuration file
my $cfgfile = $st->{file};
my $fh = CAF::FileWriter->new ($cfgfile, mode => 0640, log => $self);

print $fh "# $cfgfile\n# written by ncm-gmond. Do not edit!\n";

$self->print_include($fh, $st->{include});
$self->print_cluster($fh, $st->{cluster});
$self->print_host($fh, $st->{host});
$self->print_globals($fh, $st->{globals});
$self->print_udp_send_channel($fh, $st->{udp_send_channel});
$self->print_udp_recv_channel($fh, $st->{udp_recv_channel});
$self->print_tcp_accept_channel($fh, $st->{tcp_accept_channel});
$self->print_collection_group($fh, $st->{collection_group});
$self->print_module($fh, $st->{module});

if ($fh->close()) {
CAF::Service->new(['gmond'], log => $self)->restart()
};
}

# Location of the configuration file
my $cfgfile = $st->{file};
my $fh = CAF::FileWriter->new ($cfgfile, mode => oct(640), log => $self);

print $fh "# $cfgfile\n# written by ncm-gmond. Do not edit!\n";

$self->print_include($fh, $st->{include});
$self->print_cluster($fh, $st->{cluster});
$self->print_host($fh, $st->{host});
$self->print_globals($fh, $st->{globals});
$self->print_udp_send_channel($fh, $st->{udp_send_channel});
$self->print_udp_recv_channel($fh, $st->{udp_recv_channel});
$self->print_tcp_accept_channel($fh, $st->{tcp_accept_channel});
$self->print_collection_group($fh, $st->{collection_group});
$self->print_module($fh, $st->{module});

if ($fh->close()) {
CAF::Service->new(['gmond'], log => $self)->restart()
};

return 1;
}

1;