Hi, I'm having trouble naming a small module.
This module provides a scoring function based on a given ruleset. It is used to produce a single status out of an aggregate of statuses. The rules for deciding what is the result status can be stated in a very simple mini-language. The parser reads some source code written in that domain-specific language, and returns a code reference. That coderef takes a hash reference with statuses as keys and counts as values, and returns a single string (the "score" or summary). It's not an aggregation module. The hashref is actually the aggregation from some dataset, for which we want to produce a single, summary value. We can then create several rulesets that are applied to various aggregations of our Nagios data, to provide more synthetic indicators. The use case for us is to be able to monitor at a service level, rather than a host level. 5% of servers down from a pool might not be critical, where 10% would. The module is just one of the components used to provide this service level monitoring. * * * The module is currently named "Fleur", but that's more of a working title, as it's going to make it very difficult to find on CPAN. Here's he SYNOPSIS of the module: # create a parser my $parser = Fleur->new( input => [qw( OK WARN CRIT UNKN )], output => [qw( OK WARN CRIT UNKN )], # default: same as input default => 'OK', # default: first item in output ); # generate a scoring function my $score = $parser->parse( << 'CODE' ); %OK > 90%, %CRIT < .1: OK; %CRIT > 50%: CRIT; %CRIT + %WARN > 25%: WARN; UNKN; CODE # OK $status = $score->( { OK => 19, CRIT => 2 } ); # WARN $status = $score->( { OK => 14, CRIT => 6, WARN => 1 } ); # CRIT $status = $score->( { OK => 8, CRIT => 11, WARN => 1, UNKN => 1 } ); # UNKN $status = $score->( { OK => 18, CRIT => 2, WARN => 1 } ); The $score subroutine would be compiled from the following source code (generated from the lines above): sub { my %count = %{ shift() }; my $total = 0; $total += $_ for values %count; my %percent = $total ? map +( $_ => $count{$_} / $total ), keys %count : map +( $_ => 0 ), keys %count; return 'OK' if $percent{OK} > 0.9 && $percent{CRIT} < .1; return 'CRIT' if $percent{CRIT} > 0.5; return 'WARN' if $percent{CRIT} > 0.25; return 'UNKN'; } Without the %-prefix, names are translated to absolute values from %count. Thanks for your time and ideas, -- Philippe Bruhat (BooK) Food and life were both meant to be shared with others. (Moral from Groo The Wanderer #119 (Epic))