Giter VIP home page Giter VIP logo

cloudwatch-wrapper's Introduction

Cloudwatch Wrapper

Description

This go binary wraps around shell commands and send the results to AWS Cloudwatch as an Event

It is inpired by @jaxxstorm's Sensu Wrapper.

Usage

NAME:
   Cloudwatch Wrapper - Execute a command and send the result to cloudwatch events

USAGE:
   cloudwatch-wapper [global options] command [command options] [arguments...]

VERSION:
   0.0.1

AUTHOR:
   Aaron Cossey

COMMANDS:
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --name value, -N value, -n value         The name of the cron
   --description value, -D value, -d value  Description of what this cron is for (default: name)
   --region value, -R value, -r value       The AWS region where the event will be pushed [$AWS_REGION]
   --timeout value, -T value, -t value      Amount of time before the command times out (default: 0)
   --verbose, -V                            Print verbose output
   --help, -h                               show help
   --version, -v                            print the version

Basic Example

The minimum required are the name, region and command. The command isn't a flag, it will just take any arguments from the invocation.

This will run the command and send info about the result to Cloudwatch Events.

$ cloudwatch-wapper -n "testing" -d "testing the wrapper" -r "ap-southeast-2" /bin/echo hello

Timeout

By default, commands will continue to run until they finish. If you wish to adjust that, specify the timeout flag:

$ cloudwatch-wapper -n "testing" -d "testing the wrapper" -r "ap-southeast-2" -t 25 ping 8.8.8.8

If a command is killed due to timeout, it's assumed to have failed and will return exit code -1

Building

Make sure your $GOPATH is set: https://github.com/golang/go/wiki/GOPATH Grab the external dependencies:

go get gopkg.in/urfave/cli.v1
go get -u github.com/aws/aws-sdk-go/...

Build it!

go build cloudwatch-wapper.go

That's it!

IAM Authentication

If running on an ec2 instance with an IAM role, the role needs to have at least:

"events:PutEvents"

You can also use shared credentials (~/.aws/credentials) for local development and testing.

More info about credentials can be found here: https://github.com/aws/aws-sdk-go#configuring-credentials

You will need to specify the region, either with:

$ cloudwatch-wapper -r <region>

or in the environment with

$ AWS_REGION=<region> cloudwatch-wapper ...

cloudwatch-wrapper's People

Contributors

ecolitan avatar

Watchers

 avatar  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.