App-Unicheck-Modules-MongoDB

 view release on metacpan or  search on metacpan

lib/App/Unicheck/Modules/MongoDB.pm  view on Meta::CPAN

package App::Unicheck::Modules::MongoDB;

use 5.10.0;
use strict;
use warnings FATAL => 'all';
use Moo;
use Getopt::Long qw(GetOptionsFromArray);
use Try::Tiny;
use MongoDB;
use MongoDB::MongoClient;
use JSON;

=head1 NAME

App::Unicheck::Modules::MongoDB - App::Unicheck module to check mongodb servers.

=head1 VERSION

Version 0.03

=cut

our $VERSION = '0.03';


=head1 SYNOPSIS

App::Unicheck::Modules::MongoDB can check mongod reachability.

    # to show available information on parameters run
    unicheck --info MongoDB

=cut

sub run {
    my ($self, $action, @params) = @_;

    $self->$action(@params);
}

=head1 ACTIONS

=head2 reachable

Check if the server is reachable.

    # check default localhost:27017
    unicheck MongoDB reachable

    # check specific host:port
    unicheck MongoDB reachable --host example.com --port 1234

=cut

sub reachable {
    my ($self, @params) = @_;

    my $host = 'localhost';
    my $port = 27017;
    my $format = 'num';

    GetOptionsFromArray([@params],
        'port=i' => \$port,
        'host=s' => \$host,
        'format=s' => \$format,
    );

    my $retval;



( run in 0.817 second using v1.01-cache-2.11-cpan-39bf76dae61 )