Monitis - Monitis.com API Perl interface
This document describes Monitis version 0.8_3
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';
This library provides interface to Monitis.com API
Monitis implements following attributes:
Monitis API URL. May vary for different calls. See 'API URL' section of corresponding API manual.
UserAgent that Monitis uses as transport.
JSON decoder.
Monitis API key.
Monitis API secret.
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).
Auth token time-to-live in seconds. 24 hours by default.
Context of execution
Monitis implements following methods:
my $monitis = Monitis->new(sekret_key => '***', api_key => '***');
Construct a new Monitis instance.
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.
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.
my $response = $monitis->api_post( actionName => [param1 => 'value', param2 => 'value']);
Requires api_key and secret_key to be set.
my $json = $monitis->parse_response($response);
Takes one argument: HTTP::Response.
Returns decoded JSON (hashref or arrayref) of response content.
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.
my $request = $monitis->build_post_request( actionName => [param1 => 'value', param2 => 'value']);
Prepares HTTP POST request to Monitis API with provided parameters.
my $params = $monitis->prepare_params(\@params, \@mandatory, \@optional); my $params = $monitis->prepare_params(\@params, \@mandatory);
Checks for mandatory and removes wrong parameters.
Returns arrayref.
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.
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
Please report any bugs or feature requests at Github https://github.com/monitisexchange/Perl-SDK/issues.
Yaroslav Korshak <yko@cpan.org>
<yko@cpan.org>
Alexandr Babenko <foxcool@cpan.org>
<foxcool@cpan.org>
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.
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.
To install Monitis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Monitis
CPAN shell
perl -MCPAN -e shell install Monitis
For more information on module installation, please visit the detailed CPAN module installation guide.