Changeset 922

Show
Ignore:
Timestamp:
04/26/05 18:38:09 (7 years ago)
Author:
ilmari
Message:

Added support for summing values from log lines.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r913 r922  
    22 
    33  * Main: Tuned logging. 
     4  * Plugins: generic/loggrep now supports summing values from log lines. 
    45 
    56munin (1.3.2) 
  • trunk/node/node.d/loggrep.in

    r900 r922  
    3030#       regex         - Regex to look for (required) 
    3131#       label         - Label 
     32#       counter       - If set the value captured by the first paren 
     33#                       in the regex is summed instead of coutning lines. 
     34#                       The value is used for the vertical label. 
    3235#       regex_<key>   - Additional regexes 
    3336#       label_<key>   - Additional labels 
     37#       counter_<key> - Additional counters (the value is ignored). 
    3438#       title         - Graph title 
    3539# 
     
    4448my %regex; 
    4549my $logfile = $ENV{logfile}; 
     50my $vlabel = defined $ENV{'counter'} ? $ENV{'counter'} : 'entries'; 
    4651 
    4752(my $name = $0) =~ s|.*/||; 
     
    5358    $regex{'count'}{'label'} = $ENV{'label'} || $ENV{'regex'}; 
    5459    $regex{'count'}{'value'} = 0; 
     60    $regex{'count'}{'counter'} = defined $ENV{'counter'}; 
    5561} 
    5662 
     
    5965    $regex{$key}{'label'} = $ENV{"label_$key"} || $ENV{"regex_$key"}; 
    6066    $regex{$key}{'value'} = 0; 
     67    $regex{$key}{'counter'} = defined $ENV{"counter_$key"}; 
    6168} 
    6269 
     
    6976    print "graph_title $title\n"; 
    7077    print "graph_args --base 1000 -l 0\n"; 
    71     print "graph_vlabel entries / \${graph_period}\n"; 
     78    print "graph_vlabel $vlabel / \${graph_period}\n"; 
    7279    print "graph_category other\n"; 
    7380    for my $key (keys %regex) { 
     
    139146        for my $match (values %regex) { 
    140147            if ($line =~ $match->{'regex'}) { 
    141                 $match->{'value'}++
     148                $match->{'value'} += $match->{'counter'} ? $1 : 1
    142149            } 
    143150        }