linux-monitoring-cloudwatch

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2015 License: MIT Imports: 10 Imported by: 0

README

linux-monitoring-cloudwatch

Send MemoryUsage percentage metrics to AWS CloudWatch from Linux-based EC2 instances.

Why is this useful?

EC2 natively only sends hypervisor-visible metrics to CloudWatch (e.g. CPU usage). Others such as memory usage require OS-level integration - this is where linux-monitoring-cloudwatch comes in.

No further dependencies are necessary on your instance - just the executable.

With the metrics emitted by linux-monitoring-cloudwatch (MemoryUsage at this time), you may trigger alarms & autoscaling.

Example usage

./linux-monitoring-cloudwatch --namespace my-app/int --region eu-west-1

--region is optional: without providing it, linux-monitoring-cloudwatch will query the instance metadata API at runtime.

Building (with Docker)

docker run -v "$PWD":/go/src/github.com/darnould/linux-monitoring-cloudwatch -w /go/src/github.com/darnould/linux-monitoring-cloudwatch golang:1.3 go build

This will produce a single linux-monitoring-cloudwatch executable.

Installation

  • Build or download the executable.
  • Copy the linux-monitoring-cloudwatch executable to your instances' filesystems.
  • Allow your instances to make PutMetricData calls to CloudWatch with an IAM policy such as:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "cloudwatch:PutMetricData",
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}
  • A cron job such as the following will report metrics to CloudWatch every 5 minutes:
/5 * * * *  /path/to/linux-monitoring-cloudwatch --namespace NAMESPACE --region REGION &>> /var/log/linux-monitoring-cloudwatch.log

Coming up

  • DiskUsage percentage metric

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/awslabs/aws-sdk-go/aws
Package aws provides core functionality for making requests to AWS services.
Package aws provides core functionality for making requests to AWS services.
_workspace/src/github.com/awslabs/aws-sdk-go/aws/credentials
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
_workspace/src/github.com/awslabs/aws-sdk-go/service/cloudwatch
Package cloudwatch provides a client for Amazon CloudWatch.
Package cloudwatch provides a client for Amazon CloudWatch.
_workspace/src/github.com/guillermo/go.procmeminfo
Package procmeminfo provides an interface for /proc/meminfo import "github.com/guillermo/go.procmeminfo" meminfo := &procmeminfo.MemInfo{} meminfo.Update() Once the info was updated you can access like a normal map[string]float64 v := (*meminfo)["MemTotal"] // 1809379328 (1766972 * 1024) It also implement some handy methods, like: meminfo.Total() // (*meminfo)["MemTotal"] meminfo.Free() // MemFree + Buffers + Cached meminfo.Used() // Total - Free Return all the values in units, so while you get this from cat /proc/meminfo MemTotal: 1766972 kB MemFree: 115752 kB Buffers: 3172 kB Cached: 182552 kB SwapCached: 83572 kB Active: 1055284 kB Inactive: 382872 kB Active(anon): 932712 kB Inactive(anon): 329508 kB Active(file): 122572 kB Inactive(file): 53364 kB Unevictable: 10640 kB Mlocked: 10640 kB SwapTotal: 1808668 kB SwapFree: 1205672 kB Dirty: 100 kB Writeback: 0 kB AnonPages: 1214740 kB Mapped: 115636 kB Shmem: 4840 kB Slab: 77412 kB SReclaimable: 34344 kB SUnreclaim: 43068 kB KernelStack: 4328 kB PageTables: 39428 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 2692152 kB Committed_AS: 5448372 kB VmallocTotal: 34359738367 kB VmallocUsed: 106636 kB VmallocChunk: 34359618556 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 216236 kB DirectMap2M: 1593344 kB All the kB values are multiply by 1024 This is the info extracted from the man page of proc: /proc/meminfo This file reports statistics about memory usage on the system.
Package procmeminfo provides an interface for /proc/meminfo import "github.com/guillermo/go.procmeminfo" meminfo := &procmeminfo.MemInfo{} meminfo.Update() Once the info was updated you can access like a normal map[string]float64 v := (*meminfo)["MemTotal"] // 1809379328 (1766972 * 1024) It also implement some handy methods, like: meminfo.Total() // (*meminfo)["MemTotal"] meminfo.Free() // MemFree + Buffers + Cached meminfo.Used() // Total - Free Return all the values in units, so while you get this from cat /proc/meminfo MemTotal: 1766972 kB MemFree: 115752 kB Buffers: 3172 kB Cached: 182552 kB SwapCached: 83572 kB Active: 1055284 kB Inactive: 382872 kB Active(anon): 932712 kB Inactive(anon): 329508 kB Active(file): 122572 kB Inactive(file): 53364 kB Unevictable: 10640 kB Mlocked: 10640 kB SwapTotal: 1808668 kB SwapFree: 1205672 kB Dirty: 100 kB Writeback: 0 kB AnonPages: 1214740 kB Mapped: 115636 kB Shmem: 4840 kB Slab: 77412 kB SReclaimable: 34344 kB SUnreclaim: 43068 kB KernelStack: 4328 kB PageTables: 39428 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 2692152 kB Committed_AS: 5448372 kB VmallocTotal: 34359738367 kB VmallocUsed: 106636 kB VmallocChunk: 34359618556 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 216236 kB DirectMap2M: 1593344 kB All the kB values are multiply by 1024 This is the info extracted from the man page of proc: /proc/meminfo This file reports statistics about memory usage on the system.
_workspace/src/github.com/vaughan0/go-ini
Package ini provides functions for parsing INI configuration files.
Package ini provides functions for parsing INI configuration files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL