Forum Discussion

Dean_M_21414's avatar
Dean_M_21414
Icon for Nimbostratus rankNimbostratus
Sep 13, 2011

Report for down nodes

Hi all, I need a script that will list all down nodes per pool, by partition. We need a daily report that will show our downed nodes along with their associated pool/s (via members). We also need this report to be per partition, as we have different departments that work on these different partitions. I can see that this will require a loop within a loop: the inner loop works through the pools, checking for the inactive nodes, and the outer loop works through the partitions. I've got a fair bit of coding experience, but not in tmsh or tcl. I've got the flow diagram for this (see attached jpg) (i.e. I know what I want this to do), but i need the code. Any help would be appreciated. Regards Dean
  • George_Watkins_'s avatar
    George_Watkins_
    Historic F5 Account
    Hi Dean,

     

     

    Probably your best bet is to write an iControl script. iControl is a SOAP API for making requests to a BIG-IP. We offer libraries for a number of common script languages (Perl, Python, Ruby, Powershell, etc.), so there is more than likely one that will meet your needs. Here are a few resources to get you started:

     

     

    iControl Wiki (http://devcentral.f5.com/wiki/iControl.HomePage.ashx) - lots of code samples from numerous scripting languages

     

    iControl API Reference (http://devcentral.f5.com/wiki/iControl.APIReference.ashx)

     

    iControl LocalLB::Pool interface (http://devcentral.f5.com/wiki/iControl.LocalLB__Pool.ashx) - this is where the majority of the methods you'll need for querying pools will be

     

    iControl Management::Partition interface (http://devcentral.f5.com/wiki/iControl.Management__Partition.ashx) - where the active partition to query is set (note: partitions have been deprecated in favor of folders in version 11)

     

     

    I am more Ruby-centric, so I whipped up a small script that will report pools without active members. I hope this gives you some fuel to get started. Feel free to reply with any further questions.

     

     

    
    !/usr/bin/ruby
    
    require 'rubygems'
    require 'f5-icontrol'
    
    def usage
      puts $0 + '   '
      exit
    end
    
    usage if $*.size < 3
    
     set up Management::Partition and LocalLB::Pool interfaces
    
    bigip = F5::IControl.new($*[0], $*[1], $*[2], \
    ['Management.Partition', 'LocalLB.Pool']).get_interfaces
    
     grab a list of partition and loop through them
    
    partitions = bigip['Management.Partition'].get_partition_list
    
    partitions.each do |partition|
    
       set the active partition to query
    
      partitions = bigip['Management.Partition'].set_active_partition(partition['partition_name'])
    
      puts ('' * 5) + " {partition['partition_name']} " + ('' *5)
      puts
    
       grab a list of pools and stuff the array into a variable
    
      pools = bigip['LocalLB.Pool'].get_list.sort
    
      pool_active_members = bigip['LocalLB.Pool'].get_active_member_count(pools)
    
      [ pools, pool_active_members ].transpose.each do |pool|
        puts "{pool[0]} - {pool[1]} available members"
      end
    
      puts
    end

     

     

    -George
  • George_Watkins_'s avatar
    George_Watkins_
    Historic F5 Account
    I forgot to add the output. If you execute that script, your output will look like this:

    f5-test-linux examples % ./report-down-pools.rb 10.0.0.1 admin admin  Common  
    test_http_pool - 0 available members ftp_pool - 0 available members laptop-iis - 0 available members ntp_pool - 0 available members p.test_local_dns - 2 available membersp.test_249_http - 1 available members ssh_pool - 0 available members ubuntu_http_pool - 0 available members
    

    If you want to only report pools without members you can add an if statement to only catch those pools reporting '0' active members:

    puts "{pool[0]} has ZERO available members" if pool[1] == 0

    -George