App::MadEye::Plugin::Agent::Memcached - check Memcached.


App-MadEye documentation Contained in the App-MadEye distribution.

Index


Code Index:

NAME

Top

App::MadEye::Plugin::Agent::Memcached - check Memcached.

SCHEMA

Top

    type: map
    mapping:
        target:
            type: seq
            required: yes
            sequence:
                - type: str
        port:
            required: no
            type: int
        timeout:
            required: no
            type: int
        namespace:
            required: no
            type: str

AUTHOR

Top

Keiji Yoshimi

SEE ALSO

Top

App::MadEye, Cache::Memcached::Fast


App-MadEye documentation Contained in the App-MadEye distribution.

package App::MadEye::Plugin::Agent::Memcached;
use strict;
use warnings;
use Cache::Memcached::Fast;
use App::MadEye::Plugin::Agent::Base;

sub is_dead {
    my ($self, $host) = @_;

    my $conf    = $self->config->{config};
    my $port    = $conf->{port} || 11211;
    my $timeout = $conf->{timeout} || 1;
    my $namespace = $conf->{namespace} || 'madeye';

    my $sock = Cache::Memcached::Fast->new({
        servers => ["$host:$port"],
        namespace => $namespace,
        connect_timeout => $timeout,
    });

    $sock->set($host, 1) or
        return "Can't set data";
    return "Can't get data" unless $sock->get($host);

    return; # success!!
}

1;
__END__