[root@yyjk F5]#cat get_f5_pool_connections_json.pl
use BigIP::iControl;
use Data::Dumper;
use JSON;
my $ic = BigIP::iControl->new(
server => $ARGV[0],
username => $ARGV[1],
password => $ARGV[2],
port => '443',
proto => 'https'
);
##获取所有定义的LTM 虚拟机服务器
my $i=0;
my @arrpool=('/Common/ESB_pool','/Common/XinDai_svr_pool','/Common/XinDai_web_pool');
#my $pool='/Common/ESB_pool';
my @responce=();
foreach $pool (@arrpool){
my %hash1=();
my %hash2=();
#Returns a list of the pool members for the specified LTM pool. This method takes one mandatory parameter; the name of the pool.
#
#Pool member are returned in the format IP_address:service_port.
#返回指定的LTM pol的 成员列表,这个方法需要一个参数 pool的名字
my @member=$ic->get_ltm_pool_members($pool);
#Returns a hash containing all pool statistics for the specified pool in a delicious, easily digestable and improved formula.
#返回指定poold的所有的pool的统计信息,返回hash
my %stats = $ic->get_pool_statistics_stringified ($pool);
foreach $key (keys %stats) {
if ($key eq 'stats'){
my %h1 = %{$stats{$key}};
foreach $key (sort keys %h1){
my $a=($pool =~ s#/Common/##);
$hash1{$key}=$h1{$key};
};
};
};
$hash2{$pool}=\%hash1;
push (@responce,\%hash2);
};
print encode_json(@responce);
[root@yyjk F5]#perl get_f5_pool_connections_json.pl 1.1.1.1 xx 12345678
[{
"ESB_pool": {
"STATISTIC_CURRENT_PVA_ASSISTED_CONNECTIONS": "0",
"STATISTIC_CURRENT_SESSIONS": "0",
"STATISTIC_CONNQUEUE_AGE_OLDEST_ENTRY": "0",
"STATISTIC_PVA_SERVER_SIDE_BYTES_OUT": "0",
"STATISTIC_CONNQUEUE_AGE_EXPONENTIAL_DECAY_MAX": "0",
"STATISTIC_SERVER_SIDE_BYTES_OUT": "6251415031352",
"STATISTIC_CONNQUEUE_SERVICED": "0",
"STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS": "298",
"STATISTIC_CONNQUEUE_AGGR_SERVICED": "0",
"STATISTIC_CONNQUEUE_CONNECTIONS": "0",
"STATISTIC_SERVER_SIDE_PACKETS_OUT": "10224441871",
"STATISTIC_CONNQUEUE_AGGR_AGE_EXPONENTIAL_DECAY_MAX": "0",
"STATISTIC_CONNQUEUE_AGGR_CONNECTIONS": "0",
"STATISTIC_CONNQUEUE_AGGR_AGE_MOVING_AVG": "0",
"STATISTIC_SERVER_SIDE_MAXIMUM_CONNECTIONS": "7610",
"STATISTIC_CONNQUEUE_AGGR_AGE_MAX": "0",
"STATISTIC_PVA_SERVER_SIDE_TOTAL_CONNECTIONS": "0",
"STATISTIC_PVA_SERVER_SIDE_PACKETS_OUT": "0",
"STATISTIC_CONNQUEUE_AGGR_AGE_OLDEST_ENTRY": "0",
"STATISTIC_SERVER_SIDE_PACKETS_IN": "10024226486",
"STATISTIC_CONNQUEUE_AGE_MAX": "0",
"STATISTIC_TOTAL_REQUESTS": "0",
"STATISTIC_PVA_SERVER_SIDE_MAXIMUM_CONNECTIONS": "0",
"STATISTIC_SERVER_SIDE_TOTAL_CONNECTIONS": "1388304123",
"STATISTIC_PVA_SERVER_SIDE_PACKETS_IN": "0",
"STATISTIC_SERVER_SIDE_BYTES_IN": "2456948708492",
"STATISTIC_PVA_SERVER_SIDE_CURRENT_CONNECTIONS": "0",
"STATISTIC_TOTAL_PVA_ASSISTED_CONNECTIONS": "0",
"STATISTIC_CONNQUEUE_AGE_MOVING_AVG": "0",
"STATISTIC_PVA_SERVER_SIDE_BYTES_IN": "0"
}
}, {
"XinDai_svr_pool": {
"STATISTIC_CONNQUEUE_AGGR_AGE_MOVING_AVG": "0",
"STATISTIC_SERVER_SIDE_MAXIMUM_CONNECTIONS": "1433",
"STATISTIC_CONNQUEUE_AGGR_AGE_MAX": "0",
"STATISTIC_SERVER_SIDE_PACKETS_OUT": "4082627778",
"STATISTIC_CONNQUEUE_AGGR_CONNECTIONS": "0",
"STATISTIC_CONNQUEUE_AGGR_AGE_EXPONENTIAL_DECAY_MAX": "0",
"STATISTIC_CONNQUEUE_AGGR_SERVICED": "0",
"STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS": "79",
"STATISTIC_CONNQUEUE_CONNECTIONS": "0",
"STATISTIC_CONNQUEUE_SERVICED": "0",
"STATISTIC_PVA_SERVER_SIDE_BYTES_OUT": "0",
"STATISTIC_CONNQUEUE_AGE_EXPONENTIAL_DECAY_MAX": "0",
"STATISTIC_SERVER_SIDE_BYTES_OUT": "1899935618598",
"STATISTIC_CURRENT_PVA_ASSISTED_CONNECTIONS": "0",
"STATISTIC_CURRENT_SESSIONS": "0",
"STATISTIC_CONNQUEUE_AGE_OLDEST_ENTRY": "0",
"STATISTIC_SERVER_SIDE_BYTES_IN": "7438094432299",
"STATISTIC_PVA_SERVER_SIDE_CURRENT_CONNECTIONS": "0",
"STATISTIC_TOTAL_PVA_ASSISTED_CONNECTIONS": "0",
"STATISTIC_CONNQUEUE_AGE_MOVING_AVG": "0",
"STATISTIC_PVA_SERVER_SIDE_BYTES_IN": "0",
"STATISTIC_PVA_SERVER_SIDE_PACKETS_IN": "0",
"STATISTIC_PVA_SERVER_SIDE_MAXIMUM_CONNECTIONS": "0",
"STATISTIC_SERVER_SIDE_TOTAL_CONNECTIONS": "20968155",
"STATISTIC_CONNQUEUE_AGE_MAX": "0",
"STATISTIC_TOTAL_REQUESTS": "0",
"STATISTIC_PVA_SERVER_SIDE_TOTAL_CONNECTIONS": "0",
"STATISTIC_PVA_SERVER_SIDE_PACKETS_OUT": "0",
"STATISTIC_CONNQUEUE_AGGR_AGE_OLDEST_ENTRY": "0",
"STATISTIC_SERVER_SIDE_PACKETS_IN": "7962444123"
}
}, {
"XinDai_web_pool": {
"STATISTIC_SERVER_SIDE_BYTES_IN": "10756482594430",
"STATISTIC_TOTAL_PVA_ASSISTED_CONNECTIONS": "0",
"STATISTIC_PVA_SERVER_SIDE_CURRENT_CONNECTIONS": "0",
"STATISTIC_CONNQUEUE_AGE_MOVING_AVG": "0",
"STATISTIC_PVA_SERVER_SIDE_BYTES_IN": "0",
"STATISTIC_PVA_SERVER_SIDE_PACKETS_IN": "0",
"STATISTIC_PVA_SERVER_SIDE_MAXIMUM_CONNECTIONS": "0",
"STATISTIC_SERVER_SIDE_TOTAL_CONNECTIONS": "48501043",
"STATISTIC_CONNQUEUE_AGE_MAX": "0",
"STATISTIC_TOTAL_REQUESTS": "4090997051",
"STATISTIC_PVA_SERVER_SIDE_TOTAL_CONNECTIONS": "0",
"STATISTIC_PVA_SERVER_SIDE_PACKETS_OUT": "0",
"STATISTIC_CONNQUEUE_AGGR_AGE_OLDEST_ENTRY": "0",
"STATISTIC_SERVER_SIDE_PACKETS_IN": "22831876365",
"STATISTIC_CONNQUEUE_AGGR_AGE_MOVING_AVG": "0",
"STATISTIC_SERVER_SIDE_MAXIMUM_CONNECTIONS": "1106",
"STATISTIC_CONNQUEUE_AGGR_AGE_MAX": "0",
"STATISTIC_SERVER_SIDE_PACKETS_OUT": "21778918412",
"STATISTIC_CONNQUEUE_AGGR_CONNECTIONS": "0",
"STATISTIC_CONNQUEUE_AGGR_AGE_EXPONENTIAL_DECAY_MAX": "0",
"STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS": "114",
"STATISTIC_CONNQUEUE_AGGR_SERVICED": "0",
"STATISTIC_CONNQUEUE_CONNECTIONS": "0",
"STATISTIC_CONNQUEUE_SERVICED": "0",
"STATISTIC_CONNQUEUE_AGE_EXPONENTIAL_DECAY_MAX": "0",
"STATISTIC_PVA_SERVER_SIDE_BYTES_OUT": "0",
"STATISTIC_SERVER_SIDE_BYTES_OUT": "19525261360930",
"STATISTIC_CURRENT_PVA_ASSISTED_CONNECTIONS": "0",
"STATISTIC_CURRENT_SESSIONS": "9",
"STATISTIC_CONNQUEUE_AGE_OLDEST_ENTRY": "0"
}
}]