This file is indexed.

/usr/share/perl5/Munin/Master/Host.pm is in munin 2.0.33-1.

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
package Munin::Master::Host;

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

# $Id$

use warnings;
use strict;

use Carp;

sub new {
    my ($class, $host_name, $group, $attributes) = @_;

    $attributes ||= {};

    my $self = {
        host_name => $host_name,
        group     => $group,

        port          => 4949,
        update        => 1,
        use_node_name => 0,
        
        %$attributes,
    };

    # "Address" is required but must be lazy about it.
    # die "Attribute 'address' is required for $host_name, config line $.\n" unless $self->{address};

    return bless $self, $class;
}


sub get_full_path {
    # Find the full nested named path of the current host object
    # might one for M::M::Group too and make it recursive instead of
    # "just" iterative but not now.

    my ($self) = @_;

    my $group;
    my @groups = ( $self->{host_name} );

    $group=$self->{group};
    while (defined($group)) {
	unshift(@groups,$group->{group_name});
	$group=$group->{group};
    }

    return join(";",@groups);
}


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

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


sub get_canned_ds_config {
    my ($self, $service, $data_source) = @_;

    # XXX: Could this be done in some sane way?

    my %ds_config;
    my $svc_ds_prefix = "$service.$data_source.";

    for my $svc_ds_prop (keys %$self) {
        if (index($svc_ds_prop, $svc_ds_prefix) == 0) {
            my $prop = substr($svc_ds_prop, length($svc_ds_prefix));
            $ds_config{$prop} = $self->{$svc_ds_prop};
        }
    }

    return \%ds_config;
}

1;


__END__

=head1 NAME

Munin::Master::Host - Holds information on hosts we are interested in
collecting data from. 

=head1 DESCRIPTION

NOTE that a host and a node are not the same thing -- some hosts may
report services for several nodes, for example if they have SNMP plugins
installed.

=head1 METHODS

=over

=item B<new>

  my $host = Munin::Master::Host->new($hostname, $group, \%attrs);

Constructor.  C<$group> is the C<Munin::Master::Group> object this host
belongs to.  Valid attributes include C<port>, C<update>, and
c<use_node_name>.

=item B<get_full_path>

Returns the full nested named path of the host object (eg. "group1;group2;hostname").

=item B<add_attributes_if_not_exists>

  $host->add_attributes_if_not_exists(\%attrs);

Merges the new attributes from %attrs into the host object, without
overwriting any existing   

=item B<get_canned_ds_config>

FIX

=back