zoukankan      html  css  js  c++  java
  • Lab_4_SysOps_Monitoring_Linux_v2.5

    System Operations - Lab 4: Monitoring with CloudWatch (Linux) - 2.5
    ==================================================================================================================
    
    Using this command reference.
    
    ==================================================================================================================
    
    1. Locate the section you need. Each section in this file matches a section in the lab instructions.
    
    
    2. Replace items in angle brackets - < > - with appropriate values. For example, in this command you would replace the value - <JobFlowID> - (including the brackets) with the parameter indicated in the lab instructions:
    
       elastic-mapreduce --list <JobFlowID>.
    
       You can also use find and replace to change bracketed parameters in bulk.
    
    3. Do NOT enable the Word Wrap feature in Windows Notepad or the text editor you use to view this file.
    
    
    
    ++++1. Create Your Web Server++++
    
    ==================================================================================================================
    1.1 Create IAM Policy
    ==================================================================================================================
    
    1.1.5 Use the following custom policy
    
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Action": [
            "autoscaling:Describe*",
            "cloudwatch:*",
            "logs:*",
            "sns:*"
          ],
          "Effect": "Allow",
          "Resource": "*"
        }
      ]
    }
    
    ==================================================================================================================
    1.4 Create Web Server
    ==================================================================================================================
    
    1.4.1 Review the user data script
    
    #!/bin/bash
    yum -y update
    yum -y install httpd php
    chkconfig httpd on
    /etc/init.d/httpd start
    
    mkdir /var/awslogs
    mkdir /var/awslogs/state
    
    yum -y install awslogs
    
    cat > /etc/awslogs/awslogs.conf <<EOF
    [general]
    state_file = /var/awslogs/state/agent-state
    
    [HttpAccessLog]
    file = /var/log/httpd/access_log
    log_group_name = HttpAccessLog
    log_stream_name = {instance_id}
    datetime_format = %b %d %H:%M:%S
    
    [HttpErrorLog]
    file = /var/log/httpd/error_log
    log_group_name = HttpErrorLog
    log_stream_name = {instance_id}
    datetime_format = %b %d %H:%M:%S
    EOF
    
    REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -n 's/.$//p')
    sed -i "s/us-east-1/$REGION/g" /etc/awslogs/awscli.conf
    
    service awslogs start
    chkconfig awslogs on
    
    
    ++++2. Define CloudWatch Log Metrics++++
    
    ==================================================================================================================
    2.2 Create a CloudWatch Logs-Derived Metric
    ==================================================================================================================
    
    2.2.4 Paste the following filter pattern into the Filter Pattern text box
    
    [ip, id, user, timestamp, request, status_code=404, size]
    
    
    ++++3. Generate a Custom Metric from an Instance++++
    
    ==================================================================================================================
    3.3 Generate HTTPd Memory Usage Metric
    ==================================================================================================================
    
    3.3.1 Obtain current memory utilization of all HTTPd instances
    
    mem=$(ps -C httpd -O rss | gawk '{ count ++; sum += $2 }; END {count --; print sum/1024 ;};')
    
    3.3.2 Verify $mem
    
    echo $mem
    
    3.3.3 Retrieve the instance ID of the current instance
    
    instance_id=$(curl -s -w '
    ' http://169.254.169.254/latest/meta-data/instance-id)
    
    3.3.4 Verify $instance_id
    
    echo $instance_id
    
    3.3.5 Define your custom metric
    
    aws cloudwatch put-metric-data --namespace HttpServerMetrics --metric-name HttpServerMemUtilization --dimension InstanceId=$instance_id --value $mem --unit "Megabytes"
    
    
    
    漏 2016 Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 相关阅读:
    pixi.js 简单交互事件(点击、缩放、平移)
    w3school
    并发(Concurrent)与并行(Parallel)的区别
    CTime获得当前电脑时间
    NX二次开发-UFUN获得体的表面积,体积,重心等UF_MODL_ask_mass_props_3d
    Jvm故障问题排查以及Jvm调优总结
    jmap命令详解----查看JVM内存使用详情
    jstack命令解析
    年轻带Young GC算法示意图
    【JVM】jstat命令详解---JVM的统计监测工具
  • 原文地址:https://www.cnblogs.com/oskb/p/5943384.html
Copyright © 2011-2022 走看看