Created
February 26, 2019 18:29
-
-
Save jrelo/6aa3ea6c0c6fadf28380a3b7c07aaf21 to your computer and use it in GitHub Desktop.
zabbix pull
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/env perl | |
use strict; | |
use warnings; | |
use Zabbix::Tiny; | |
$|++; | |
my %hostgroups = ( | |
'Test' => "42", | |
); | |
my $zabbix = Zabbix::Tiny->new( | |
server => 'https://myzabbix.something.com/api_jsonrpc.php', | |
user => 'user', | |
password => 'pass', | |
); | |
my @entries; | |
foreach my $group ( keys %hostgroups ) { | |
print "Checking: $group\n"; | |
my $hosts = $zabbix->do('host.get', | |
{ | |
groupids => $hostgroups{$group}, | |
monitored => 1, | |
output => [qw( | |
hostid | |
name | |
host | |
)], | |
} | |
); | |
foreach my $host ( @$hosts ) { | |
push @entries, sprintf("%s\t%s\t%s", $host->{hostid}, $host->{name}, $host->{host}); | |
} | |
} | |
print(join "\n", sort @entries); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment