Zabbix API gets all host names, IP

Source: Internet
Author: User

The main added 1 Selectinterfaces records, the essence is that the database is the join this table. The Perl code is as follows:

#!/usr/bin/perl UseStrict; Usewarnings; UseJSON::RPC::Client; UseData::dumper; UseJSON; UseUTF8; UseParallel::Forkmanager;my $pm= Parallel::forkmanager->new ( -); #define the number of open processes$| =1;Binmode(STDIN,': Encoding (UTF8)' );Binmode(STDOUT,': Encoding (UTF8)' ); #Three rowsBinmode(STDERR,': Encoding (UTF8)' ); #for normal output Chinese # Authenticate yourselfmy $client= new JSON::RPC::Client;my $url='http://zabbix.mcshell.org/api_jsonrpc.php';my $authID;my $response; my $json={Jsonrpc="2.0",Method="User.login",params={User="User",Password="Password"    },ID=1}; $response=$client->call ($url,$json ); #Check If response was successful die "Authentication failed\n" unless $response->content->{'result'}; $authID=$response->content->{'result'};Print "authentication successful. Auth ID:".$authID."\ n"; PrintDumper \get_all_host_and_ip ();SubGet_all_host_and_ip {my $json={Jsonrpc='2.0',Method='Host.get',params= {            "Output"= ['name',"Host"],#fuzzy matching is possible            "selectinterfaces"= ["Interfaces","IP" ]    #Filter IP},ID=1,Auth="$authID",    }; my $response=$client->call ($url,$json );  die "Host.get failed\n" unless $response->content->{result}; my $hostID; foreach my $host( @{$response->content->{result}}) {  for my $num( @{$host-{Interfaces}}) {   $hostID->{$host-{host}}=$num-{IP}; }     }    return $hostID; }

Zabbix API gets all host names, IP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.