Exemplo n.º 1
0
def DataPlaneBufferUtilization(root, namespace, asg_name):
    logger.info('DataPlaneBufferUtilization...')
    logger.info('root[0][1].text: ' + str(root[0].text))

    hw_buf = str(root[0].text)
    hw_buf = hw_buf.replace("hardware buffer", '"hardware buffer"')
    hw_buf = hw_buf.replace("packet descriptor", '"packet descriptor"')
    hw_buf = hw_buf.replace("software buffer", '"software buffer"')
    d = valueToDict(hw_buf, "sw.mprelay.s1.dp0.packetbuffers:")
    if d is None:
        pan_print('Error happened in DataPlaneBufferUtilization: ' +
                  str(root[0].text))
        return

    pan_print('Get is: ' + str(d.get('hw-buf')))
    max = str(d['hw-buf']['max'])
    used = str(d['hw-buf']['used'])
    m = float(max)
    u = float(used)
    v = (u / m) * 100
    value = float("{0:.2f}".format(v))
    pan_print('DataPlaneBufferUtilization in percentage: Max: ' + max +
              ' Used: ' + used + ' Util: ' + str(value))

    if remote == 0:
        return

    if sqs_msg is not None:
        v = lib.getScalingValue(sqs_msg, ScalingParameter)
        if v is not None:
            print(sqs_msg)
            logger.info('Pushing simulated data to CW: ' + str(v))
            value = float(v)
        else:
            logger.info('Starting to Publish metrics in namespace: ' +
                        namespace)
    else:
        logger.info('Starting to Publish metrics in namespace: ' + namespace)

    timestamp = datetime.datetime.utcnow()
    response = cw_client.put_metric_data(Namespace=namespace,
                                         MetricData=[{
                                             'MetricName':
                                             'DataPlaneBufferUtilization',
                                             'Dimensions': [{
                                                 'Name':
                                                 'AutoScalingGroupName',
                                                 'Value': asg_name
                                             }],
                                             'Timestamp':
                                             timestamp,
                                             'Value':
                                             value,
                                             'Unit':
                                             'Percent'
                                         }])

    logger.info("[INFO]: Published GOOD metric for {}".format(gwMgmtIp))
    return
Exemplo n.º 2
0
def GPGatewayUtilization(root, namespace, asg_name):
    logger.info('GPGatewayUtilization...')
    logger.info('root[0][1].text: ' + str(root[0].text))
    d = valueToString(str(root[0].text), "sw.rasmgr.resource.tunnel:")
    if d is None:
        pan_print('Error happened in DataPlaneBufferUtilization: ' +
                  str(root[0].text))
        return

    list = d.split(" ")
    cur = list[3]
    max = list[5]

    cur = str(int(cur, 16))
    max = str(int(max, 16))

    m = float(max)
    u = float(cur)
    v = (u / m) * 100
    value = float("{0:.2f}".format(v))
    pan_print('GPGatewayUtilization in percentage: Max: ' + max + ' Cur: ' +
              cur + ' Util: ' + str(value))

    if remote == 0:
        return

    if sqs_msg is not None:
        v = lib.getScalingValue(sqs_msg, ScalingParameter)
        if v is not None:
            print(sqs_msg)
            logger.info('Pushing simulated data to CW: ' + str(v))
            value = float(v)
        else:
            logger.info('Starting to Publish metrics in namespace: ' +
                        namespace)
    else:
        logger.info('Starting to Publish metrics in namespace: ' + namespace)

    timestamp = datetime.datetime.utcnow()
    response = cw_client.put_metric_data(Namespace=namespace,
                                         MetricData=[{
                                             'MetricName':
                                             'GPGatewayUtilization',
                                             'Dimensions': [{
                                                 'Name':
                                                 'AutoScalingGroupName',
                                                 'Value': asg_name
                                             }],
                                             'Timestamp':
                                             timestamp,
                                             'Value':
                                             value,
                                             'Unit':
                                             'Percent'
                                         }])

    logger.info("[INFO]: Published GOOD metric for {}".format(gwMgmtIp))
    return
Exemplo n.º 3
0
def DataPlaneCPUUtilization(root, namespace, asg_name):
    logger.info('DataPlaneCPUUtilization')
    logger.info('root[0][1].text: ' + str(root[0].text))
    cpu = ""
    d = valueToDict(str(root[0].text), "sys.monitor.s1.dp0.exports:")
    if d is None:
        pan_print('Error happened in DataPlaneCPUUtilization: ' +
                  str(root[0].text))
        return

    cpu = float(d['cpu']['1minavg'])
    pan_print('DataPlaneCPUUtilization in percentage: ' + str(cpu))

    if remote == 0:
        return

    if sqs_msg is not None:
        v = lib.getScalingValue(sqs_msg, ScalingParameter)
        if v is not None:
            print(sqs_msg)
            logger.info('Pushing simulated data to CW: ' + str(v))
            cpu = float(v)
        else:
            logger.info('Starting to Publish metrics in namespace: ' +
                        namespace)
    else:
        logger.info('Starting to Publish metrics in namespace: ' + namespace)

    timestamp = datetime.datetime.utcnow()
    response = cw_client.put_metric_data(Namespace=namespace,
                                         MetricData=[{
                                             'MetricName':
                                             'DataPlaneCPUUtilization',
                                             'Dimensions': [{
                                                 'Name':
                                                 'AutoScalingGroupName',
                                                 'Value': asg_name
                                             }],
                                             'Timestamp':
                                             timestamp,
                                             'Value':
                                             cpu,
                                             'Unit':
                                             'Percent'
                                         }])

    logger.info("[INFO]: Published GOOD metric for {}".format(gwMgmtIp))
    return
Exemplo n.º 4
0
def ActiveSessions(root, namespace, asg_name):
    #Now to find number of active sessions
    logger.info('ActiveSessions...')
    logger.info('root[0][1].text: ' + str(root[0].text))
    value = ""
    d = valueToDict(str(root[0].text), "sw.mprelay.s1.dp0.stats.session:")
    if d is None:
        pan_print('Error happened in ActiveSessions: ' + str(root[0].text))
        return

    value = float(d['session_active'])
    pan_print('ActiveSessions in numbers: ' + str(value))

    if remote == 0:
        return

    if sqs_msg is not None:
        v = lib.getScalingValue(sqs_msg, ScalingParameter)
        if v is not None:
            print(sqs_msg)
            logger.info('Pushing simulated data to CW: ' + str(v))
            value = float(v)
        else:
            logger.info('Starting to Publish metrics in namespace: ' +
                        namespace)
    else:
        logger.info('Starting to Publish metrics in namespace: ' + namespace)

    timestamp = datetime.datetime.utcnow()
    response = cw_client.put_metric_data(Namespace=namespace,
                                         MetricData=[{
                                             'MetricName':
                                             'ActiveSessions',
                                             'Dimensions': [{
                                                 'Name':
                                                 'AutoScalingGroupName',
                                                 'Value': asg_name
                                             }],
                                             'Timestamp':
                                             timestamp,
                                             'Value':
                                             value,
                                             'Unit':
                                             'Count'
                                         }])

    logger.info("[INFO]: Published GOOD metric for {}".format(gwMgmtIp))
    return
Exemplo n.º 5
0
def SessionUtilization(root, namespace, asg_name):
    logger.info('SessionUtilization')
    logger.info('root[0][1].text: ' + str(root[0].text))
    sess = 0.0
    d = valueToDict(str(root[0].text), "sw.mprelay.s1.dp0.stats.session:")
    if d is None:
        pan_print('Error happened in SessionUtilization: ' + str(root[0].text))
        return

    sess = float(d['session_util'])
    pan_print('SessionUtilization in percentage: ' + str(sess))

    if remote == 0:
        return

    if sqs_msg is not None:
        v = lib.getScalingValue(sqs_msg, ScalingParameter)
        if v is not None:
            print(sqs_msg)
            logger.info('Pushing simulated data to CW: ' + str(v))
            sess = float(v)
        else:
            logger.info('Starting to Publish metrics in namespace: ' +
                        namespace)
    else:
        logger.info('Starting to Publish metrics in namespace: ' + namespace)

    timestamp = datetime.datetime.utcnow()
    response = cw_client.put_metric_data(Namespace=namespace,
                                         MetricData=[{
                                             'MetricName':
                                             'SessionUtilization',
                                             'Dimensions': [{
                                                 'Name':
                                                 'AutoScalingGroupName',
                                                 'Value': asg_name
                                             }],
                                             'Timestamp':
                                             timestamp,
                                             'Value':
                                             sess,
                                             'Unit':
                                             'Percent'
                                         }])

    logger.info("[INFO]: Published GOOD metric for {}".format(gwMgmtIp))
    return