Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.73 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use Zabbix::Tiny;
  5.  
  6. my $hostname = $ARGV[0];
  7. my $username = 'user';
  8. my $password = 'goodpassword';
  9. my $url      = 'https://zabbix.domain.com/zabbix/api_jsonrpc.php';
  10.  
  11. # Create a new Zabbix::Tiny object
  12. my $zabbix = Zabbix::Tiny->new(
  13.     server   => $url,
  14.     password => $password,
  15.     user     => $username,
  16. );
  17.  
  18. my $hosts = $zabbix->do(
  19.     'host.get',
  20.     output => [qw(hostid name host)],
  21.     filter => {
  22.         host => $hostname,
  23.     }
  24. );
  25.  
  26. for my $host (@$hosts) {
  27.     print "$host->{name}   URL:  $host->{inventory}->{url_a}\n";
  28.     my $update => {
  29.         'host.update',
  30.         hostid         => $host->{hostid},
  31.         inventory_mode => 1
  32.     };
  33. }
  34.  
  35. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement