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.
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
请发表评论