(self, config=None)
Create a new instance of cloudwatchHandler class
Create a new instance of cloudwatchHandler class
Create a new instance of cloudwatchHandler class
def __init__(self, config=None):
        """
          Create a new instance of cloudwatchHandler class
        """

        # Initialize Handler
        Handler.__init__(self, config)

        if not boto:
            self.log.error(
                "CloudWatch: Boto is not installed, please install boto.")
            return

        # Initialize Data
        self.connection = None

        # Initialize Options
        self.region = self.config['region']

        instance_metadata = boto.utils.get_instance_metadata()
        if 'instance-id' in instance_metadata:
            self.instance_id = instance_metadata['instance-id']
            self.log.debug("Setting InstanceId: " + self.instance_id)
        else:
            self.instance_id = None
            self.log.error('CloudWatch: Failed to load instance metadata')

        self.valid_config = ('region', 'collector', 'metric', 'namespace',
                             'name', 'unit', 'collect_by_instance',
                             'collect_without_dimension', 'dimensions')

        self.rules = []
        for key_name, section in self.config.items():
            if section.__class__ is Section:
                keys = section.keys()
                rules = self.get_default_rule_config()
                for key in keys:
                    if key not in self.valid_config:
                        self.log.warning("invalid key %s in section %s",
                                         key, section.name)
                    else:
                        rules[key] = section[key]

                self.rules.append(rules)

        # Create CloudWatch Connection
        self._bind()
def __init__ ( self , config = None ) : # Initialize Handler Handler . __init__ ( self , config ) if not boto : self . log . error ( "CloudWatch: Boto is not installed, please install boto." ) return # Initialize Data self . connection = None # Initialize Options self . region = self . config [ 'region' ] instance_metadata = boto . utils . get_instance_metadata ( ) if 'instance-id' in instance_metadata : self . instance_id = instance_metadata [ 'instance-id' ] self . log . debug ( "Setting InstanceId: " + self . instance_id ) else : self . instance_id = None self . log . error ( 'CloudWatch: Failed to load instance metadata' ) self . valid_config = ( 'region' , 'collector' , 'metric' , 'namespace' , 'name' , 'unit' , 'collect_by_instance' , 'collect_without_dimension' , 'dimensions' ) self . rules = [ ] for key_name , section in self . config . items ( ) : if section . __class__ is Section : keys = section . keys ( ) rules = self . get_default_rule_config ( ) for key in keys : if key not in self . valid_config : self . log . warning ( "invalid key %s in section %s" , key , section . name ) else : rules [ key ] = section [ key ] self . rules . append ( rules ) # Create CloudWatch Connection self . _bind ( )