The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Monitis - Monitis.com API Perl interface

VERSION

This document describes Monitis version 0.8_3

SYNOPSIS

    use Monitis;

    my $api =
      Monitis->new(sekret_key => $SECRET_KEY, api_key => $API_KEY);

    # Create subaccount, see Monitis::SubAccounts
    my $response = $api->sub_accounts->add(
        firstName => 'John',
        lastName  => 'Smith',
        email     => 'john@smith.com',
        password  => '****',
        group     => 'test user'
    );

    die "Failed to create account: $response->{status}"
      unless $response->{status} eq 'ok';

    # Add memory monitor, see Monitis::Memory
    $response = $api->memory->add(
        agentkey      => 'test-agent',
        name          => 'memory_monitor',
        tag           => 'test_from_api',
        platform      => 'LINUX',
        freeLimit     => 100,
        freeSwapLimit => 500,
        bufferedLimit => 500,
        cachedLimit   => 500
    );

    die "Failed to create memory monitor: $response->{status}"
      unless $response->{status} eq 'ok';

DESCRIPTION

This library provides interface to Monitis.com API

ATTRIBUTES

Monitis implements following attributes:

api_url

Monitis API URL. May vary for different calls. See 'API URL' section of corresponding API manual.

ua

UserAgent that Monitis uses as transport.

json

JSON decoder.

api_key

Monitis API key.

secret_key

Monitis API secret.

auth_token

Monitis API auth_token.

Read/write. If no token set, but secret_key and api_key are set, Monitis try to get auth_token from Monitis API.

auth_token auto-updates token, when it expires (after 24 hours).

token_ttl

Auth token time-to-live in seconds. 24 hours by default.

context

Context of execution

METHODS

Monitis implements following methods:

new

    my $monitis = Monitis->new(sekret_key => '***', api_key => '***');

Construct a new Monitis instance.

context methods

sub_accounts layout contacts predefined_monitors external_monitors

itnernal_monitors agents cpu memory drive process load_average http ping

transaction_monitors full_page_load_monitors

visitor_trackers cloud_instances

This methods switch API context to corresponding section. There's map of available contexts and corresponding packages:

    sub_accounts            =>    Monitis::SubAccounts
    layout                  =>    Monitis::Layout
    contacts                =>    Monitis::Contacts
    predefined_monitors     =>    Monitis::PredefinedMonitors
    external_monitors       =>    Monitis::ExternalMonitors
    internal_monitors       =>    Monitis::InternalMonitors
    agents                  =>    Monitis::Agents
    cpu                     =>    Monitis::CPU
    memory                  =>    Monitis::Memory
    drive                   =>    Monitis::Drive
    process                 =>    Monitis::Process
    load_average            =>    Monitis::LoadAverage
    http                    =>    Monitis::HTTP
    ping                    =>    Monitis::Ping
    transaction_monitors    =>    Monitis::TransactionMonitors
    custom_monitors         =>    Monitis::CustomMonitors
    full_page_load_monitors =>    Monitis::FullPageLoadMonitors
    visitor_trackers        =>    Monitis::VisitorTrackers
    cloud_instances         =>    Monitis::CloudInstances

Please refer to documentation of corresponding package (see "SEE ALSO") and to Monitis API manual.

api_get

    my $response =
      $monitis->api_get(actionName => [param1 => 'value', param2 => 'value']);

Executes action at Monitis.com API and returns result.

Returns parsed JSON: array or hash, depending on server response.

Requires api_key to be set.

api_post

    my $response = $monitis->api_post(
        actionName => [param1 => 'value', param2 => 'value']);

Executes action at Monitis.com API and returns result.

Returns parsed JSON: array or hash, depending on server response.

Requires api_key and secret_key to be set.

parse_response

    my $json = $monitis->parse_response($response);

Takes one argument: HTTP::Response.

Returns decoded JSON (hashref or arrayref) of response content.

build_get_request

    my $request = $monitis->build_get_request(
        actionName => [param1 => 'value', param2 => 'value']);

Prepares HTTP GET request to Monitis API with provided parameters.

Returns HTTP::Request object.

build_post_request

    my $request = $monitis->build_post_request(
        actionName => [param1 => 'value', param2 => 'value']);

Prepares HTTP POST request to Monitis API with provided parameters.

Returns HTTP::Request object.

prepare_params

    my $params = $monitis->prepare_params(\@params, \@mandatory, \@optional);
    my $params = $monitis->prepare_params(\@params, \@mandatory);

Checks for mandatory and removes wrong parameters.

Returns arrayref.

checksum

    my $checksum = $monitis->checksum(\@params);
    my $checksum =
      $monitis->checksum([param1 => 'value1', param2 => 'value2']);

Produces checksum of list of parameters.

Requires api_secret to be set.

SEE ALSO

Monitis::SubAccounts Monitis::Layout Monitis::Contacts Monitis::PredefinedMonitors Monitis::ExternalMonitors Monitis::InternalMonitors Monitis::Agents Monitis::CPU Monitis::Memory Monitis::Drive Monitis::Process Monitis::LoadAverage Monitis::HTTP Monitis::Ping Monitis::TransactionMonitors Monitis::FullPageLoadMonitors Monitis::VisitorTrackers Monitis::CloudInstanses Monitis::CustomMonitors

Official API page: http://monitis.com/api/api.html

BUGS AND LIMITATIONS

Please report any bugs or feature requests at Github https://github.com/monitisexchange/Perl-SDK/issues.

AUTHORS

Yaroslav Korshak <yko@cpan.org>

Alexandr Babenko <foxcool@cpan.org>

LICENCE AND COPYRIGHT

Copyright (C) 2006-2011, Monitis Inc.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.