forked from roa/pabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Abraham
committed
Sep 3, 2012
1 parent
767346d
commit 8fbae3f
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ pm_to_blib | |
tmp/ | ||
*.tar | ||
*.tar.gz | ||
bin/test.pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package Pabbix::Trigger::Exist; | ||
|
||
use strict; | ||
use warnings; | ||
use Moo; | ||
use Pabbix::Request; | ||
use Data::Dumper; | ||
|
||
sub exist | ||
{ | ||
my $self = shift; | ||
|
||
my $response = Pabbix::Request->new( | ||
url => $self->url, | ||
json => $self->_createJson, | ||
); | ||
return $response->get; | ||
} | ||
|
||
sub _createJson | ||
{ | ||
my $self = shift; | ||
my $json = { | ||
jsonrpc => "2.0", | ||
method => "trigger.exists", | ||
params => { | ||
description => $self->description, | ||
expression => $self->expression, | ||
}, | ||
auth => $self->authToken, | ||
id => 0 | ||
}; | ||
|
||
if( $self->hostid ) | ||
{ | ||
$json->{'params'}{'hostid'} = $self->hostid; | ||
} | ||
if( $self->host ) | ||
{ | ||
$json->{'params'}{'host'} = $self->host; | ||
} | ||
if( $self->nodeids ) | ||
{ | ||
$json->{'params'}{'nodeids'} = $self->nodeids; | ||
} | ||
|
||
return $json; | ||
} | ||
|
||
has url => ( | ||
is => 'ro', | ||
); | ||
|
||
has authToken => ( | ||
is => 'ro', | ||
); | ||
|
||
has host => ( | ||
is => 'ro', | ||
); | ||
|
||
has hostid => ( | ||
is => 'ro', | ||
); | ||
|
||
has description => ( | ||
is => 'ro', | ||
required => 1, | ||
); | ||
|
||
has expression => ( | ||
is => 'ro', | ||
required => 1, | ||
); | ||
|
||
has nodeids => ( | ||
is => 'ro', | ||
); | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ has authToken => ( | |
); | ||
|
||
has statusValue => ( | ||
is => 'ro' | ||
is => 'ro', | ||
); | ||
|
||
1; |