(self)
Collect s3 bucket stats
Collect s3 bucket stats
Collect s3 bucket stats
def collect(self):
        """
        Collect s3 bucket stats
        """
        if boto is None:
            self.log.error("Unable to import boto python module")
            return {}
        for s3instance in self.config['s3']:
            self.log.info("S3: byte_unit: %s" % self.config['byte_unit'])
            aws_access = self.config['s3'][s3instance]['aws_access_key']
            aws_secret = self.config['s3'][s3instance]['aws_secret_key']
            for bucket_name in self.config['s3'][s3instance]['buckets']:
                bucket = self.getBucket(aws_access, aws_secret, bucket_name)

                # collect bucket size
                total_size = self.getBucketSize(bucket)
                for byte_unit in self.config['byte_unit']:
                    new_size = diamond.convertor.binary.convert(
                        value=total_size,
                        oldUnit='byte',
                        newUnit=byte_unit
                    )
                    self.publish("%s.size.%s" % (bucket_name, byte_unit),
                                 new_size)
def collect ( self ) : if boto is None : self . log . error ( "Unable to import boto python module" ) return { } for s3instance in self . config [ 's3' ] : self . log . info ( "S3: byte_unit: %s" % self . config [ 'byte_unit' ] ) aws_access = self . config [ 's3' ] [ s3instance ] [ 'aws_access_key' ] aws_secret = self . config [ 's3' ] [ s3instance ] [ 'aws_secret_key' ] for bucket_name in self . config [ 's3' ] [ s3instance ] [ 'buckets' ] : bucket = self . getBucket ( aws_access , aws_secret , bucket_name ) # collect bucket size total_size = self . getBucketSize ( bucket ) for byte_unit in self . config [ 'byte_unit' ] : new_size = diamond . convertor . binary . convert ( value = total_size , oldUnit = 'byte' , newUnit = byte_unit ) self . publish ( "%s.size.%s" % ( bucket_name , byte_unit ) , new_size )