Send a ping request to a lambda function.

    :param awsclient:
    :param function_name:
    :param start_dt:
    :param end_dt:
    :param tail:
    :return:
4661
def logs(awsclient, function_name, start_dt, end_dt=None, tail=False):
    
    log.debug('Getting cloudwatch logs for: %s', function_name)
    log_group_name = '/aws/lambda/%s' % function_name

    current_date = None
    start_ts = datetime_to_timestamp(start_dt)
    if end_dt:
        end_ts = datetime_to_timestamp(end_dt)
    else:
        end_ts = None

    # tail mode
    # we assume that logs can arrive late but not out of order
    # so we hold the timestamp of the last logentry and start the next iteration
    # from there
    while True:
        logentries = filter_log_events(awsclient, log_group_name,
                                       start_ts=start_ts, end_ts=end_ts)
        if logentries:
            for e in logentries:
                actual_date, actual_time = decode_format_timestamp(e['timestamp'])
                if current_date != actual_date:
                    # print the date only when it changed
                    current_date = actual_date
                    log.info(current_date)
                log.info('%s  %s' % (actual_time, e['message'].strip()))
        if tail:
            if logentries:
                start_ts = logentries[-1]['timestamp'] + 1
            time.sleep(2)
            continue
        break
150221
def ping(self, timestamp=None):
        
        cmd = 'ping'
        if timestamp: cmd += ' %s' % timestamp
        return tuple(map(float, self.fetch(cmd)[1].split()[1:]))
1265237
def ping(self):
        
        from datetime import datetime
        nextRun = datetime.utcnow().timestamp() + self.cfg.getPingInterval()
        self.sendHeartbeat()
        self.scheduleNextHeartbeat(nextRun)
290540
def send(self, endpoint, json_message):
        
        _send_event_task.spool(endpoint=endpoint, json_message=json_message)
392315
def get_function(session_factory, name, role, sns_topic, log_groups,
                 subject="Lambda Error", pattern="Traceback"):
    

    # Lazy import to avoid runtime dependency
    from c7n.mu import (
        LambdaFunction, PythonPackageArchive, CloudWatchLogSubscription)

    config = dict(
        name=name,
        handler='logsub.process_log_event',
        runtime='python2.7',
        memory_size=512,
        timeout=15,
        role=role,
        description='Custodian Ops Error Notify',
        events=[
            CloudWatchLogSubscription(
                session_factory, log_groups, pattern)])

    archive = PythonPackageArchive()
    archive.add_py_file(__file__)
    archive.add_contents(
        'config.json', json.dumps({
            'topic': sns_topic,
            'subject': subject
        }))
    archive.close()

    return LambdaFunction(config, archive)
864850
async def handle_client_ping(self, client_addr, _: Ping):
        
        await ZMQUtils.send_with_addr(self._client_socket, client_addr, Pong())
1043712
def ping(self):
        
        start = time.time()
        self._conn.ping()
        return (time.time() - start)
907200
def list_functions(awsclient):
    
    client_lambda = awsclient.get_client('lambda')
    response = client_lambda.list_functions()
    for function in response['Functions']:
        log.info(function['FunctionName'])
        log.info('\t' 'Memory: ' + str(function['MemorySize']))
        log.info('\t' 'Timeout: ' + str(function['Timeout']))
        log.info('\t' 'Role: ' + str(function['Role']))
        log.info('\t' 'Current Version: ' + str(function['Version']))
        log.info('\t' 'Last Modified: ' + str(function['LastModified']))
        log.info('\t' 'CodeSha256: ' + str(function['CodeSha256']))

        log.info('\n')
    return 0
957239
def _send(self, message):
        
        message['command'] = 'zappa.asynchronous.route_sns_task'
        payload = json.dumps(message).encode('utf-8')
        if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover
            raise AsyncException("Payload too large for SNS")
        self.response = self.client.publish(
                                TargetArn=self.arn,
                                Message=payload
                            )
        self.sent = self.response.get('MessageId')
488389
def _lambda_add_s3_event_source(awsclient, arn, event, bucket, prefix,
                                suffix):
    
    json_data = {
        'LambdaFunctionConfigurations': [{
            'LambdaFunctionArn': arn,
            'Id': str(uuid.uuid1()),
            'Events': [event]
        }]
    }

    filter_rules = build_filter_rules(prefix, suffix)

    json_data['LambdaFunctionConfigurations'][0].update({
        'Filter': {
            'Key': {
                'FilterRules': filter_rules
            }
        }
    })
    # http://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-notification-configuration.html
    # http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
    client_s3 = awsclient.get_client('s3')

    bucket_configurations = client_s3.get_bucket_notification_configuration(
        Bucket=bucket)
    bucket_configurations.pop('ResponseMetadata')

    if 'LambdaFunctionConfigurations' in bucket_configurations:
        bucket_configurations['LambdaFunctionConfigurations'].append(
            json_data['LambdaFunctionConfigurations'][0]
        )
    else:
        bucket_configurations['LambdaFunctionConfigurations'] = json_data[
            'LambdaFunctionConfigurations']

    response = client_s3.put_bucket_notification_configuration(
        Bucket=bucket,
        NotificationConfiguration=bucket_configurations
    )
    # TODO don't return a table, but success state
    return json2table(response)
748697
def get_lambda_function(self, function_name):
        
        response = self.lambda_client.get_function(
                FunctionName=function_name)
        return response['Configuration']['FunctionArn']
885149
def on_ping(self, data):
        
        self.log.debug('jupyter_server_proxy: on_ping: {}'.format(data))
        self._record_activity()
        if hasattr(self, 'ws'):
            self.ws.protocol.write_ping(data)
1033443
def Ping(self, request, context):
        
        status =  processor_pb2.Status()
        status.message='alive'
        return status
1130217
def ping(self, event):
        """"""

        self.log('Client ping received:', event.data, lvl=verbose)
        response = {
            'component': 'hfos.ui.clientmanager',
            'action': 'pong',
            'data': [event.data, time() * 1000]
        }

        self.fire(send(event.client.uuid, response))
70498
def ping(self):
    

    msg = "PING\0"
    self.sfile.write(msg)

    ret, output = self.__response__()
    reply = str(output[0])

    if ret:
      msg = "Error pinging server %d:%s" % (ret, reply)
      raise LDBDClientException, msg

    return reply
1196184
def send(transport, time, state, host, description, service, tag, attribute,
         ttl, metric_f, echo):
    """"""
    client = CommandLineClient(transport)
    event = client.create_event({
        'time': time,
        'state': state,
        'host': host,
        'description': description,
        'service': service,
        'tags': tag,
        'attributes': dict(attribute),
        'ttl': ttl,
        'metric_f': metric_f
    })

    with client:
        client.send_event(event)
    if echo:
        echo_event(client.create_dict(event))
52526
async def client_start(self):
        
        await self._start_socket()
        await self._on_connect()

        self._ping_count = 0

        # Start the loops, and don't forget to add them to the list of asyncio task to close when the client restarts
        task_socket = self._loop.create_task(self._run_socket())
        task_ping = self._loop.create_task(self._do_ping())

        self._restartable_tasks.append(task_ping)
        self._restartable_tasks.append(task_socket)