• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

moomindani/aws-mon-linux: Bash script that reports custom metric data about Linu ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

moomindani/aws-mon-linux

开源软件地址(OpenSource Url):

https://github.com/moomindani/aws-mon-linux

开源编程语言(OpenSource Language):

Shell 100.0%

开源软件介绍(OpenSource Introduction):

aws-mon-linux

Bash script that reports custom metric data about Linux performance to Amazon CloudWatch

This script is intended for use with Amazon EC2 instances running Linux operating systems. The scripts have been tested on the following Amazon Machine Images (AMIs) for both 32-bit and 64-bit versions:

  • Amazon Linux 2014.3
  • Red Hat Enterprise Linux 6.4
  • Ubuntu Server 13.10

The script is written in simple Bash, so you can use it very easily. The script is almost compatible with Amazon CloudWatch Monitoring Scripts for Linux, so you can use almost same options.

Metrics of This Script

This script can report the following metrics:

  • load average
  • interrupt
  • context switch
  • cpu (user/system/idle/wait/steal)
  • memory
  • swap
  • disk

Prerequisites

This script requires AWS Command Line Interface.

Amazon Linux

Instances that you launch using the Amazon Linux AMI already include the CLI tools.

All you have to do is to install git.

yum install git

RHEL, Ubuntu

RHEL

Install git.

yum install git

Ubuntu

Install git, unzip and jre.

apt-get install git
apt-get install unzip
apt-get install default-jre

RHEL, Ubuntu

You can install AWS Command Line Interface with following steps:

pip install awscli

Getting Started

Download "aws-mon.sh" or clone repository using following steps:

git clone https://github.com/moomindani/aws-mon-linux.git
cd aws-mon-linux
./aws-mon.sh --help

Using the Script

This script collects load average, cpu, memory, swap, and disk space utilization data on the current system. It then makes a remote call to Amazon CloudWatch to report the collected data as custom metrics.

Option

Name Description
--help Displays usage information.
--version Displays the version number.
--verify Checks configuration and prepares a remote call.
--verbose Displays details of what the script is doing.
--debug Displays information for debugging.
--from-cron Use this option when calling the script from cron.
--profile VALUE Use a specific profile from your credential file.
--load-ave1 Reports load average for 1 minute in counts.
--load-ave5 Reports load average for 5 minutes in counts.
--load-ave15 Reports load average for 15 minutes in counts.
--interrupt Reports interrupt in counts.
--context-switch Reports context switch in counts.
--cpu-us Reports cpu utilization (user) in percentages.
--cpu-sy Reports cpu utilization (system) in percentages.
--cpu-id Reports cpu utilization (idle) in percentages.
--cpu-wa Reports cpu utilization (wait) in percentages.
--cpu-st Reports cpu utilization (steal) in percentages.
--memory-units UNITS Specifies units in which to report memory usage. If not specified, memory is reported in megabytes. UNITS may be one of the following: bytes, kilobytes, megabytes, gigabytes.
--mem-used-incl-cache-buff Count memory that is cached and in buffers as used.
--mem-util Reports memory utilization in percentages.
--mem-used Reports memory used in megabytes.
--mem-avail Reports available memory in megabytes.
--swap-util Reports swap utilization in percentages.
--swap-used Reports allocated swap space in megabytes.
--swap-avail Reports available swap space in megabytes.
--disk-path PATH Selects the disk by the path on which to report.
--disk-space-units UNITS Specifies units in which to report disk space usage. If not specified, disk space is reported in gigabytes. UNITS may be one of the following: bytes, kilobytes, megabytes, gigabytes.
--disk-space-util Reports disk space utilization in percentages.
--disk-space-used Reports allocated disk space in gigabytes.
--disk-space-avail Reports available disk space in gigabytes.
--all-items Reports all items.

Examples

The following examples assume that you have already configured awscli with "aws configure".

To perform a simple test run without posting data to CloudWatch

  • Run the following command:
./aws-mon.sh --mem-util --verify --verbose

To collect all available cpu metrics and send them to CloudWatch

  • Run the following command:
./aws-mon.sh --cpu-us --cpu-sy --cpu-id --cpu-wa --cpu-st

To collect all available memory metrics and send them to CloudWatch

  • Run the following command:
./aws-mon.sh --mem-util --mem-used --mem-avail

To collect all available disk metrics and send them to CloudWatch

  • Run the following command:
./aws-mon.sh --disk-space-util --disk-space-used --disk-space-avail --disk-path /

To collect all load average metrics and send them to CloudWatch

  • Run the following command:
./aws-mon.sh --load-ave1 --load-ave5 --load-ave15

To set a cron schedule for metrics reported to CloudWatch

  1. Start editing the crontab using the following command:
crontab -e
  1. Add the following command to report all items to CloudWatch every five minutes:
*/5 * * * *  ~/aws-mon-linux/aws-mon.sh --all-items --disk-path=/ --from-cron



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap