Code Monkey home page Code Monkey logo

aws-mon-linux's 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

aws-mon-linux's People

Contributors

moomindani avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.