<commit_before>import boto
import boto.redshift
import sys

from boundary_aws_plugin.cloudwatch_plugin import CloudwatchPlugin
from boundary_aws_plugin.cloudwatch_metrics import CloudwatchMetrics


class RedshiftCloudwatchMetrics(CloudwatchMetrics):
    def __init__(self, access_key_id, secret_access_key):
        return super(RedshiftCloudwatchMetrics, self).__init__(access_key_id, secret_access_key, 'AWS/Redshift')

    def get_region_list(self):
        return boto.redshift.regions()

    def get_entities_for_region(self, region):
        rs = boto.connect_redshift(self.access_key_id, self.secret_access_key, region=region)
        return rs.describe_clusters()['DescribeClustersResponse']['DescribeClustersResult']['Clusters']

    def get_entity_source_name(self, cluster):
        return cluster['ClusterIdentifier']

    def get_entity_dimensions(self, region, cluster):
        return dict(ClusterIdentifier=cluster['ClusterIdentifier'])

    def get_metric_list(self):
        return (
            ('CPUUtilization', 'Average', 'AWS_REDSHIFT_CPU_UTILIZATION'),
            ('DatabaseConnections', 'Average', 'AWS_REDSHIFT_DATABASE_CONNECTIONS'),
            ('HealthStatus', 'Average', 'AWS_REDSHIFT_HEALTH_STATUS'),
            ('MaintenanceMode', 'Average', 'AWS_REDSHIFT_MAINTENANCE_MODE'),
            ('NetworkReceiveThroughput', 'Average', 'AWS_REDSHIFT_NETWORK_RECEIVE_THROUGHPUT'),
            ('NetworkTransmitThroughput', 'Average', 'AWS_REDSHIFT_NETWORK_TRANSMIT_THROUGHPUT'),
            ('PercentageDiskSpaceUsed', 'Average', 'AWS_REDSHIFT_PERCENTAGE_DISK_SPACE_USED'),
        )


if __name__ == '__main__':
    if len(sys.argv) > 1 and sys.argv[1] == '-v':
        import logging
        logging.basicConfig(level=logging.INFO)

    plugin = CloudwatchPlugin(RedshiftCloudwatchMetrics, '', 'boundary-plugin-aws-redshift-python-status')
    plugin.main()
<commit_msg>Added NEM prefix to metrics.<commit_after>import boto
import boto.redshift
import sys

from boundary_aws_plugin.cloudwatch_plugin import CloudwatchPlugin
from boundary_aws_plugin.cloudwatch_metrics import CloudwatchMetrics


class RedshiftCloudwatchMetrics(CloudwatchMetrics):
    def __init__(self, access_key_id, secret_access_key):
        return super(RedshiftCloudwatchMetrics, self).__init__(access_key_id, secret_access_key, 'AWS/Redshift')

    def get_region_list(self):
        return boto.redshift.regions()

    def get_entities_for_region(self, region):
        rs = boto.connect_redshift(self.access_key_id, self.secret_access_key, region=region)
        return rs.describe_clusters()['DescribeClustersResponse']['DescribeClustersResult']['Clusters']

    def get_entity_source_name(self, cluster):
        return cluster['ClusterIdentifier']

    def get_entity_dimensions(self, region, cluster):
        return dict(ClusterIdentifier=cluster['ClusterIdentifier'])

    def get_metric_list(self):
        return (
            ('CPUUtilization', 'Average', 'AWS_REDSHIFT_CPU_UTILIZATION'),
            ('DatabaseConnections', 'Average', 'AWS_REDSHIFT_DATABASE_CONNECTIONS'),
            ('HealthStatus', 'Average', 'AWS_REDSHIFT_HEALTH_STATUS'),
            ('MaintenanceMode', 'Average', 'AWS_REDSHIFT_MAINTENANCE_MODE'),
            ('NetworkReceiveThroughput', 'Average', 'AWS_REDSHIFT_NETWORK_RECEIVE_THROUGHPUT'),
            ('NetworkTransmitThroughput', 'Average', 'AWS_REDSHIFT_NETWORK_TRANSMIT_THROUGHPUT'),
            ('PercentageDiskSpaceUsed', 'Average', 'AWS_REDSHIFT_PERCENTAGE_DISK_SPACE_USED'),
        )


if __name__ == '__main__':
    if len(sys.argv) > 1 and sys.argv[1] == '-v':
        import logging
        logging.basicConfig(level=logging.INFO)

    plugin = CloudwatchPlugin(RedshiftCloudwatchMetrics, 'NEM_', 'boundary-plugin-aws-redshift-python-status')
    plugin.main()

{'fraction_non_alphanumeric': 0.10621557828481511, 'fraction_numerical': 0.001049042748492001, 'mean_word_length': 4.726726726726727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3697431', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1133, 'n_words': 183}