WWW::Giraffi::API::Item - Giraffi API Item Method Item Module
0.13
use strict; use warnings; use WWW::Giraffi::API; my $apikey = "ilovenirvana_ilovekurtcobain"; my $g = WWW::Giraffi::API->new(apikey => $apikey); # get all item data my $arrayref = $g->item->all; foreach $ref(@{$arrayref}) { ## anything to do... }
WWW::Giraffi::API::Item is Giraffi API Item Method Access Module
Get All Item Setting
Example:
$ create item object my $item = $g->item; my $arrayref = $item->all;
Return Array Reference:
[ { item => { warninginterval => 60, warningretry => 2, status => 1, ip => '127.0.0.1', name => 'Test Monitoring', allowcopy => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ), host => 'localhost', user_id => 16, id => 5, normalinterval => 120, customkey' => undef } } ]
Get Item Setting
my $conditions = { 'name' => 'Test Monitoring' }; my $arrayref = $item->search($conditions);
# only conditions match [ { item => { warninginterval => 60, warningretry => 2, status => 1, ip => '127.0.0.1', name => 'Test Monitoring', allowcopy => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ), host => 'localhost', user_id => 16, id => 5, normalinterval => 120, customkey' => undef } } ]
Get One Item Setting
my $item_id = 1; my $ref = $item->find($item_id);
Return Reference:
{ item => { warninginterval => 60, warningretry => 2, status => 1, ip => '127.0.0.1', name => 'Test Monitoring', allowcopy => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ), host => 'localhost', user_id => 16, id => 5, normalinterval => 120, customkey' => undef } }
Get all services related to an item, specified by an item id parameter.
my $item_id = 5; my $arrayref = $item->find_service($item_id);
[ { service => { warninginterval => 60, options => {}, warningretry => 2, status => 1, item_id => 5, id => 7, normalinterval => 120, servicetype => 'web_response_time' } } ]
Downloads an agent (Shell script) that can collect and post system performance statistics from the specified host.
my $item_id = 5; my $content = $item->find_agent($item_id);
$content is shell script string. see https://github.com/giraffi/giraffi/wiki/Giraffi-REST-API-Resources#wiki-get_items_item_id_agent
Post Item Setting
my $conditions = { name => 'Test Monitoring', host => "f00-196.238.145.203.fs-user.net", ip => "203.145.238.196", normalinterval => 120, warninginterval => 60, warningretry => 2, status => 1, }; $item->create($conditions);
Update Item Setting
my $item_id = 1; my $conditions = { name => 'Emergency Monitoring' }; $item->update($item_id, $conditions);
Delete Item Setting
my $item_id = 1; $item->delete($item_id);
Adds a new service to an item, specified by an item id parameter
my $item_id = 2; my $service_conditions = { servicetype => "web_response_time", normalinterval => 120, warninginterval => 60, warningretry => 2, status => 1, options => {} }; $item->add_service($item_id, $service_conditions);
Deletes the specified service using the service id parameter from an item, specified by an item id parameter.
my $item_id = 100; my $service_id = 2; $item->remove_service($item_id, $service_id);
Akira Horimoto <emperor@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install WWW::Giraffi::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Giraffi::API
CPAN shell
perl -MCPAN -e shell install WWW::Giraffi::API
For more information on module installation, please visit the detailed CPAN module installation guide.