AC-Yenta

 view release on metacpan or  search on metacpan

lib/AC/Yenta/Kibitz/Status.pm  view on Meta::CPAN


    return ACPYentaStatusReply->encode({
        status	=> \@peer,
    });
}

################################################################

# do not believe a client that says it is up
# put it on the sceptical queue, and check for ourself
sub update_sceptical {
    my $gpb = shift;
    my $io  = shift;

    return unless $gpb;
    my $c;
    eval {
        $c = ACPYentaStatusRequest->decode( $gpb );
        $c = $c->{myself};
    };
    if(my $e = $@){

lib/AC/Yenta/Kibitz/Status.pm  view on Meta::CPAN

    }

    my $id = $c->{server_id};

    # don't track myself
    return if AC::Yenta::Status->my_server_id() eq $id;

    AC::Yenta::Status->update_sceptical($id, $c, $io);
}

sub update {
    my $gpb = shift;

    return unless $gpb;
    my $c;
    eval {
        $c = ACPYentaStatusReply->decode( $gpb );
    };
    if(my $e = $@){
        problem("cannot decode status data: $e");
        return;

lib/AC/Yenta/Monitor.pm  view on Meta::CPAN

    $d->{timestamp}   = $^T;

    debug("monitor $id is down");

    if( $d->{lastup} < $^T - $OLD_KEEP ){
        debug("monitor $id down too long. removing from report");
        delete $MON{$id};
    }
}

sub update {
    my $id = shift;
    my $gb = shift;	# ACPHeartbeat

    my $up;
    eval {
        $up = ACPHeartBeat->decode( $gb );
        $up->{id} = $id;
    };
    if(my $e = $@){
        problem("cannot decode hb data: $e");

lib/AC/Yenta/NetMon.pm  view on Meta::CPAN

sub init {

    my $natinfo = my_network_info();
    for my $n ( @$natinfo ){
        my $dom = $n->{natdom} || 'public';
        $natdom{ $n->{ipa} } = $dom;
        $lastok{ $dom } = $^T;	# assume everything is working
    }
}

sub update {
    my $io = shift;

    my $ip  = inet_ntoa( (sockaddr_in(getsockname($io->{fd})))[1] );
    my $dom = $natdom{ $ip } || 'public';

    $lastok{$dom} = $^T;
}

sub status_dom {
    my $dom = shift;

lib/AC/Yenta/Status.pm  view on Meta::CPAN

    my $id    = shift;
    my $up    = shift;

    # if( $up->{environment} ne conf_value('environment') ){
    #     verbose("ignoring update from $id - wrong env: $up->{environment}");
    #     return;
    # }
    return 1;
}

sub update_sceptical {
    my $class = shift;
    my $id    = shift;	# ->server_id
    my $up    = shift;
    my $io    = shift;

    return unless $class->_env_ok($id, $up);

    if( $DATA->{allpeer}{$id} ){
        # already known
        delete $DATA->{sceptical}{$id};

lib/AC/Yenta/Status.pm  view on Meta::CPAN

    # only accept updates from the server itself
    # no 3rd party updates. no misconfigured serevrs.
    problem("server misconfigured $id != $io->{peerip}")
      unless grep { inet_atoi($io->{peerip}) == $_->{ipv4}  } @{$up->{ip}};

    $up->{id} = $id;
    delete $up->{lastup};
    $DATA->{sceptical}{$id} = $up;
}

sub update {
    my $class = shift;
    my $id    = shift;	# -> server_id
    my $up    = shift;

    return unless $class->_env_ok($id, $up);

    # only keep it if it is relatively fresh, and valid
    return unless $up->{timestamp} > $^T - $KEEPLOST;
    return unless $up->{status};



( run in 0.348 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )