This file is indexed.

/usr/share/perl5/Munin/Master/Group.pm is in munin 2.0.25-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package Munin::Master::Group;

use base qw(Munin::Master::GroupRepository);

# $Id$

use warnings;
use strict;

use Carp;
use Munin::Master::Host;

sub new {
    my ($class, $group_name) = @_;

    my $self = {
        group_name => $group_name,
        hosts      => {},
    };

    return bless $self, $class;
}


sub add_attributes {
    my ($self, $attributes) = @_;

    my %valid_attributes = map {$_ => 1} qw(node_order local_address contacts);

    croak "Invalid attributes: " . join(', ', keys %$attributes)
        if grep { !$valid_attributes{$_} } keys %$attributes;

    %$self = (%$self, %$attributes);
}


sub add_host {
    my ($self, $host) = @_;

    $self->{hosts}{$host->{host_name}} = $host;
}


sub give_attributes_to_hosts {
    my ($self) = @_;

    my %not_inheritable = map {$_ => 1} qw(group_name hosts node_order);
    my %attributes = grep { !$not_inheritable{$_} } %$self;

    map { $_->add_attributes_if_not_exists(\%attributes) } values %{$self->{hosts}};

    return 1;
}


sub get_all_hosts {
    my ($self) = @_;

    my @hosts = ();

    for my $group (values %{$self->{groups}}) {
        push @hosts, $group->get_all_hosts;
    }

    push @hosts, values %{$self->{hosts}};

    return @hosts;
}

1;


__END__

=head1 NAME

Munin::Master::Group - Holds information on host groups.

Groups can be nested.

=head1 METHODS

=over

=item B<new>

  my $group = Munin::Master::Group->new($name, $parent);

Constructor.  $name is the name of the group.

=item B<add_attributes>

  $group->add_attributes(\%attrs);

Sets attributes %attrs for the group.  Valid attributes are:

=over 4

=item node_order

Override the order of the hosts within the group.

=item local_address

The local address the update process should bind to when contacting the nodes
in this group.

=item contacts

The contacts for this group.  See L<http://munin-monitoring.org/wiki/HowToContact>.

=back

An exception will be thrown if invalid attributes are provided.

(Full details here: L<http://munin-monitoring.org/wiki/munin.conf#Groupleveldirectives>.)

=item B<add_host>

  $group->add_host($host);

Adds host $host to the group.

=item B<give_attributes_to_hosts>

  $group->give_attributes_to_hosts();

Propagates the attributes of $group to all hosts in the group.  (This does
B<not> apply to hosts belonging to sub-groups.)

=item B<get_all_hosts>

  my @hosts = $group->get_all_hosts();

Returns the list of all hosts associated with this group, including those
belonging to any sub-groups.

=back

=cut
# vim: ts=4 : sw=4 : et