| 1 | package App::MadEye::Plugin::Agent::POP3S; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use App::MadEye::Plugin::Agent::Base; | ||
| 5 | use IO::Socket qw(SOCK_STREAM); | ||
| 6 | use IO::Socket::SSL; | ||
| 7 | |||
| 8 | sub is_dead { | ||
| 9 | my ($self, $host) = @_; | ||
| 10 | |||
| 11 | my $conf = $self->config->{config}; | ||
| 12 | my $port = $conf->{port} or die "missing port"; | ||
| 13 | my $timeout = $conf->{timeout} || 10; | ||
| 14 | |||
| 15 | eval { | ||
| 16 | my $sock = IO::Socket::SSL->new( | ||
| 17 | PeerAddr => $host, | ||
| 18 | PeerPort => $port, | ||
| 19 | Proto => 'tcp', | ||
| 20 | Type => SOCK_STREAM, | ||
| 21 | Timeout => $timeout, | ||
| 22 | ) or die "can't connect pop3s $host:$port $!\n"; | ||
| 23 | }; | ||
| 24 | |||
| 25 | if ( $@ ) { | ||
| 26 | return "pop3d is dead $@"; | ||
| 27 | } else { | ||
| 28 | return 0; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; | ||
| 33 | __END__ |