pyControl Gtm Stats
Problem this snippet solves:
This pyControl v2 script prints out status and statistics for GTM wideIPs and pools.
How to use this snippet:
This pyControl v2 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() status = obj.get_object_status(wide_ips = wideips) except Exception, e: print e 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() status = obj.get_object_status(pool_names = pools) except Exception, e: print e 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() except Exception, e: print e for x in stats.statistics: print "WideIP: ", x.wide_ip print "\n"*2 for y in x.statistics: print "\t%s = %s" % (y.type, (y.value.high<<32)|y.value.low) def get_pool_stats(obj): try: stats = obj.get_all_statistics() except Exception, e: print e for x in stats.statistics: print "Pool: ", x.pool_name print "\n"*2 for y in x.statistics: print "\t%s = %s" % (y.type, (y.value.high<<32)|y.value.low) if __name__ == "__main__": import pycontrol.pycontrol as pc import getpass from sys import argv if pc.__version__[:3] == '2.0': pass else: print "Requires pycontrol version 2.x!" sys.exit() #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, fromurl = True, wsdls = ['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