Forum Discussion
Gordon_Johnston
Nimbostratus
Jun 29, 2005Monitor instance status checking
Hi All,
Delurking here with a query I hope someone can assist with.
I'm writing a script to be used by our 24/7 team to give them a full overview of a BigIP from a single screen. One of the requirements is that the current monitor statuses for each pool member can be viewed. I.e. to show red/green for each monitor associated with an individual pool member.
I'm scratching my head on how to do this with iControl.
LocalLB.PoolMember.get_monitor_association returns the monitors by name that are assocated with a particular member. However this only returns the name of the monitor and nothing else to identify which instance of the monitor it is.
LocalLB.PoolMember.get_monitor_status returns the status of the member as an aggregation of all the associated monitors but not the individual monitors.
LocalLB.Pool.get_monitor_instance returns the full list of monitor instances, including the ip/port definition for each, however it does not return the nodes that these are assoicated with and it doesn't not appear to guarentee to return the results in the same order as LocalLB.PoolMember.get_monitor_association
I'm struggling as to how to link this data together. I could make queries to LocalLB.Monitor.get_instance_state but not until I know which instances belong to which pool member.
Any help appreciated.
- what you want is the LocalLB::Pool::get_monitor_instance(). Per the documentation:
!/usr/bin/perl ---------------------------------------------------------------------------- The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5 Software Development Kit for iControl"; you may not use this file except in compliance with the License. The License is included in the iControl Software Development Kit. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is iControl Code and related documentation distributed by F5. The Initial Developer of the Original Code is F5 Networks, Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2005 F5 Networks, Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc. Alternatively, the contents of this file may be used under the terms of the GNU General Public License (the "GPL"), in which case the provisions of GPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of the GPL and not to allow others to use your version of this file under the License, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL. If you do not delete the provisions above, a recipient may use your version of this file under either the License or the GPL. ---------------------------------------------------------------------------- use SOAP::Lite + trace => qw(method debug); use SOAP::Lite; use MIME::Base64; BEGIN {push (@INC, "..");} use iControlTypeCast; ---------------------------------------------------------------------------- Validate Arguments ---------------------------------------------------------------------------- my $sHost = $ARGV[0]; my $sPort = $ARGV[1]; my $sUID = $ARGV[2]; my $sPWD = $ARGV[3]; my $sPool = $ARGV[4]; my $sProtocol = "https"; if ( ("80" eq $sPort) or ("8080" eq $sPort) ) { $sProtocol = "http"; } if ( ($sHost eq "") or ($sPort eq "") or ($sUID eq "") or ($sPWD eq "") ) { die ("Usage: LocalLBPoolMember.pl host port uid pwd [pool_name]\n"); } ---------------------------------------------------------------------------- Transport Information ---------------------------------------------------------------------------- sub SOAP::Transport::HTTP::Client::get_basic_credentials { return "$sUID" => "$sPWD"; } $Pool = SOAP::Lite -> uri('urn:iControl:LocalLB/Pool') -> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi"); $Pool->transport->http_request->header ( 'Authorization' => 'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '') ); if ( $sPool eq "" ) { &getAllPoolMemberMonitorInfo(); } else { &getPoolMemberMonitorInfo($sPool); } ---------------------------------------------------------------------------- checkResponse ---------------------------------------------------------------------------- sub checkResponse() { my ($soapResponse) = (@_); if ( $soapResponse->fault ) { print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n"; exit(); } } ---------------------------------------------------------------------------- getAllPoolMemberMonitorInfo ---------------------------------------------------------------------------- sub getAllPoolMemberMonitorInfo() { $soapResponse = $Pool->get_list(); &checkResponse($soapResponse); my @pool_list = @{$soapResponse->result}; &getPoolMemberMonitorInfo(@pool_list); } ---------------------------------------------------------------------------- getAddress() ---------------------------------------------------------------------------- sub getAddress() { ($MonitorInstance) = (@_); $instance = $MonitorInstance->{"instance"}; $template_name = $instance->{"template_name"}; $instance_definition = $instance->{"instance_definition"}; $ipport = $instance_definition->{"ipport"}; $address = $ipport->{"address"}; $port = $ipport->{"port"}; return "$address:$port"; } ---------------------------------------------------------------------------- sort_by_member ---------------------------------------------------------------------------- sub sort_by_member { return &getAddress($a) cmp &getAddress($b); } ---------------------------------------------------------------------------- getPoolMemberMonitorInfo ---------------------------------------------------------------------------- sub getPoolMemberMonitorInfo() { my @pool_list = @_; my $last_member = ""; Get Member List $soapResponse = $Pool->get_monitor_instance ( SOAP::Data->name(pool_names => [@pool_list]) ); &checkResponse($soapResponse); my @MonitorInstanceStateAofA = @{$soapResponse->result}; for $i (0 .. $MonitorInstanceStateAofA) { print "Pool $pool_list[$i] {\n"; $MonitorInstanceStateList = $MonitorInstanceStateAofA[$i]; foreach $MonitorInstance ( sort sort_by_member @{$MonitorInstanceStateList} ) { $instance = $MonitorInstance->{"instance"}; $template_name = $instance->{"template_name"}; $instance_definition = $instance->{"instance_definition"}; $address_type = $instance_definition->{"address_type"}; $ipport = $instance_definition->{"ipport"}; $address = $ipport->{"address"}; $port = $ipport->{"port"}; $instance_state = $MonitorInstance->{"instance_state"}; $enabled_state = $MonitorInstance->{"enabled_state"}; $current_member = "$address:$port"; if ( $current_member ne $last_member ) { New member so print header $last_member = $current_member; print " Member : $current_member\n"; } print " Template : $template_name\n"; print " Address Type : $address_type\n"; print " Instance State: $instance_state\n"; print " Enabled State :"; if ( 0 == $enabled_state ) { print "Disabled"; } else { print "Enabled"; } print "\n"; } print "}\n"; } }
- Gordon_Johnston
Nimbostratus
Excellent that's exactly what I need thanks Joe. - Gordon_Johnston
Nimbostratus
On second thoughts unfortunatly that still doesn't get what I need.Pool gj_pool { Member : 192.168.123.123:1234 Template : http Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_DOWN Enabled State :Enabled Member : 192.168.222.222:80 Template : gj_specific_port_specific_addr Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_DOWN Enabled State :Enabled Template : gj_specific_port_specific_addr Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_DOWN Enabled State :Enabled Template : gj_specific_port_specific_addr Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_DOWN Enabled State :Enabled Member : 192.168.230.133:80 Template : http Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_UP Enabled State :Enabled Member : 192.168.230.161:80 Template : http Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_UP Enabled State :Enabled }
Pool gj_pool { Member : 192.168.123.123:1234 Template : http Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_DOWN Enabled State :Enabled Template : gj_specific_port_specific_addr Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_DOWN Enabled State :Enabled Member : 192.168.230.133:80 Template : http Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_UP Enabled State :Enabled Template : gj_specific_port_specific_addr Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_DOWN Enabled State :Enabled Member : 192.168.230.161:80 Template : http Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_UP Enabled State :Enabled Template : gj_specific_port_specific_addr Address Type : ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT Instance State: INSTANCE_STATE_DOWN Enabled State :Enabled }
- Gordon_Johnston
Nimbostratus
Thanks for your time Joe, it does appear that PoolMember::get_monitor_instance() is what's needed. I'll keep an eye out for it in a future release. - The same monitors may well apply to each of the nodes, but there is a separate instance of each one running for each node. So, you could look at all instances of that specific monitor, but there is no way to be sure that all 3 of them are in the same state that the GUI or CLI will represent. Give it a shot though and let us know what you find out.
- Gordon_Johnston
Nimbostratus
Raising the dead here, but just wondering if "LocalLB::PoolMember::get_monitor_instance()" made it into 9.2? - Loc_Pham_101863Historic F5 AccountYes, LocalLB.PoolMember.get_monitor_instance method has been added to 9.2.0.
- Yes, LocalLB::PoolMember::get_monitor_instance() was added in 9.2. Here are the specs for it (and are also defined in the WSDL included in the BIG-IP v9.2 release).
struct IPPortDefinition { string address; long port; }; enum AddressType { ATYPE_UNSET = 0, ATYPE_STAR_ADDRESS_STAR_PORT = 1, ATYPE_STAR_ADDRESS_EXPLICIT_PORT = 2, ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT = 3, ATYPE_STAR_ADDRESS = 4, ATYPE_EXPLICIT_ADDRESS = 5 }; struct MonitorIPPort { AddressType ip_address; IPPortDefinition ipport; }; struct MonitorInstance { String instance_name; MonitorIPPort instance_definition; }; enum MonitorInstanceStateType { INSTANCE_STATE_UNCHECKED = 0, INSTANCE_STATE_CHECKING = 1, INSTANCE_STATE_UP = 2, INSTANCE_STATE_DOWN = 3, INSTANCE_STATE_FORCED_DOWN = 4, INSTANCE_STATE_DISABLED = 5 }; struct MonitorInstanceState { MonitorInstance instance; MonitorInstanceStateType instance_state; boolean enabled_state; }; struct MemberMonitorInstanceState { IPPortDefinition member; MonitorInstanceState[] monitor_instances }; MemberMonitorInstanceState[][] LocalLB::PoolMemberget_monitor_instance( in String[] pool_names );
- Gordon_Johnston
Nimbostratus
Works a treat thanks very much.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects