Changeset 1251

Show
Ignore:
Timestamp:
11/15/06 23:03:45 (5 years ago)
Author:
janl
Message:
  • Starting to put stuff in Munin::Server

Moving around on files and adapting the makefile

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/janl/Makefile

    r1205 r1251  
    11# Gnu make only.  Seriously. 
     2# 
    23# $Id$ 
    3  
     4
    45# Defaults/paths from this file 
    56include Makefile.config 
     
    910INSTALL          = ./install-sh 
    1011DIR              = $(shell /bin/pwd | sed 's/^.*\///') 
    11 INFILES          = $(shell find . -name '*.in') 
    12 PLUGINS          = $(wildcard node/node.d.$(OSTYPE)/* node/node.d/*) 
     12INFILES          = $(shell find src -type f -print | egrep -v '(/\.svn/|~)') 
     13PLUGINS          = $(wildcard src/node/node.d.$(OSTYPE)/* src/node/node.d/*) 
    1314MANCENTER        = "Munin Documentation" 
    1415MAN8             = node/munin-node node/munin-run \ 
    15                         node/munin-node-configure-snmp \ 
     16                        src/node/munin-node-configure-snmp \ 
    1617                        node/munin-node-configure \ 
    1718                        server/munin-graph server/munin-update \ 
     
    5051                $(INSTALL) -m 0644 "$$p" $(CONFDIR)/templates/ ; \ 
    5152        done 
    52         $(INSTALL) -m 0644 server/logo.png $(CONFDIR)/templates/ 
    53         $(INSTALL) -m 0644 server/style.css $(CONFDIR)/templates/ 
    54         $(INSTALL) -m 0644 server/definitions.html $(CONFDIR)/templates/ 
    55         $(INSTALL) -m 0755 server/VeraMono.ttf $(LIBDIR)/ 
    56         $(INSTALL) -m 0644 resources/favicon.ico $(HTMLDIR)/ 
     53        $(INSTALL) -m 0644 nonsrc/logo.png $(CONFDIR)/templates/ 
     54        $(INSTALL) -m 0644 nonsrc/style.css $(CONFDIR)/templates/ 
     55        $(INSTALL) -m 0644 nonsrc/definitions.html $(CONFDIR)/templates/ 
     56        $(INSTALL) -m 0755 nonsrc/VeraMono.ttf $(LIBDIR)/ 
     57        $(INSTALL) -m 0644 nonsrc/favicon.ico $(HTMLDIR)/ 
    5758        test -f $(HTMLDIR)/.htaccess || $(INSTALL) -m 0644 build/server/munin-htaccess $(HTMLDIR)/.htaccess 
    58         test -f "$(CONFDIR)/munin.conf" || $(INSTALL) -m 0644 build/server/munin.conf $(CONFDIR)/ 
     59        test -f "$(CONFDIR)/munin.conf" || $(INSTALL) -m 0644 build/server/munin.conf $(CONFDIR)/ 
    5960        $(INSTALL) -m 0755 build/server/munin-cron $(BINDIR)/ 
    6061        $(INSTALL) -m 0755 build/server/munin-update $(LIBDIR)/ 
     
    216217        touch build-stamp 
    217218        rm -rf build 
    218         @for file in $(INFILES); do                     \ 
    219                 destname=`echo $$file | sed 's/.in$$//'`;               \ 
    220                 echo Generating build/$$destname..;                     \ 
    221                 mkdir -p build/`dirname $$file`;                        \ 
    222                 sed -e 's|@@PREFIX@@|$(PREFIX)|g'                       \ 
     219        @for file in $(INFILES); do                                     \ 
     220                destname=`echo $$file | sed 's|^src/|build/|'`;         \ 
     221                echo Generating $$destname;                             \ 
     222                mkdir -p `dirname $$destname`;                          \ 
     223                sed -e '1 s|#!/bin/sh|#!$(GOODSH)|'                     \ 
     224                    -e '1 s|#!/bin/bash|#!$(BASH)|'                     \ 
     225                    -e '1 s|#!/usr/bin/perl|#!$(PERL)|'                 \ 
     226                    -e '1 s|#!/usr/bin/env python|#!$(PYTHON)|'         \ 
     227                    -e 's|@@PREFIX@@|$(PREFIX)|g'                       \ 
    223228                    -e 's|@@CONFDIR@@|$(CONFDIR)|g'                     \ 
    224229                    -e 's|@@BINDIR@@|$(BINDIR)|g'                       \ 
     
    245250                    -e 's|@@GOODSH@@|$(GOODSH)|g'                       \ 
    246251                    -e 's|@@BASH@@|$(BASH)|g'                           \ 
    247                     $$file > build/$$destname;                                \ 
     252                    $$file > $$destname;                              \ 
    248253        done 
    249254 
  • people/janl/src/libperl/Munin.pm

    r1249 r1251  
    2121 
    2222use strict; 
    23 use vars qw(@ISA @EXPORT $VERSION $CONFDIR); 
    2423use Exporter; 
     24 
     25use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION $CONFDIR $DEBUG @legalfetch 
     26            @legalconfig @copy_fields); 
    2527 
    2628@ISA = ('Exporter'); 
     
    3335           'munin_runlock', 
    3436           'munin_getlock', 
    35            'munin_readconfig', 
    36            'munin_writeconfig', 
    3737           'munin_delete', 
    3838           'munin_overwrite', 
    39            'munin_config', 
    4039           'munin_draw_field', 
    4140           'munin_get_bool', 
     
    5251           'munin_get_field_order', 
    5352           'munin_get_rrd_filename', 
     53           '$CONFDIR', 
     54           '$DEBUG', 
    5455           ); 
     56 
     57@EXPORT_OK = ''; # qw($CONFDIR); 
     58 
     59$VERSION='@@VERSION@@'; 
     60$CONFDIR='@@CONFDIR@@'; 
    5561 
    5662use RRDs; 
     
    5965use Symbol 'gensym'; 
    6066 
    61 $VERSION='@@VERSION@@'; 
    62 $CONFDIR='@@CONFDIR@@'; 
    63 1; 
    64 __END__ 
    65  
    6667$VERSION = '@@VERSION@@'; 
    6768 
     
    6970my $config = undef; 
    7071 
    71 my $DEBUG=0; 
     72$DEBUG=0; 
    7273my $configfile='@@CONFDIR@@/munin.conf'; 
    7374 
     
    8485                ); 
    8586 
    86  
    8787# Fields to copy when "aliasing" a field 
    88 my @copy_fields    = ("label", "draw", "type", "rrdfile", "fieldname", "info"); 
     88@copy_fields    = ("label", "draw", "type", "rrdfile", "fieldname", "info"); 
    8989 
    9090# Make configuration settings available at runtime. 
    9191my $PREFIX               = '@@PREFIX@@'; 
    9292$ENV{'MUNIN_PREFIX'}     = $PREFIX; 
    93 $CONFDIR              = '@@CONFDIR@@';   # /etc/munin,/etc/opt/munin or such 
     93$CONFDIR                 = '@@CONFDIR@@';   # /etc/munin,/etc/opt/munin or such 
    9494print "CONFDIR: $CONFDIR!\n"; 
    9595$ENV{'MUNIN_CONFDIR'}    = $CONFDIR; 
     
    270270} 
    271271 
    272 sub munin_readconfig { 
    273     my ($conf, $missingok, $corruptok) = @_; 
    274     my $config   = undef; 
    275     my @contents = undef; 
    276  
    277     $conf ||= $configfile; 
    278     if (! -r $conf and ! $missingok) { 
    279                 ::logger ("munin_readconfig: cannot open '$conf'"); 
    280                 return undef; 
    281     } 
    282     if (open (CFG, $conf)) 
    283     { 
    284         @contents = <CFG>; 
    285         close (CFG); 
    286     } 
    287  
    288     $config = &munin_parse_config (\@contents); 
    289  
    290     # Some important defaults before we return... 
    291     $config->{'rundir'} ||= "/tmp/"; 
    292     $config->{'dbdir'}  ||= "/var/lib/munin/"; 
    293     $config->{'logdir'} ||= "/var/log/"; 
    294     $config->{'tmpldir'}||= "/etc/munin/templates/"; 
    295     $config->{'htmldir'}||= "@@HTMLDIR@@/"; 
    296     return ($config); 
    297 } 
    298  
    299 sub munin_parse_config 
    300 { 
    301     my $lines    = shift; 
    302     my $hash     = undef; 
    303     my $prefix   = ""; 
    304     my $prevline = ""; 
    305  
    306     foreach my $line (@{$lines}) 
    307     { 
    308         chomp $line; 
    309 #$line =~ s/(^|[^\\])#.*/$1/g if $line =~ /#/;  # Skip comments... 
    310         if ($line =~ /#/) 
    311         {  
    312             next if ($line =~ /^#/); 
    313             $line =~ s/(^|[^\\])#.*/$1/g; 
    314         } 
    315         next unless ($line =~ /\S/);  # And empty lines... 
    316         if (length $prevline) 
    317         { 
    318             $line = $prevline . $line; 
    319             $prevline = ""; 
    320         } 
    321         if ($line =~ /\\\\$/) 
    322         { 
    323             $line =~ s/\\\\$/\\/; 
    324         } 
    325         elsif ($line =~ /\\$/) 
    326         { 
    327             ($prevline = $line) =~ s/\\$//; 
    328             next; 
    329         } 
    330         $line =~ s/\s+$//g;           # And trailing whitespace... 
    331         $line =~ s/^\s+//g;           # And heading whitespace... 
    332  
    333         if ($line =~ /^\.(\S+)\s+(.+)\s*$/) 
    334         { 
    335             my ($var, $val) = ($1, $2); 
    336             $hash = &munin_set_var_path ($hash, $var, $val); 
    337         } 
    338         elsif ($line =~ /^\s*\[([^\]]*)]\s*$/) 
    339         { 
    340             $prefix = $1; 
    341             if ($prefix =~ /^([^:;]+);([^:;]+)$/) 
    342             { 
    343                 $prefix .= ":"; 
    344             } 
    345             elsif ($prefix =~ /^([^:;]+);$/) 
    346             { 
    347                 $prefix .= ""; 
    348             } 
    349             elsif ($prefix =~ /^([^:;]+);([^:;]+):(.*)$/) 
    350             { 
    351                 $prefix .= "."; 
    352             } 
    353             elsif ($prefix =~ /^([^:;]+)$/) 
    354             { 
    355                 (my $domain = $prefix) =~ s/^[^\.]+\.//; 
    356                 $prefix = "$domain;$prefix:"; 
    357             } 
    358             elsif ($prefix =~ /^([^:;]+):(.*)$/) 
    359             { 
    360                 (my $domain = $prefix) =~ s/^[^\.]+\.//; 
    361                 $prefix = "$domain;$prefix."; 
    362             } 
    363         } 
    364         elsif ($line =~ /^\s*(\S+)\s+(.+)\s*$/) 
    365         { 
    366             my ($var, $val) = ($1, $2); 
    367             $hash = &munin_set_var_path ($hash, "$prefix$var", $val); 
    368         } 
    369         else 
    370         { 
    371             warn "Malformed configuration line \"$line\"."; 
    372         } 
    373     } 
    374  
    375     return $hash; 
    376 } 
    377  
    378 sub munin_get_var_path 
    379 { 
    380     my $hash = shift; 
    381     my $var  = shift; 
    382     my $val  = shift; 
    383  
    384     print "DEBUG: Getting var \"$var\" = \"$val\"\n" if $DEBUG; 
    385     if ($var =~ /^\s*([^;:]+);([^;:]+):(\S+)\s*$/) 
    386     { 
    387         my ($dom, $host, $rest) = ($1, $2, $3); 
    388         my @sp = split (/\./, $rest); 
    389  
    390         if (@sp == 3) 
    391         { 
    392             return $hash->{domain}->{$dom}->{node}->{$host}->{client}->{$sp[0]}->{"$sp[1].$sp[2]"}; 
    393         } 
    394         elsif (@sp == 2) 
    395         { 
    396             return $hash->{domain}->{$dom}->{node}->{$host}->{client}->{$sp[0]}->{$sp[1]}; 
    397         } 
    398         elsif (@sp == 1) 
    399         { 
    400             return $hash->{domain}->{$dom}->{node}->{$host}->{$sp[0]}; 
    401         } 
    402         else 
    403         { 
    404             warn "munin_set_var: Malformatted variable path \"$var\"."; 
    405         } 
    406     } 
    407     elsif ($var =~ /^\s*([^;:]+);([^;:]+)\s*$/) 
    408     { 
    409         my ($dom, $rest) = ($1, $2); 
    410         my @sp = split (/\./, $rest); 
    411  
    412         if (@sp == 1) 
    413         { 
    414             return $hash->{domain}->{$dom}->{$sp[0]}; 
    415         } 
    416         else 
    417         { 
    418             warn "munin_set_var: Malformatted variable path \"$var\"."; 
    419         } 
    420     } 
    421     elsif ($var =~ /^\s*([^;:\.]+)\s*$/) 
    422     { 
    423         return $hash->{$1}; 
    424     } 
    425     else 
    426     { 
    427         warn "munin_set_var: Malformatted variable path \"$var\"."; 
    428     } 
    429  
    430     return undef; 
    431 } 
    432  
    433 sub munin_set_var_path { 
    434     my $hash = shift; 
    435     my $var  = shift; 
    436     my $val  = shift; 
    437  
    438     print "DEBUG: Setting var \"$var\" = \"$val\"\n" if $DEBUG; 
    439     if ($var =~ /^\s*([^;:]+);([^:]+):(\S+)\s*$/) 
    440     { 
    441         my ($dom, $host, $rest) = ($1, $2, $3); 
    442         my @sp = split (/\./, $rest); 
    443  
    444         if (@sp == 3) 
    445         { 
    446             ::logger ("Warning: Unknown option \"$sp[2]\" in \"$dom;$host:$sp[0].$sp[1].$sp[2]\".") 
    447                 unless defined $legal_expanded{$sp[2]}; 
    448             $hash->{domain}->{$dom}->{node}->{$host}->{client}->{$sp[0]}->{"$sp[1].$sp[2]"} = $val; 
    449         } 
    450         elsif (@sp == 2) 
    451         { 
    452             ::logger ("Warning: Unknown option \"$sp[1]\" in \"$dom;$host:$sp[0].$sp[1]\".") 
    453                 unless defined $legal_expanded{$sp[1]}; 
    454             $hash->{domain}->{$dom}->{node}->{$host}->{client}->{$sp[0]}->{$sp[1]} = $val; 
    455         } 
    456         elsif (@sp == 1) 
    457         { 
    458             ::logger ("Warning: Unknown option \"$sp[0]\" in \"$dom;$host:$sp[0]\".") 
    459                 unless defined $legal_expanded{$sp[0]}; 
    460             $hash->{domain}->{$dom}->{node}->{$host}->{$sp[0]} = $val; 
    461         } 
    462         else 
    463         { 
    464             warn "munin_set_var: Malformatted variable path \"$var\"."; 
    465         } 
    466     } 
    467     elsif ($var =~ /^\s*([^;:]+);([^;:]+)\s*$/) 
    468     { 
    469         my ($dom, $rest) = ($1, $2); 
    470         my @sp = split (/\./, $rest); 
    471  
    472         if (@sp == 1) 
    473         { 
    474             ::logger ("Warning: Unknown option \"$sp[0]\" in \"$dom;$sp[0]\".") 
    475                 unless defined $legal_expanded{$sp[0]}; 
    476             $hash->{domain}->{$dom}->{$sp[0]} = $val; 
    477         } 
    478         else 
    479         { 
    480             warn "munin_set_var: Malformatted variable path \"$var\"."; 
    481         } 
    482     } 
    483     elsif ($var =~ /^\s*([^;:\.]+)\s*$/) 
    484     { 
    485         ::logger ("Warning: Unknown option \"$1\" in \"$1\".") 
    486             unless defined $legal_expanded{$1}; 
    487         $hash->{$1} = $val; 
    488     } 
    489     elsif ($var =~ /^\s*([^\.]+)\.([^\.]+)\.([^\.]+)$/) 
    490     { 
    491         ::logger ("Warning: Unknown option \"$1\" in \"$var\".") 
    492             unless defined $legal_expanded{$1}; 
    493         ::logger ("Warning: Unknown option \"$3\" in \"$var\".") 
    494             unless defined $legal_expanded{$3}; 
    495         $hash->{$1}->{$2}->{$3} = $val; 
    496     } 
    497     else 
    498     { 
    499         warn "munin_set_var: Malformatted variable path \"$var\"."; 
    500     } 
    501  
    502     return $hash; 
    503 } 
    504  
    505 sub munin_writeconfig_loop { 
    506     my ($data,$fh,$pre) = @_; 
    507     $pre |= ""; 
    508  
    509     # Write datafile 
    510     foreach my $a (keys %{$data}) 
    511     { 
    512         if (ref ($data->{$a}) eq "HASH") 
    513         { 
    514             if ($a eq "domain" or $a eq "node" or $a eq "client") 
    515             { 
    516                 &munin_writeconfig_loop ($data->{$a}, $fh, "$pre"); 
    517             } 
    518             elsif ($a eq "contact" and $pre eq "") 
    519             { 
    520                 &munin_writeconfig_loop ($data->{$a}, $fh, "contact."); 
    521             } 
    522             else 
    523             { 
    524                 my $lpre = $pre; 
    525                 if ($lpre eq "") 
    526                 { 
    527                     $lpre = $a.";"; 
    528                 } 
    529                 elsif ($lpre =~ /;$/) 
    530                 { 
    531                     $lpre .= $a.":"; 
    532                 } 
    533                 else 
    534                 { 
    535                     $lpre .= $a."."; 
    536                 } 
    537                 &munin_writeconfig_loop ($data->{$a}, $fh, "$lpre"); 
    538             } 
    539         } 
    540         elsif (defined $data->{$a} and length $data->{$a}) 
    541         { 
    542             next if "$pre$a" eq "version"; # Handled separately 
    543             print "Writing: $pre$a $data->{$a}\n" if $DEBUG; 
    544             if ($data->{$a} =~ /\\$/) 
    545             { # Backslash as last char has special meaning. Avoid it. 
    546                 print $fh "$pre$a $data->{$a}\\\n";  
    547             } else { 
    548                 print $fh "$pre$a $data->{$a}\n"; 
    549             } 
    550         } 
    551     } 
    552 } 
    553 sub munin_writeconfig { 
    554     my ($datafilename,$data,$fh) = @_; 
    555 #   my $datafile = new Config::General(); 
    556 #   $datafile->save_file($datafilename,$data); 
    557  
    558     if (!defined $fh) 
    559     { 
    560         $fh = gensym(); 
    561         unless (open ($fh, ">$datafilename")) 
    562         { 
    563             die "Fatal error: Could not open \"$datafilename\" for writing: $!"; 
    564         } 
    565     } 
    566  
    567     # Write version 
    568     print $fh "version $VERSION\n"; 
    569     # Write datafile 
    570     &munin_writeconfig_loop ($data, $fh, ""); 
    571      
    572     if (defined $fh) 
    573     { 
    574         print "DEBUG: Closing filehandle \"$datafilename\"...\n" if $DEBUG; 
    575         close ($fh); 
    576     } 
    577 } 
    578      
    579 sub munin_config { 
    580     my $conffile = shift; 
    581     $config = shift; 
    582     $conffile ||= $configfile; 
    583     $config = &munin_readconfig ($conffile); 
    584     ::logger_open ($config->{logdir}); 
    585     my $data = &munin_readconfig("$config->{dbdir}/datafile", 1, 1); 
    586      
    587     $data = &munin_overwrite($data,$config); 
    588     return ($data); 
    589 } 
    590272 
    591273sub munin_get_picture_filename { 
  • people/janl/src/libperl/Munin/Server.pm

    r1247 r1251  
    33use strict; 
    44use RRDs; 
    5 use Munin; 
    6 use vars qw($configfile @legal %legal_expanded @copy_fields); 
     5 
     6use Exporter; 
     7 
     8use vars qw($configfile @legal %legal_expanded @copy_fields @ISA 
     9            @EXPORT $VERSION); 
     10 
     11@ISA = qw(Munin Exporter); 
     12 
     13@EXPORT= qw($configfile @legal %legal_expanded @copy_fields 
     14            munin_readconfig munin_parse_config 
     15           ); 
    716 
    817$configfile='@@CONFDIR@@/munin.conf'; 
    918 
    10 @legal = ("tmpldir", "ncsa", "ncsa_server", "ncsa_config", "rundir", 
    11         "dbdir", "logdir", "htmldir", "include", "domain_order", "node_order", 
    12         "graph_sources", "fork", "special_stack", "special_sum", 
    13         "stack", "sum", "address", "htaccess", "warn", 
    14         "use_default_name", "use_node_name", "port", "graph_noscale", 
    15         "nsca", "nsca_server", "nsca_config", "extinfo", "fetch_data", 
    16         "filename", "max_processes", "nagios", "info", "graph_info", 
    17         "graph_category", "graph_strategy", "graph_width", 
    18         "graph_height", "graph_sums", "local_address", "compare", 
    19         "text", "command", "contact", "contacts",  "max_messages", 
    20         "always_send", "notify_alias", "line", "state", "graph_period", 
    21         "cgiurl_graph", "cgiurl", "tls", "service_order", "category_order", 
    22         "version", "tls_certificate", "tls_private_key", "tls_pem", 
    23         "tls_verify_certificate", "tls_verify_depth", "graph_data_size", 
    24          
    25     ); 
     19@legal = qw( 
     20            tmpldir ncsa ncsa_server ncsa_config rundir dbdir logdir 
     21            htmldir include domain_order node_order graph_sources fork 
     22            special_stack special_sum stack sum address htaccess warn 
     23            use_default_name use_node_name port graph_noscale nsca 
     24            nsca_server nsca_config extinfo fetch_data filename 
     25            max_processes nagios info graph_info graph_category 
     26            graph_strategy graph_width graph_height graph_sums 
     27            local_address compare text command contact contacts 
     28            max_messages always_send notify_alias line state 
     29            graph_period cgiurl_graph cgiurl tls service_order 
     30            category_order version tls_certificate tls_private_key 
     31            tls_pem tls_verify_certificate tls_verify_depth 
     32            graph_data_size 
     33           ); 
    2634 
    2735push(@legal,@Munin::legalfetch,@Munin::legalconfig); 
    2836 
     37$VERSION='@@VERSION@@'; 
    2938 
    3039%legal_expanded = map { $_ => 1 } @legal; 
     
    5261 
    5362    # Some important defaults before we return... 
    54     $config->{'rundir'} ||= "/tmp/"
    55     $config->{'dbdir'}  ||= "/var/lib/munin/"
    56     $config->{'logdir'} ||= "/var/log/"
    57     $config->{'tmpldir'}||= "/etc/munin/templates/"
    58     $config->{'htmldir'}||= "@@HTMLDIR@@/"
     63    $config->{'rundir'} ||= '/tmp/'
     64    $config->{'dbdir'}  ||= '@@DBDIR@@/'
     65    $config->{'logdir'} ||= '@@LOGDIR@@/'
     66    $config->{'tmpldir'}||= '@@CONFDIR@@/templates/'
     67    $config->{'htmldir'}||= '@@HTMLDIR@@/'
    5968    return ($config); 
    6069} 
    6170 
    62 sub munin_parse_config 
    63 
     71sub munin_parse_config { 
    6472    my $lines    = shift; 
    6573    my $hash     = undef; 
     
    6775    my $prevline = ""; 
    6876 
    69     foreach my $line (@{$lines}) 
    70     { 
     77    foreach my $line (@{$lines}) { 
    7178        chomp $line; 
    7279#$line =~ s/(^|[^\\])#.*/$1/g if $line =~ /#/;  # Skip comments... 
    73         if ($line =~ /#/) 
    74         {  
     80        if ($line =~ /#/) { 
    7581            next if ($line =~ /^#/); 
    7682            $line =~ s/(^|[^\\])#.*/$1/g; 
    7783        } 
    7884        next unless ($line =~ /\S/);  # And empty lines... 
    79         if (length $prevline) 
    80         { 
     85        if (length $prevline) { 
    8186            $line = $prevline . $line; 
    8287            $prevline = ""; 
    8388        } 
    84         if ($line =~ /\\\\$/) 
    85         { 
     89        if ($line =~ /\\\\$/) { 
    8690            $line =~ s/\\\\$/\\/; 
    87         } 
    88         elsif ($line =~ /\\$/) 
    89         { 
     91        } elsif ($line =~ /\\$/) { 
    9092            ($prevline = $line) =~ s/\\$//; 
    9193            next; 
     
    9496        $line =~ s/^\s+//g;           # And heading whitespace... 
    9597 
    96         if ($line =~ /^\.(\S+)\s+(.+)\s*$/) 
    97         { 
     98        if ($line =~ /^\.(\S+)\s+(.+)\s*$/) { 
    9899            my ($var, $val) = ($1, $2); 
    99100            $hash = &munin_set_var_path ($hash, $var, $val); 
    100         } 
    101         elsif ($line =~ /^\s*\[([^\]]*)]\s*$/) 
    102         { 
     101        } elsif ($line =~ /^\s*\[([^\]]*)]\s*$/) { 
    103102            $prefix = $1; 
    104             if ($prefix =~ /^([^:;]+);([^:;]+)$/) 
    105             { 
     103            if ($prefix =~ /^([^:;]+);([^:;]+)$/) { 
    106104                $prefix .= ":"; 
    107             } 
    108             elsif ($prefix =~ /^([^:;]+);$/) 
    109             { 
     105            } elsif ($prefix =~ /^([^:;]+);$/) { 
    110106                $prefix .= ""; 
    111             } 
    112             elsif ($prefix =~ /^([^:;]+);([^:;]+):(.*)$/) 
    113             { 
     107            } elsif ($prefix =~ /^([^:;]+);([^:;]+):(.*)$/) { 
    114108                $prefix .= "."; 
    115             } 
    116             elsif ($prefix =~ /^([^:;]+)$/) 
    117             { 
     109            } elsif ($prefix =~ /^([^:;]+)$/) { 
    118110                (my $domain = $prefix) =~ s/^[^\.]+\.//; 
    119111                $prefix = "$domain;$prefix:"; 
    120             } 
    121             elsif ($prefix =~ /^([^:;]+):(.*)$/) 
    122             { 
     112            } elsif ($prefix =~ /^([^:;]+):(.*)$/) { 
    123113                (my $domain = $prefix) =~ s/^[^\.]+\.//; 
    124114                $prefix = "$domain;$prefix."; 
    125115            } 
    126         } 
    127         elsif ($line =~ /^\s*(\S+)\s+(.+)\s*$/) 
    128         { 
     116        } elsif ($line =~ /^\s*(\S+)\s+(.+)\s*$/) { 
    129117            my ($var, $val) = ($1, $2); 
    130118            $hash = &munin_set_var_path ($hash, "$prefix$var", $val); 
    131         } 
    132         else 
    133         { 
     119        } else { 
    134120            warn "Malformed configuration line \"$line\"."; 
    135121        } 
     
    145131    my $val  = shift; 
    146132 
    147     print "DEBUG: Getting var \"$var\" = \"$val\"\n" if $DEBUG; 
     133    print "DEBUG: Getting var \"$var\" = \"$val\"\n" if $::DEBUG; 
    148134    if ($var =~ /^\s*([^;:]+);([^;:]+):(\S+)\s*$/) 
    149135    { 
     
    199185    my $val  = shift; 
    200186 
    201     print "DEBUG: Setting var \"$var\" = \"$val\"\n" if $DEBUG; 
     187    print "DEBUG: Setting var \"$var\" = \"$val\"\n" if $::DEBUG; 
    202188    if ($var =~ /^\s*([^;:]+);([^:]+):(\S+)\s*$/) 
    203189    { 
     
    304290        { 
    305291            next if "$pre$a" eq "version"; # Handled separately 
    306             print "Writing: $pre$a $data->{$a}\n" if $DEBUG; 
     292            print "Writing: $pre$a $data->{$a}\n" if $::DEBUG; 
    307293            if ($data->{$a} =~ /\\$/) 
    308294            { # Backslash as last char has special meaning. Avoid it. 
     
    314300    } 
    315301} 
     302 
     303 
    316304sub munin_writeconfig { 
    317305    my ($datafilename,$data,$fh) = @_; 
     
    335323    if (defined $fh) 
    336324    { 
    337         print "DEBUG: Closing filehandle \"$datafilename\"...\n" if $DEBUG; 
     325        print "DEBUG: Closing filehandle \"$datafilename\"...\n" 
     326          if $::DEBUG; 
    338327        close ($fh); 
    339328    } 
    340329} 
    341330 
    342 sub munin_config
     331sub munin_config ($$)
    343332    my $conffile = shift; 
    344     $config = shift; 
     333    my $config = shift; 
    345334    $conffile ||= $configfile; 
    346335    $config = &munin_readconfig ($conffile); 
  • people/janl/src/server/munin-update

    r1249 r1251  
    2424 
    2525use strict; 
    26 # use IO::Socket; 
    27 use lib "../build/libperl"; 
     26use IO::Socket; 
     27use lib "../../build/libperl"; 
    2828use Munin; 
    29  
    30 # print "$VERSION"; 
    31 print "$Munin::VERSION\n"; 
    32 print "$Munin::CONFDIR\n"; 
    33  
    34 __END__ 
    35  
     29use Munin::Server; 
    3630use Time::HiRes; 
    3731use RRDs; 
     
    4034use POSIX ":sys_wait_h"; 
    4135use Storable qw(fd_retrieve nstore_fd); 
    42  
    43 print "Confdir: ",$Munin::CONFDIR,"\n"; 
    44 exit 0; 
    4536 
    4637my $DEBUG=0;