import json
import logging
-logging.basicConfig(filename='MON_plugins.log',
- format='%(asctime)s %(message)s',
- datefmt='%m/%d/%Y %I:%M:%S %p', filemode='a',
- level=logging.INFO)
log = logging.getLogger(__name__)
class AccessCredentials():
+ def logtest(self):
+ log.info("Access credentials sourced for CloudWatch MON plugin")
+
+
def access_credential_calls(self,message):
try:
message = json.loads(message.value)['access_config']
except Exception as e:
log.error("Access credentials not provided correctly: %s", str(e))
+
import boto.vpc
import boto.ec2.cloudwatch
import boto.ec2.connection
- import logging as log
+ import logging
from boto.ec2.cloudwatch.alarm import MetricAlarm
from boto.ec2.cloudwatch.dimension import Dimension
from boto.sns import connect_to_region
except:
exit("Boto not avialable. Try activating your virtualenv OR `pip install boto`")
+log = logging.getLogger(__name__)
class Connection():
"""Connection Establishement with AWS -- VPC/EC2/CloudWatch"""
self.AWS_REGION = os.environ.get("AWS_EC2_REGION","us-west-2")
#TODO Read from the cloudwatch_credentials.txt file
-
+
return self.connection_instance()
except Exception as e:
log.error("AWS Credentials not configured, Try setting the access credentials first %s: ",str(e))
import datetime
import random
import json
-import logging as log
+import logging
from random import randint
from operator import itemgetter
from connection import Connection
+log = logging.getLogger(__name__)
try:
import boto
import sys
import datetime
import json
-import logging as log
+import logging
try:
import boto
except:
exit("Boto not avialable. Try activating your virtualenv OR `pip install boto`")
-
+log = logging.getLogger(__name__)
class Metrics():
import sys
import json
-import logging as log
+import logging
from jsmin import jsmin
from connection import Connection
from metric_alarms import MetricAlarm
sys.path.append("../../core/message_bus")
from producer import KafkaProducer
+log = logging.getLogger(__name__)
+
class plugin_alarms():
"""Receives Alarm info from MetricAlarm and connects with the consumer/producer"""
def __init__ (self):
from metrics import Metrics
sys.path.append("../../core/message_bus")
from producer import KafkaProducer
-import logging as log
+import logging
+
+log = logging.getLogger(__name__)
class plugin_metrics():
"""Receives Alarm info from MetricAlarm and connects with the consumer/producer """
#---------------------------------------------------------------------------------------------------------------------------
def metric_calls(self,message,aws_conn):
- '''Consumer will consume the message from SO,
- 1) parse the message and trigger the methods ac
- cording to keys and topics provided in request.
-
- 2) The response from plugin is saved in json format.
-
- 3) The producer object then calls the producer response
- methods to send the response back to message bus
- '''
+ """Gets the message from the common consumer"""
try:
self.cloudwatch_conn = aws_conn['cloudwatch_connection']