pyControl System Quick Audit

Problem this snippet solves:

This script gathers some basic but useful system information and prints it out.

You'll need to change the parameters to reflect your system(s). In this example our BigIP system is 192.168.1.245 with the default username and password info. See the syntax section below for example usage and sample output.

How to use this snippet:

Syntax

import pycontrol.pyControl as pc
from pycontrol.samples.system_quick_audit import *
from pycontrol.Utils import convert_uptime
b = pc.BIGIP(hostname = 'your_system_ip_address', username = 'your_username', password = 'your_password', wsdl_files = ['System.SystemInfo'])
get_basic_audit(b)

Sample Output

>>> get_basic_audit(b)
===================================
System:  lab-box.mylab.com
Serial:  bipXXXXXXs
Product: 6400 (D63)
Version: BIG-IP_v9.4.2
Uptime:  14 days, 21===================================

Code :

#!/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.
----------------------------------------------------------------------------
'''

import pycontrol.pyControl as pyControl
from pycontrol.Utils import convert_uptime

''' 
Perform a quick audit of basic system info.
'''

def get_basic_audit(b):
'''
get_basic_audit: gather some general info about a BigIP system.
expects a valid, connected object as an argument.
'''
#Create a convenience object
s = b.System_SystemInfo

#Get some basic info
uptime   = s.get_uptime()['return']
version  = s.get_version()['return'] 
sysinfo  = s.get_system_information()
print "=" * 35
print "System:  %s" % sysinfo['return']['host_name']
print "Serial:  %s" % sysinfo['return']['chassis_serial']
print "Product: %s (%s)" % ( sysinfo['return']['product_category'], sysinfo['return']['platform'] )
print "Version: %s" % version
print "Uptime:  %s days, %s:%s:%s " % (convert_uptime(uptime))
print "=" * 35



if __name__ == "__main__":

#Change the info below to reflect your system.

b = pyControl.BIGIP(hostname = '192.168.1.245',
 username   = 'admin',
password   = 'admin',
wsdl_files = ['System.SystemInfo'])

get_basic_audit(b)
Published Mar 09, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment