pyControl GTM Statistics
Problem this snippet solves:
Summary: This script prints out status and statistics for GTM wideIPs and pools.
How to use this snippet:
This script will print out status and statistics for all GTM wideIPs and pools.
Usage: GTMstats.py
Code :
#!/usr/bin/env python ''' ---------------------------------------------------------------------------- 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-2004 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. ---------------------------------------------------------------------------- ''' def get_wideips(obj): ''' Shows the wideips configured on the GTM ''' try: wideips = obj.get_list()['return'] status = obj.get_object_status(wide_ips = wideips)['return'] except: "Unable to fetch wideip list or get status - check trace log" combined = zip(wideips,status) for x in combined: print "WideIP: ", x[0] print "\t", x[1]['availability_status'] print "\t", x[1]['enabled_status'] print "\t", x[1]['status_description'] print "\n"*2 def get_pools(obj): '''Shows the pools configured, LTM or GTM''' try: pools = obj.get_list()['return'] status = obj.get_object_status(pool_names = pools)['return'] except: "Unable to fetch pool list or get status - check trace log" combined = zip(pools, status) for x in combined: print "Pool: ", x[0] print "\t", x[1]['availability_status'] print "\t", x[1]['enabled_status'] print "\t", x[1]['status_description'] print "\n"*2 def get_wideip_stats(obj): try: stats = obj.get_all_statistics()['return'] except: "Unable to fetch wideip list or get statistics - check trace log" for x in stats['statistics']: print "WideIP: ", x['wide_ip'] print "\n"*2 for y in x['statistics']: value = y.get('value') high = value.get('high') low = value.get('low') value64 = (high<<32)|low print "\t", y.get('type') , value64 def get_pool_stats(obj): try: stats = obj.get_all_statistics()['return'] except: "Unable to fetch pool list or get statistics - check trace log" for x in stats['statistics']: print "Pool: ", x['pool_name'] print "\n"*2 for y in x['statistics']: value = y.get('value') high = value.get('high') low = value.get('low') value64 = (high<<32)|low print "\t", y.get('type') , value64 if __name__ == "__main__": import pycontrol.pycontrol as pc import getpass from sys import argv #Require Command-line arguments if len(argv) != 3: exit("Usage: GTMstats.py") host = argv[1] uname = argv[2] print "%s, enter your " % getpass.getuser(), upass = getpass.getpass() b = pc.BIGIP( hostname = host, username = uname, password = upass, wsdl_files = ['GlobalLB.WideIP', 'GlobalLB.Pool'] ) w = b.GlobalLB_WideIP p = b.GlobalLB_Pool print "Fetching wideip info...\n" get_wideips(w) print "Fetching wideip stats...\n" get_wideip_stats(w) print "Fetching pool info...\n" get_pools(p) print "Fetching pool stats...\n" get_pool_stats(p)
Published Mar 09, 2015
Version 1.0CodeCentral_194
Cirrus
Joined May 05, 2019
CodeCentral_194
Cirrus
Joined May 05, 2019
No CommentsBe the first to comment