The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ylastic-costagent - Send AWS usage and cost data to Ylastic

VERSION

version 0.006

SYNOPSIS

   ylastic-costagent [OPTIONS] <CONFIG_FILE>
 
   --dir|-d      Directory to hold downloads (default is tempdir)
   --syslog|-s   Syslogd facility for logging (default is none)
   --logpath|-l  Directory to hold a logfile (default is no logfile)
   --dry-run|-n  Download, but don't upload (default is false)
   --debug       Log with extra detail (default is false)
   --help|h      Show summary of options

DESCRIPTION

This program downloads your Amazon Web Services usage data and uploads it to your Ylastic account for cost analysis. It should be run regularly from a cron job to ensure up-to-date usage and spending history.

CONFIGURATION

Installation

Install App::Ylastic::CostAgent using your regular CPAN client or distribution package manager (if available). You may need the OpenSSL development libraries installed if you don't already have SSL working.

If you aren't sure how to configure a CPAN client, see this excellent post on using CPAN as a non-root user.

For example, assuming Ubuntu Linux and a bash shell:

  $ sudo apt-get install libssl-dev
  $ curl -L http://cpanmin.us | perl - -l ~/perl5 App::cpanminus local::lib
  $ eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`
  $ echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.bashrc
  $ cpanm App::Ylastic::CostAgent

Config file format

The ylastic-costagent program requires a configuration file that specifies your Ylastic and AWS account data. The file is 'INI' format. Here is a template:

   ylastic_id = 1234567890abdcef1234567890abcdef12345678
 
   [1234-5689-0123]
   user = foo@example.com
   pass = trustno1
 
   [4321-9865-3210]
   user = foo@example.com
   pass = trustno1

Each Amazon account should be listed as a separate section with the account ID number in brackets. (You may omit dashes if you wish.)

Security

Your config file contains AWS usernames and passwords. These give complete control over your AWS account(s). Do not make your config file group/world readable. You should only run this program on a machine that is safely behind a firewall. All web requests with account data are transmitted over SSL.

Automation

This program should be run regularly to keep your usage data current on Ylastic. Here is an example cron job entry that updates usage data every 12 hours:

   0 */12 * * * /path/to/ylastic-costagent -s user /path/to/config.ini

The -s user option will log to the user facility of syslogd.

If you use a local perl library, be sure to add an appropriate PERL5LIB to your crontab file:

   PERL5LIB=$HOME/perl5/lib/perl5/i686-linux:$HOME/perl5/lib/perl5

Look at the PERL5LIB set by local::lib for the right paths to use.

ACKNOWLEDGMENTS

This program is based on the original ylastic_aws_costs_agent.py program distributed by Ylastic, which was credited as based on a Python scrypt by Robert Coup.

SEE ALSO

AUTHOR

David Golden <dagolden@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2011 by David Golden.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004