"Fossies" - the Fresh Open Source Software Archive

Member "munin-2.0.52/master/_bin/munin-update.in" (20 Nov 2019, 4885 Bytes) of package /linux/misc/munin-2.0.52.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!@@PERL@@
    2 # -*- cperl -*-
    3 
    4 use warnings;
    5 use strict;
    6 
    7 # $Id$
    8 
    9 use English qw(-no_match_vars);
   10 use Getopt::Long;
   11 use Pod::Usage;
   12 use Log::Log4perl qw(:easy);
   13 
   14 use Munin::Master::Update;
   15 use Munin::Master::Logger;
   16 use Munin::Master::Config;
   17 use Munin::Master::Utils;
   18 
   19 
   20 # TODO
   21 #
   22 # - Include data from Munin::Master::Config in config dump?
   23 # - nested groups
   24 
   25 Getopt::Long::Configure(qw(auto_help));
   26 
   27 my $globconfig = Munin::Master::Config->instance();
   28 my $config = $globconfig->{'config'};
   29 
   30 sub main {
   31     exit_if_run_by_super_user();
   32 
   33     configure();
   34 
   35     logger_open($config->{'logdir'});
   36     logger_debug() if $config->{debug};
   37 
   38     my $update = Munin::Master::Update->new();
   39     $update->run();
   40 
   41     return 0;
   42 }
   43 
   44 
   45 sub configure {
   46     my %args = parse_args();
   47 
   48     # Uses default file if config_file is not defined by arguments.
   49     $config->parse_config_from_file($args{config_file});
   50 
   51     if (defined $config->{'includedir'}) {
   52 	my $dirname = $config->{'includedir'};
   53 
   54 	my $DIR;
   55 	opendir($DIR, $dirname) or
   56 	    WARN "[Warning] Could not open includedir directory $dirname: $OS_ERROR\n";
   57 	my @files = grep { ! /^\.|~$/ } readdir($DIR);
   58 	closedir($DIR);
   59 
   60 	@files = map { $_ = $dirname.'/'.$_; } (sort @files);
   61 
   62 	foreach my $f (@files) {
   63 	    $config->parse_config_from_file($f);
   64 	}
   65     }
   66 
   67     # Arguments overrides settings from config file.  Note that
   68     # this only handles settings that are on the base level, not
   69     # anything within groups or hosts.
   70     $config->set(\%args);
   71 }
   72 
   73 
   74 sub parse_args {
   75     my $do_usage = 0;
   76     my $do_version = 0;
   77 
   78     my %args = (
   79         "version" => \&print_version_and_exit,
   80     );
   81 
   82     GetOptions (
   83         \%args, 
   84         "config_file=s",
   85         "debug!",
   86         "fork!",
   87         "host=s@",
   88         "service=s@",
   89         "timeout=s",
   90         "version!",
   91     ) or pod2usage(1);
   92 
   93     delete $args{version};
   94 
   95     $args{limit_hosts} = { map { $_ => 1 } @{$args{host}} };
   96     delete $args{host};
   97 
   98     $args{limit_services} = { map { $_ => 1 } @{$args{service}} };;
   99     delete $args{service};
  100 
  101     return %args;
  102 }
  103 
  104 
  105 exit main() unless caller;
  106 
  107 
  108 1;
  109 
  110 __END__
  111 
  112 =encoding utf8
  113 
  114 =head1 NAME
  115 
  116 munin-update - A program to gather data from machines running munin-node
  117 
  118 =head1 SYNOPSIS
  119 
  120 munin-update [options]
  121 
  122  Options:
  123      --config_file=<file>    Use <file> as configuration file. 
  124      --[no]debug             Enable [or disable] debug messages. [--nodebug]
  125      --[no]fork              Query hosts in parallel (--fork), or
  126                              sequentially (--nofork). [--fork]
  127      --host <host>	     Limit graphed hosts to <host>. Multiple --host 
  128                              options may be supplied.
  129      --service <service>     Limit graphed services to <service>. Multiple
  130  			     --service options may be supplied.
  131      --timeout=<seconds>     TCP timeout when talking to clients. [$timeout]
  132      --help                  View this message.
  133      --version               View version information.
  134 
  135 
  136 =head1 OPTIONS
  137 
  138 =over 5
  139 
  140 =item B<< --config_file=<file> >>
  141 
  142 Use E<lt>fileE<gt> as the configuration file. [@@CONFDIR@@/munin.conf]
  143 
  144 =item B<< --[no]debug >>
  145 
  146 If set, log debug messages. [--nodebug]
  147 
  148 =item B<< --[no]fork >>
  149 
  150 If set, will fork off one process for each host. [--fork]
  151 
  152 =item B<< --host <host> >>
  153 
  154 Limit fetched data to those from E<lt>host<gt>. Multiple --host
  155 options may be supplied. [unset]
  156 
  157 =item B<< --service <service> >>
  158 
  159 Limit fetched data to those of E<lt>serviceE<gt>. Multiple --service
  160 options may be supplied. [unset]
  161 
  162 =item B<< --timeout <seconds> >>
  163 
  164 Set the network timeout to <seconds>. [180]
  165 
  166 =item B<< --help >>
  167 
  168 Print the help message then exit.
  169 
  170 =item B<< --version >>
  171 
  172 Print version information then exit.
  173 
  174 =back
  175 
  176 
  177 =head1 DESCRIPTION
  178 
  179 
  180 Munin-update is a part of the package Munin, which is used in
  181 combination with Munin's node.  Munin is a group of programs to gather
  182 data from Munin's nodes, graph them, create html-pages, and optionally
  183 warn Nagios about any off-limit values.
  184 
  185 Munin-update does the gathering. It is usually only used from within
  186 munin-cron.
  187 
  188 It contacts each host's munin-node in turn, gathers data from it, and
  189 stores them in .rrd-files. If necessary, it will create the rrd-files
  190 and the directories to store them in.
  191 
  192 
  193 =head1 FILES
  194 
  195 	@@CONFDIR@@/munin.conf
  196 	@@DBDIR@@/*
  197 	@@LOGDIR@@/munin-update
  198 	@@STATEDIR@@/*
  199 
  200 
  201 =head1 BUGS
  202 
  203 For a list of bugs concerning munin-update, see FIX<point to right
  204 ticket report>.
  205 
  206 Please report bugs in the bug tracker at L<http://munin-monitoring.org/>.
  207 
  208 
  209 =head1 AUTHORS
  210 
  211 The Munin Team. FIX
  212 
  213 
  214 =head1 COPYRIGHT
  215 
  216 Copyright © 2002-2009 Jimmy Olsen, Audun Ytterdal, Tore Andersson, Kjell-Magne Øierud, Linpro AS, Redpill Linpro AS
  217 
  218 This is free software; see the source for copying conditions. There is
  219 NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
  220 PURPOSE.
  221 
  222 This program is released under the GNU General Public License.