Created
December 10, 2011 08:41
-
-
Save mikeda/1454835 to your computer and use it in GitHub Desktop.
add Zabbix TriggerDependencies(trigger2->trigger1) by ZabbixAPI.pm
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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use utf8; | |
use Data::Dumper; | |
use ZabbixAPI; | |
my $user = "<user>"; | |
my $password = "<password>"; | |
my $za = ZabbixAPI->new("http://127.0.0.1/zabbix/"); | |
$za->auth($user, $password); | |
my $trigger1 = $za->trigger_get({ | |
filter => { | |
"host" => ["test01"], | |
"description" => ["trigger01"] | |
}, | |
select_dependencies => "extend", | |
# output => "extend" | |
})->[0]; | |
print Dumper $trigger1; | |
my $trigger2 = $za->trigger_get({ | |
filter => { | |
"host" => ["test01"], | |
"description" => ["trigger02"] | |
}, | |
select_dependencies => "extend", | |
# output => "extend" | |
})->[0]; | |
print Dumper $trigger2; | |
unless(@{$trigger2->{dependencies}}){ | |
print "add dependency\n"; | |
my $result = $za->trigger_addDependencies( | |
[ | |
{ | |
triggerid => $trigger2->{triggerid}, | |
dependsOnTriggerid => $trigger1->{triggerid} | |
} | |
] | |
); | |
print Dumper $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment