I am trying to use this from windows command line: DevCentral - An F5 Technical Community. I have python installed on the server. I saved the syntax/usage section to a file called check.py and modified host, user and password. I saved the main script to a file called pool_status.py. I am calling check.py from comand line and I get:
C:\Python27>c:\scripts\check.py
Traceback (most recent call last):
File “c:\scripts\check.py”, line 1, in
import pycontrol.pyControl as pyControl
ImportError: No module named pycontrol.pyControl
I have never ran a python script before, so perhaps I am doing somehting wrong. Any help would be great.
Thanks.
EDIT:
I am now going another route based on a recommendation by Jason Rahm
Working on trying to get this to work, but having issues (See further down in the topic)
I don’t have much experience with pycontrol, but I guess that’s because you don’t have a path for python set or you don’t have the pycontrol.pycontrol file saved in the library directory. I think the path to python is expected from your environment variables:
!/bin/env python
On an LTM, this shows:
/bin/env python
Python 2.4.3 (1, Oct 18 2010, 11:25:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>>
If that’s not working on the host you’re running the script from, try setting the path explicitly in the script. You could also try copying the pycontrol.pycontrol file to your current directory.
Next, you need to use this updated version below. Note that the host, username, password, and a valid pool in the second function call in main (mine below is testpool) will need to reflect your environment. The reason the pool name has to be passed as a list is a limitation in the zip python method. If you don’t pass as a list, the pool name will only be stored as the first character of the pool name.
!/usr/bin/python
def show_all_pools_status(obj):
''' Show the status of all pools '''
try:
pools = obj.get_list()
status = obj.get_object_status(pool_names = pools)
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 show_pool_status(obj, pool_name = None):
''' show the status of a single pool '''
status = obj.get_object_status(pool_names = [pool_name])
combined = zip(pool_name, 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
if __name__ == "__main__":
import pycontrol.pycontrol as pc
Setup connection
host = '10.10.20.5'
uname = 'admin'
upass = 'admin'
b = pc.BIGIP(
hostname = host,
username = uname,
password = upass,
fromurl = True,
wsdls = ['LocalLB.Pool']
)
p = b.LocalLB.Pool
print "Fetching pool info...\n"
show_all_pools_status(p)
print "Fetching pool X info...\n"
show_pool_status(p, ['testpool'])
Thanks for your help. I still cannot seem to get this to work. Just to confirm, I don’t need to install anything on the load balancers themselves correct? I am basically needing somehting to show me the node status of all the nodes in every pool (we have 20 or so) without having to look at the poolstatus page on the F5. So somehting that exports to an html file, or something would work. I wanted to see what this looked like as it seemed to be close to what i needed, but not sure.
Wow, that sounds like it is exactly what I need (iRule version). I will try this. My only question is, once setup, how do you view the page? I did not see instructions for that in the link.
I am having an issue with setting this up. On step 3, it mentions setting up the iRule. I do this, and then create the .class file in the class folder. When I try to click finsih, it gives me :The string class external file (/var/class/pool_member_status_list.class) has n invalid format, line: 1. It then deletes the file from that location.
no, this won’t work. What you’ve done is place the iRule in the class. An external class is a file where items of like functionality are stored, like a list of urls, or in this cass, a list of pool members. The iRule should be saved either in the GUI in the iRules text window, or in the bigip.conf file in the appropriate partition, or via the iRule editor. The iRule references the class, it isn’t stored in the class.
I see. So then what exaclty is in that .class file? Is that populated by the BigIP as I add the iRUle to their pool HTTP monitors? I did not see anything defined in the link for that unless I messed it.
Ok, now I have an iRule defined with the code above, and an empty .class file. I am not sure what needs to be done next. I am also not exaclty sure how I access the page externally, or even what the URL would be (I assume the first part would be the BIGIP Manageement Page URL)
Getting closer! The .class file was populated by the BIGIP. I have assinged the iRule to one of my virtual servers… Now the question is how do I view this information externally? I assume it must be an html page of some kind…
You can access the virtual server in a browser. If the VS IP is publicly accessible now, you may want to restrict access to trusted hosts/networks either upstream or in the iRule itself.
So you are saying that the way I view the status externally is just to go to the VIP IP? I understood this has being a holistic view of all of the Pool status’s on the BIGIP, and not just one at a time?
Nope… Create a new virtual server that’s just for getting status of all of the pools and add this iRule to it. It will loop through and get status for all of the pools.
Nope… Create a new virtual server that’s just for getting status of all of the pools and add this iRule to it. It will loop through and get status for all of the pools.
Aaron
Oh!!! Well that makes more sense!! Any other configuration needed for this Virtual Server? I have created, but for some reason I cannot connect. THe IP was responding with Ping right when I created it, then it went back to timing out. THis is just a virtual server with an IP assigned and no Pool. I am using http and the default HTTP Profile.