(self)
Collector for average disk busyness per aggregate

            As of Nov 22nd 2013 there is no API call for agr busyness.
            You have to collect all disk busyness and then compute agr
            busyness. #fml
Collector for average disk busyness per aggregate
Collector for average disk busyness per aggregate
def agr_busy(self):
        """ Collector for average disk busyness per aggregate

            As of Nov 22nd 2013 there is no API call for agr busyness.
            You have to collect all disk busyness and then compute agr
            busyness. #fml

        """

        c1 = {}  # Counters from time a
        c2 = {}  # Counters from time b
        disk_results = {}  # Disk busyness results %
        agr_results = {}  # Aggregate busyness results $
        names = ['disk_busy', 'base_for_disk_busy', 'raid_name',
                 'base_for_disk_busy', 'instance_uuid']
        netapp_api = NaElement('perf-object-get-instances')
        netapp_api.child_add_string('objectname', 'disk')
        disk_1 = self.get_netapp_elem(netapp_api, 'instances')
        time.sleep(1)
        disk_2 = self.get_netapp_elem(netapp_api, 'instances')

        for instance_data in disk_1:
            temp = {}
            for element in instance_data.findall(".//counters/counter-data"):
                if element.find('name').text in names:
                    temp[element.find('name').text] = element.find(
                        'value').text

            agr_name = temp['raid_name']
            agr_name = agr_name[agr_name.find('/', 0):agr_name.find('/', 1)]
            temp['raid_name'] = agr_name.lstrip('/')
            c1[temp.pop('instance_uuid')] = temp

        for instance_data in disk_2:
            temp = {}
            for element in instance_data.findall(".//counters/counter-data"):
                if element.find('name').text in names:
                    temp[element.find('name').text] = element.find(
                        'value').text

            agr_name = temp['raid_name']
            agr_name = agr_name[agr_name.find('/', 0):agr_name.find('/', 1)]
            temp['raid_name'] = agr_name.lstrip('/')
            c2[temp.pop('instance_uuid')] = temp

        for item in c1:
            t_c1 = int(c1[item]['disk_busy'])  # time_counter_1
            t_b1 = int(c1[item]['base_for_disk_busy'])  # time_base_1
            t_c2 = int(c2[item]['disk_busy'])
            t_b2 = int(c2[item]['base_for_disk_busy'])

            disk_busy = 100 * (t_c2 - t_c1) / (t_b2 - t_b1)

            if c1[item]['raid_name'] in disk_results:
                disk_results[c1[item]['raid_name']].append(disk_busy)
            else:
                disk_results[c1[item]['raid_name']] = [disk_busy]

        for aggregate in disk_results:
            agr_results[aggregate] = \
                sum(disk_results[aggregate]) / len(disk_results[aggregate])

        for aggregate in agr_results:
            self.push('avg_busy', 'aggregate.' + aggregate,
                      agr_results[aggregate])
def agr_busy ( self ) : c1 = { } # Counters from time a c2 = { } # Counters from time b disk_results = { } # Disk busyness results % agr_results = { } # Aggregate busyness results $ names = [ 'disk_busy' , 'base_for_disk_busy' , 'raid_name' , 'base_for_disk_busy' , 'instance_uuid' ] netapp_api = NaElement ( 'perf-object-get-instances' ) netapp_api . child_add_string ( 'objectname' , 'disk' ) disk_1 = self . get_netapp_elem ( netapp_api , 'instances' ) time . sleep ( 1 ) disk_2 = self . get_netapp_elem ( netapp_api , 'instances' ) for instance_data in disk_1 : temp = { } for element in instance_data . findall ( ".//counters/counter-data" ) : if element . find ( 'name' ) . text in names : temp [ element . find ( 'name' ) . text ] = element . find ( 'value' ) . text agr_name = temp [ 'raid_name' ] agr_name = agr_name [ agr_name . find ( '/' , 0 ) : agr_name . find ( '/' , 1 ) ] temp [ 'raid_name' ] = agr_name . lstrip ( '/' ) c1 [ temp . pop ( 'instance_uuid' ) ] = temp for instance_data in disk_2 : temp = { } for element in instance_data . findall ( ".//counters/counter-data" ) : if element . find ( 'name' ) . text in names : temp [ element . find ( 'name' ) . text ] = element . find ( 'value' ) . text agr_name = temp [ 'raid_name' ] agr_name = agr_name [ agr_name . find ( '/' , 0 ) : agr_name . find ( '/' , 1 ) ] temp [ 'raid_name' ] = agr_name . lstrip ( '/' ) c2 [ temp . pop ( 'instance_uuid' ) ] = temp for item in c1 : t_c1 = int ( c1 [ item ] [ 'disk_busy' ] ) # time_counter_1 t_b1 = int ( c1 [ item ] [ 'base_for_disk_busy' ] ) # time_base_1 t_c2 = int ( c2 [ item ] [ 'disk_busy' ] ) t_b2 = int ( c2 [ item ] [ 'base_for_disk_busy' ] ) disk_busy = 100 * ( t_c2 - t_c1 ) / ( t_b2 - t_b1 ) if c1 [ item ] [ 'raid_name' ] in disk_results : disk_results [ c1 [ item ] [ 'raid_name' ] ] . append ( disk_busy ) else : disk_results [ c1 [ item ] [ 'raid_name' ] ] = [ disk_busy ] for aggregate in disk_results : agr_results [ aggregate ] = sum ( disk_results [ aggregate ] ) / len ( disk_results [ aggregate ] ) for aggregate in agr_results : self . push ( 'avg_busy' , 'aggregate.' + aggregate , agr_results [ aggregate ] )