<commit_before>from __future__ import (absolute_import, print_function)
from boto3.session import Session
import datetime


def get_boto3_session(aws_config):
    return Session(region_name=aws_config.region,
                   aws_access_key_id=aws_config.access_key_id,
                   aws_secret_access_key=aws_config.secret_access_key)


def ec2_stats(aws_config=None, instance_id=None):
    session = get_boto3_session(aws_config)
    cloudwatch_client = session.client('cloudwatch')
    #import datetime
    #print(instance_id)
    out = cloudwatch_client.get_metric_statistics(
            Namespace='AWS/EC2',
            MetricName='CPUUtilization',
            Dimensions=[
                {
                 'Name': 'InstanceId',
                 'Value': instance_id
                }
            ],
            StartTime=datetime.datetime.utcnow() - datetime.timedelta(seconds=3600),
            EndTime=datetime.datetime.utcnow(),
            Period=1800,
            Statistics=[
                'Average',
            ],
            Unit='Percent'
        )
    # 'SampleCount'|'Average'|'Sum'|'Minimum'|'Maximum',
    # Unit='Seconds'|'Microseconds'|'Milliseconds'|'Bytes'|'Kilobytes'|'Megabytes'|'Gigabytes'|'Terabytes'|'Bits'|'Kilobits'|'Megabits'|'Gigabits'|'Terabits'|'Percent'|'Count'|'Bytes/Second'|'Kilobytes/Second'|'Megabytes/Second'|'Gigabytes/Second'|'Terabytes/Second'|'Bits/Second'|'Kilobits/Second'|'Megabits/Second'|'Gigabits/Second'|'Terabits/Second'|'Count/Second'|'None'

    print(out)
    #account_id = iam_client.get_user().get('User').get('Arn').split(':')[4]
    #output_account_info(output_media='console',
    #                    account_id=account_id,
    #                    account_aliases=aliases)


    #session = get_boto3_session(aws_config)
    #conn = session.resource('ec2')
    #instance = conn.Instance(instance_id)
    #print(instance.monitoring)
    #output_ec2_info(output_media='console',
    #                instance=conn.Instance(instance_id))
    exit(0)


#def _get_network_in_utilisation_avg(conn=None, instance_id=None, period=None):
#    stat = conn.get_metric_statistics(
#        period, datetime.datetime.utcnow() - datetime.timedelta(seconds=period),
#        datetime.datetime.utcnow(),
#        'NetworkIn',
#        'AWS/EC2',<commit_msg>remove rubbish.<commit_after>from __future__ import (absolute_import, print_function)
from boto3.session import Session
import datetime


def get_boto3_session(aws_config):
    return Session(region_name=aws_config.region,
                   aws_access_key_id=aws_config.access_key_id,
                   aws_secret_access_key=aws_config.secret_access_key)


def ec2_stats(aws_config=None, instance_id=None):
    session = get_boto3_session(aws_config)
    cloudwatch_client = session.client('cloudwatch')
    out = cloudwatch_client.get_metric_statistics(
            Namespace='AWS/EC2',
            MetricName='CPUUtilization',
            Dimensions=[
                {
                 'Name': 'InstanceId',
                 'Value': instance_id
                }
            ],
            StartTime=datetime.datetime.utcnow() - datetime.timedelta(seconds=3600),
            EndTime=datetime.datetime.utcnow(),
            Period=1800,
            Statistics=[
                'Average',
            ],
            Unit='Percent'
        )
    # 'SampleCount'|'Average'|'Sum'|'Minimum'|'Maximum',
    # Unit='Seconds'|'Microseconds'|'Milliseconds'|'Bytes'|'Kilobytes'|'Megabytes'|'Gigabytes'|'Terabytes'|'Bits'|'Kilobits'|'Megabits'|'Gigabits'|'Terabits'|'Percent'|'Count'|'Bytes/Second'|'Kilobytes/Second'|'Megabytes/Second'|'Gigabytes/Second'|'Terabytes/Second'|'Bits/Second'|'Kilobits/Second'|'Megabits/Second'|'Gigabits/Second'|'Terabits/Second'|'Count/Second'|'None'

    print(out)
    exit(0)


#def _get_network_in_utilisation_avg(conn=None, instance_id=None, period=None):
#    stat = conn.get_metric_statistics(
#        period, datetime.datetime.utcnow() - datetime.timedelta(seconds=period),
#        datetime.datetime.utcnow(),
#        'NetworkIn',
#        'AWS/EC2',
{'fraction_non_alphanumeric': 0.13693957115009747, 'fraction_numerical': 0.008284600389863547, 'mean_word_length': 3.171747967479675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3604904', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1357, 'n_words': 129}