Changeset 7562

Show
Ignore:
Timestamp:
03/06/08 16:38:31 (5 years ago)
Author:
tokuhirom
Message:

itkz は NoPaste? を使うべき。この時間帯は無視するよ的なルールを策定した。

Location:
lang/perl/App-MadEye/trunk
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/App-MadEye/trunk/config.yaml

    r7560 r7562  
    1010       - http://google.com/ 
    1111 
    12 # - module: Worker::Simple 
     12  - module: Worker::Simple 
     13    config: 
     14      timeout: 1 
     15 
     16# - module: Worker::Gearman 
    1317#   config: 
    14 #     timeout: 4 
    15  
    16   - module: Worker::Gearman 
    17     config: 
    18       fork_num: 3 
    19       gearman_servers: 
    20         - 127.0.0.1 
     18#     fork_num: 3 
     19#     gearman_servers: 
     20#       - 127.0.0.1 
    2121 
    2222# - module: Agent::HTTP 
     
    2828    config: 
    2929      target: ftp.ring.gr.jp 
    30       message: FTP server ready. 
     30      message: FTP server raady. 
     31    rule: 
     32      - module: DateTimeCron 
     33        config: 
     34          crontab: "* 16 * * *" 
     35          type: ignore 
    3136 
    3237# - module: Agent::HTTP 
     
    7984#       - 127.0.0.1:1111 
    8085 
    81   - module: Agent::SMTPTLS 
    82     config: 
    83       timeout: 1 
    84       target: 
    85         - 127.0.0.1 
    86         - 192.168.1.1 
     86# - module: Agent::SMTPTLS 
     87#   config: 
     88#     timeout: 1 
     89#     target: 
     90#       - 127.0.0.1 
     91#       - 192.168.1.1 
    8792 
    8893# - module: Agent::Process 
     
    9297#     pattern: /usr/bin/gearmandaa 
    9398 
    94   - module: Agent::Ping 
    95     config: 
    96       target: 
    97         - 127.0.0.1 
    98         - 192.168.2.3 
     99# - module: Agent::Ping 
     100#   config: 
     101#     target: 
     102#       - 127.0.0.1 
     103#       - 192.168.2.3 
    99104 
    100   - module: Agent::SMTP 
    101     config: 
    102       target: 
    103         - 127.0.0.1 
    104         - 192.168.2.3 
     105# - module: Agent::SMTP 
     106#   config: 
     107#     target: 
     108#       - 127.0.0.1 
     109#       - 192.168.2.3 
    105110 
    106111  - module: Notify::Debug 
  • lang/perl/App-MadEye/trunk/lib/App/MadEye.pm

    r7560 r7562  
    66use Class::Component; 
    77use Params::Validate; 
     8use UNIVERSAL::require; 
    89__PACKAGE__->load_components(qw/Plaggerize Autocall::InjectMethod/); 
    910 
     
    4142    my $args = {@_}; 
    4243 
     44    return unless $self->_should_add_result(target => $args->{target}, plugin => $args->{plugin}); 
     45 
    4346    push @{$self->{results}->{ref $args->{plugin}}}, +{ 
    4447        target  => $args->{target}, 
    4548        message => $args->{message}, 
    46     };  
     49    }; 
     50} 
     51 
     52sub _should_add_result { 
     53    my $self = shift; 
     54    validate( 
     55        @_ => +{ 
     56            plugin => 1, 
     57            target => 1, 
     58        } 
     59    ); 
     60    my $args = {@_}; 
     61 
     62    if ($args->{plugin}->config->{rule}) { 
     63        for my $rule_conf ( @{ $args->{plugin}->config->{rule} } ) { 
     64            my $rule = $self->_load_rule($rule_conf); 
     65            my $ret = $rule->dispatch( 
     66                $self, 
     67                +{ 
     68                    target => $args->{target}, 
     69                } 
     70            ); 
     71            return 0 if $ret; 
     72        } 
     73    } 
     74    return 1; 
     75} 
     76 
     77sub _load_rule { 
     78    my ($self, $rule) = @_; 
     79 
     80    my $class = $rule->{module}; 
     81    if ($class =~ /^\+/) { 
     82        $class =~ s/^\+//; 
     83    } else { 
     84        $class = __PACKAGE__ . '::Rule::' . $class; 
     85    } 
     86    $class->use or die $@; 
     87    return $class->new($rule->{config}); 
    4788} 
    4889