NAME
WWW::Giraffi::API::Item - Giraffi API Item Method Item Module
VERSION
0.2_03
SYNOPSIS
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...
}
DESCRIPTION
WWW::Giraffi::API::Item is Giraffi API Item Method Access Module
METHOD
all
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
}
}
]
search
Get Item Setting
Example:
my
$conditions
= {
'name'
=>
'Test Monitoring'
};
my
$arrayref
=
$item
->search(
$conditions
);
Return Array Reference:
# 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
}
}
]
find
Get One Item Setting
Example:
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
}
}
find_service
Get all services related to an item, specified by an item id parameter.
Example:
my
$item_id
= 5;
my
$arrayref
=
$item
->find_service(
$item_id
);
Return Array Reference:
[
{
service
=> {
warninginterval
=> 60,
options
=> {},
warningretry
=> 2,
status
=> 1,
item_id
=> 5,
id
=> 7,
normalinterval
=> 120,
servicetype
=>
'web_response_time'
}
}
]
find_agent
Downloads an agent (Shell script) that can collect and post system performance statistics from the specified host.
Example:
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
create
Post Item Setting
Example:
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
Update Item Setting
Example:
my
$item_id
= 1;
my
$conditions
= {
name
=>
'Emergency Monitoring'
};
$item
->update(
$item_id
,
$conditions
);
destroy
Delete Item Setting
Example:
my
$item_id
= 1;
$item
->
delete
(
$item_id
);
reload
Item/Service/Trigger all setting reload
Example:
$item
->reload;
add_service
Adds a new service to an item, specified by an item id parameter
Example:
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
);
remove_service
Deletes the specified service using the service id parameter from an item, specified by an item id parameter.
Example:
my
$item_id
= 100;
my
$service_id
= 2;
$item
->remove_service(
$item_id
,
$service_id
);
AUTHOR
Akira Horimoto <emperor@gmail.com>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.