Skip to content

Instantly share code, notes, and snippets.

@mikeda
Created December 10, 2011 08:41
Show Gist options
  • Save mikeda/1454835 to your computer and use it in GitHub Desktop.
Save mikeda/1454835 to your computer and use it in GitHub Desktop.
add Zabbix TriggerDependencies(trigger2->trigger1) by ZabbixAPI.pm
#!/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