def run(self): servo.log.info('starting cloudwatch metrics reporter') elb_host = config.get_clc_host() servo_instance_id = config.get_servo_id() if elb_host is None or servo_instance_id is None: servo.log.error( 'some required parameters are missing; failed to start cloudwatch report loop' ) return while self.running: aws_access_key_id = config.get_access_key_id() aws_secret_access_key = config.get_secret_access_key() security_token = config.get_security_token() try: con = servo.ws.connect_elb( aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, security_token=security_token) metric = stat_instance.get_and_clear_stat() con.put_cw_metric(servo_instance_id, metric) servo.log.debug('reported the metrics: %s' % metric) except Exception, err: servo.log.error('failed to report the cloudwatch metrics: %s', err) cw_loop_delay = config.CWATCH_REPORT_PERIOD_SEC while cw_loop_delay > 0 and self.running: time.sleep(1) cw_loop_delay -= 1
def run(self): servo.log.info('starting cloudwatch metrics reporter') elb_host = config.get_clc_host() servo_instance_id = config.get_servo_id() if elb_host is None or servo_instance_id is None: servo.log.error('some required parameters are missing; failed to start cloudwatch report loop') return start_time = time.time() while time.time() - start_time < config.CWATCH_REPORT_PERIOD_SEC and self.running: time.sleep(1) while self.running: aws_access_key_id = config.get_access_key_id() aws_secret_access_key = config.get_secret_access_key() security_token = config.get_security_token() con = servo.ws.connect_elb(host_name=elb_host, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, security_token=security_token) try: metric = stat_instance.get_and_clear_stat() con.put_cw_metric(servo_instance_id, metric) servo.log.debug('reported the metrics: %s' % metric) except Exception, err: servo.log.error('failed to report the cloudwatch metrics: %s', err) start_time = time.time() while time.time() - start_time < config.CWATCH_REPORT_PERIOD_SEC and self.running: time.sleep(1)
def __init__(self): # get the instance id from metadata service self.__instance_id = None self.__elb_host = config.get_clc_host() # TODO: should query user-data if self.__instance_id is None: self.__instance_id = config.get_servo_id() self.__status = ServoLoop.STOPPED servo.log.debug('main loop running with elb_host=%s, instance_id=%s' % (self.__elb_host, self.__instance_id))
def __init__(self): # get the instance id from metadata service self.__instance_id = None self.__elb_host = config.get_clc_host() # TODO: should query user-data if self.__instance_id is None: self.__instance_id = config.get_servo_id() self.__redis = None self.__pubsub = None servo.log.debug('main loop running with elb_host=%s, instance_id=%s' % (self.__elb_host, self.__instance_id))
def __init__(self): # get the instance id from metadata service self.__instance_id = None self.__elb_host = config.get_clc_host() # TODO: should query user-data if self.__instance_id is None: self.__instance_id = config.get_servo_id() self.__redis = None self.__pubsub = None servo.log.debug("main loop running with elb_host=%s, instance_id=%s" % (self.__elb_host, self.__instance_id))