Hi All,
perl-скриптом вызваю метод trigger.get
и в ответ получаю сложную структуру
Достаю из неё описание тригера и приоритет.
foreach my $vect (@{$response->content->{result}}) {
print " description: ".$vect->{description}." priority: ".$vect->{priority}."\n";
Подскажите, как можно достать имя хоста (host)?
perl-скриптом вызваю метод trigger.get
Code:
$json = {
jsonrpc => "2.0",
method => "trigger.get",
params => {
output => "extend",
select_hosts => "extend",
filter => { value => 1 },
sortfield => "priority",
sortorder => "DESC",
active => 1,
monitored => 1
},
auth => "6af2a2b48432760b4d2345648944cf3c8",
id => 1
};
$response = $client->call($url, $json);
foreach my $vect (@{$response->content->{result}}) {
print " description: ".$vect->{description}." priority: ".$vect->{priority}."\n";
}
Code:
$VAR1 = bless( {
'version' => 0,
'content' => {
'jsonrpc' => '2.0',
'id' => 1,
'result' => [
{
'priority' => '2',
'hosts' => [
{
'dns' => '',
'maintenances' => [
{
'maintenanceid' => '0'
}
],
'outbytes' => '0',
'snmp_error' => '',
'ipmi_ip' => '',
'ipmi_authtype' => '-1',
'ipmi_username' => '',
'ipmi_error' => '',
'useipmi' => '0',
'port' => '10050',
'maintenanceid' => '0',
'errors_from' => '0',
'ipmi_password' => '',
'useip' => '1',
'ipmi_privilege' => '2',
'maintenance_type' => '0',
'maintenance_status' => '0',
'ip' => 'xxxxx',
'status' => '0',
'lastaccess' => '0',
'hostid' => '100100000010108',
'ipmi_port' => '623',
'ipmi_errors_from' => '0',
'ipmi_available' => '0',
'disable_until' => '0',
'proxy_hostid' => '0',
'error' => '',
'snmp_disable_until' => '0',
'maintenance_from' => '0',
'available' => '0',
'snmp_available' => '1',
'host' => 'ZZZZ',
'inbytes' => '0',
'snmp_errors_from' => '0',
'ipmi_disable_until' => '0'
}
],
'value' => '1',
'status' => '0',
'templateid' => '0',
'comments' => '',
'description' => 'DDDD',
'lastchange' => '1387456173',
'triggerid' => '100100000013576',
'expression' => '{100100000013235}=0',
'error' => '',
'url' => '',
'type' => '0',
'dep_level' => '0'
}
]
},
foreach my $vect (@{$response->content->{result}}) {
print " description: ".$vect->{description}." priority: ".$vect->{priority}."\n";
Подскажите, как можно достать имя хоста (host)?
Comment