Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated PredefinedMonitors

  • Loading branch information...
commit 22540fe5a5e29289ce780b60c2d2a6939f114492 1 parent a2cdef8
@yko yko authored
Showing with 124 additions and 3 deletions.
  1. +67 −0 lib/Monitis/PredefinedMonitors.pm
  2. +57 −3 xt/predefined_monitors.t
View
67 lib/Monitis/PredefinedMonitors.pm
@@ -18,6 +18,73 @@ sub custom_report {
return $self->api_get('report' => $params);
}
+sub top_external {
+ shift->_top_by_type('topexternal', @_);
+}
+
+sub top_cpu {
+ shift->_top_by_type('topcpu', @_);
+}
+
+sub top_drive {
+ shift->_top_by_type('topdrive', @_);
+}
+
+sub top_memory {
+ shift->_top_by_type('topmemory', @_);
+}
+
+sub top_load1 {
+ shift->_top_by_type('topload1', @_);
+}
+
+sub top_load5 {
+ shift->_top_by_type('topload5', @_);
+}
+
+sub top_load15 {
+ shift->_top_by_type('topload15', @_);
+}
+
+sub top_internal_http {
+ shift->_top_by_type('topInternalHTTP', @_);
+}
+
+sub top_internal_ping {
+ shift->_top_by_type('topInternalPing', @_);
+}
+
+sub top_transaction {
+ shift->_top_by_type('topTransaction', @_);
+}
+
+sub top_fullpage {
+ shift->_top_by_type('topFullpage', @_);
+}
+
+sub top_process_by_cpu_usage {
+ shift->_top_by_type('topProcessByCPUUsage', @_);
+}
+
+sub top_process_by_memory_usage {
+ shift->_top_by_type('topProcessByMemoryUsage', @_);
+}
+
+sub top_process_by_virt_memory_usage {
+ shift->_top_by_type('topProcessByVirtMemoryUsage', @_);
+}
+
+sub _top_by_type {
+ my ($self, $type, @params) = @_;
+
+ my @mandatory = qw//;
+ my @optional = qw/timezoneoffset limit tag/;
+
+ my $params = $self->prepare_params(\@params, \@mandatory, \@optional);
+
+ $self->api_get($type => $params);
+}
+
__END__
=head1 NAME
View
60 xt/predefined_monitors.t
@@ -1,11 +1,65 @@
use lib 't/lib';
-use Test::Monitis tests => 1, live => 1;
+use Test::Monitis tests => 15, live => 1;
note 'Action report (predefined_monitors->custom_report)';
-
my $response = api->predefined_monitors->custom_report(
type => 'external',
period => 'Last30Days'
);
-
isa_ok $response, 'ARRAY', 'JSON response ok';
+
+note 'Action topexternal (predefined_monitors->top_external)';
+$response = api->predefined_monitors->top_external;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topcpu (predefined_monitors->top_cpu)';
+$response = api->predefined_monitors->top_cpu;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topdrive (predefined_monitors->top_drive)';
+$response = api->predefined_monitors->top_drive;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topmemory (predefined_monitors->top_memory)';
+$response = api->predefined_monitors->top_memory;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topload1 (predefined_monitors->top_load1)';
+$response = api->predefined_monitors->top_load1;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topload5 (predefined_monitors->top_load5)';
+$response = api->predefined_monitors->top_load5;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topload15 (predefined_monitors->top_load15)';
+$response = api->predefined_monitors->top_load15;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topInternalHTTP (predefined_monitors->top_internal_http)';
+$response = api->predefined_monitors->top_internal_http;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topInternalPing (predefined_monitors->top_internal_ping)';
+$response = api->predefined_monitors->top_internal_ping;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topTransaction (predefined_monitors->top_transaction)';
+$response = api->predefined_monitors->top_transaction;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topFullpage (predefined_monitors->top_fullpage)';
+$response = api->predefined_monitors->top_fullpage;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topProcessByCPUUsage (predefined_monitors->top_process_by_cpu_usage)';
+$response = api->predefined_monitors->top_process_by_cpu_usage;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topProcessByMemoryUsage (predefined_monitors->top_process_by_memory_usage)';
+$response = api->predefined_monitors->top_process_by_memory_usage;
+isa_ok $response, 'HASH', 'JSON response ok';
+
+note 'Action topProcessByVirtMemoryUsage (predefined_monitors->top_process_by_virt_memory_usage)';
+$response = api->predefined_monitors->top_process_by_virt_memory_usage;
+isa_ok $response, 'HASH', 'JSON response ok';
Please sign in to comment.
Something went wrong with that request. Please try again.