File: munin-node

package info (click to toggle)
munin 2.999.14-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 10,036 kB
  • sloc: perl: 31,052; sh: 12,473; java: 1,924; python: 852; makefile: 336; ruby: 232; awk: 169; xml: 45; sql: 11
file content (250 lines) | stat: -rwxr-xr-x 6,044 bytes parent folder | download
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/usr/bin/perl -T
#
# Copyright (C) 2006-2010 Nicolai Langfeldt
# Copyright (C) 2009-2010 Matthew Boyle
# Copyright (C) 2009 Kjell-Magne Øierud
# Copyright (C) 2004-2006 Tore Anderson
# Copyright (C) 2002-2007 Jimmy Olsen
# Copyright (C) 2002-2004 Audun Ytterdal
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#

use strict;
use warnings;

use Getopt::Long;

use Munin::Common::Defaults;
use Munin::Node::Config;
use Munin::Node::OS;
use Munin::Node::Service;
use Munin::Node::Server;

use English qw(-no_match_vars);

my $servicedir = "$Munin::Common::Defaults::MUNIN_CONFDIR/plugins";
my $sconfdir = "$Munin::Common::Defaults::MUNIN_CONFDIR/plugin-conf.d";
my $conffile = "$Munin::Common::Defaults::MUNIN_CONFDIR/munin-node.conf";
my $DEBUG    = 0;
my $VERBOSE  = 0;
my $PIDEBUG  = 0;
my $paranoia = 0;

sub main
{
    chdir ("/");

    # "Clean" environment to disable taint-checking on the environment. We _know_
    # that the environment is insecure, but we want to let admins shoot themselves
    # in the foot with it, if they want to.
    foreach my $key (keys %ENV) {
        $ENV{$key} =~ /^(.*)$/;
        $ENV{$key} = $1;
    }

    parse_args();

    my $config = Munin::Node::Config->instance();
    $config->parse_config_from_file($conffile);

    $paranoia = $config->{paranoia} if defined $config->{paranoia};

    my $services = Munin::Node::Service->new(
        servicedir => $servicedir,
        defuser    => $config->{defuser},
        defgroup   => $config->{defgroup},
        pidebug    => $PIDEBUG,
        timeout    => $config->{timeout},
    );

    $config->reinitialize({
        %$config,

        services => $services,
        sconfdir => $sconfdir,
        conffile => $conffile,

        DEBUG    => $DEBUG,
        VERBOSE  => $VERBOSE,

        paranoia => $paranoia,
    });

    Munin::Node::Server->run(
        syslog_ident => 'munin-node',
        conf_file    => $conffile,
    );

    return 0;
}


sub parse_args
{
    my @ORIG_ARGV  = @ARGV;

    my $servicedir_cmdline;
    my $sconfdir_cmdline;
    print_usage_and_exit() unless GetOptions(
        "config=s"     => \$conffile,
        "servicedir=s" => \$servicedir_cmdline,
        'sconfdir=s'   => \$sconfdir_cmdline,
        "debug!"       => \$DEBUG,
        "verbose!"     => \$VERBOSE,
        "pidebug!"     => \$PIDEBUG,
        "paranoia!"    => \$paranoia,
        "version"      => \&print_version_and_exit,
        "help"         => \&print_usage_and_exit,
    );

    # We untaint the args brutally, since the sysadm should know what he does
    $servicedir = $1 if defined $servicedir_cmdline && $servicedir_cmdline =~ m/(.*)/;
    $sconfdir   = $1 if defined $sconfdir_cmdline   && $sconfdir_cmdline   =~ m/(.*)/;

    # Reset ARGV (for HUPing)
    @ARGV = @ORIG_ARGV;

    return;
}


sub print_usage_and_exit
{
    require Pod::Usage;
    Pod::Usage::pod2usage(-verbose => 1);
}


sub print_version_and_exit
{
    require Pod::Usage;
    Pod::Usage::pod2usage(
        -verbose => 99,
        -sections => 'VERSION|COPYRIGHT',
    );
}


exit main() unless caller;


1;

__END__

=head1 NAME

munin-node - A daemon to gather information in cooperation with the main
Munin program

=head1 SYNOPSIS

munin-node [--options]

=head1 DESCRIPTION

munin-node is a daemon for reporting statistics on system performance.

It doesn't produce these itself, but instead relies on a number of plugins
which are responsible for gathering the data they require, and
describing how this should be graphed.  In fact, it does little more than
fielding requests from the Munin master, running the appropriate plugins,
and returning the output they produce.

=head1 OPTIONS

=over 5

=item B<< --config <configfile> >>

Use E<lt>fileE<gt> as configuration file. [@@CONFDIR@@/munin-node.conf]

=item B<< --servicedir <dir> >>

Override plugin directory [@@CONFDIR@@/plugins/]

=item B<< --sconfdir <dir> >>

Override plugin configuration directory [@@CONFDIR@@/plugin-conf.d/]

=item B< --[no]paranoia >

Only run plugins owned by root. Check permissions as well. [--noparanoia]

=item B< --help >

View this help message.

=item B< --[no]debug >

View debug messages.  This can be very verbose.

=item B< --[no]verbose >

Be verbose.

=item B< --[no]pidebug >

Plugin debug.  Sets the environment variable MUNIN_DEBUG to 1 so that plugins
may enable debugging. [--nopidebug]

=back

=head1 FILES

    @@CONFDIR@@/munin-node.conf
    @@CONFDIR@@/plugins/*
    @@CONFDIR@@/plugin-conf.d/*
    @@STATEDIR@@/munin-node.pid
    @@LOGDIR@@/munin-node.log

=head1 VERSION

This is munin-node v@@VERSION@@


=head1 AUTHORS

Audun Ytterdal, Jimmy Olsen, and Tore Anderson.

=head1 BUGS

Please see L<http://munin-monitoring.org/report/1>.

=head1 COPYRIGHT

Copyright (C) 2002-2006 Audun Ytterdal, Jimmy Olsen, and Tore Anderson / Linpro AS.

This is free software; see the source for copying conditions. There is
NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

This program is released under the GNU General Public License

=head1 SEE ALSO

For information on configuration options, please refer to the man page for
F<munin-node.conf>.

Many plugins can report whether or not they can reasonably be used on the
node.  C<munin-node-configure> can use this information to help manage
installed plugins.

The network protocol is documented at
L<http://munin-monitoring.org/wiki/network-protocol>

=cut