Put metric to Amazon CloudWatch that use AWS Toolkit for Windows PowerShell.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
attributes
providers
recipes
resources
templates/default
.gitignore
.kitchen.yml
Berksfile
CHANGELOG.md
Gemfile
README.md
Thorfile
Vagrantfile
chefignore
metadata.rb

README.md

powershell_cloudwatch Cookbook

Put metric to Amazon CloudWatch that use AWS Toolkit for Windows PowerShell.

Requirements

  • Chef 11 or higher
  • Windows Server 2008 R2 or later
  • PowerShell 3.0 or higher

Attributes

powershell_cloudwatch::default

default[:powershell_cloudwatch][:aws_access_key] = ""
default[:powershell_cloudwatch][:aws_secret_key] = ""
default[:powershell_cloudwatch][:region]         = "ap-northeast-1"
default[:powershell_cloudwatch][:profile_name]   = "PutMetricToCloudWatch"
default[:powershell_cloudwatch][:is_ec2]         = true
Key Type Description Default
['powershell_cloudwatch']['aws_access_key'] String AWS Access Key
['powershell_cloudwatch']['aws_secret_key'] String AWS Secret Access Key
['powershell_cloudwatch']['region'] String AWS Region ap-northeast-1
['powershell_cloudwatch']['profile_name'] String Credential profile name for AWS Toolkit for Powershell ap-northeast-1
['powershell_cloudwatch']['profile_name'] String Credential profile name for AWS Toolkit for Powershell PutMetricToCloudWatch
['powershell_cloudwatch']['is_ec2'] Boolean Is your instance in AWS EC2? true

Usage

1. Just include powershell_cloudwatch in your node's run_list or include your cookbook:
{
  "name":"my_node",
  "run_list": [
    "recipe[powershell_cloudwatch]"
  ]
}

or

include_recipe "powershell_cloudwatch"
2. Just include powershell_cloudwatch in your cookbook's metadata.rb:
depends 'powershell_cloudwatch'
3-1. Create recipe that use powershell_cloudwatch_counter resource like this:

powershell_cloudwatch_counter is a custom resourece that collect internal information on the system by PerformanceCounter. Get a sample in every interval you specified interval until count of the sample that you specified sample_count. And put metric(Max,Min,Sum,SampleCount) to Amazon CloudWatch from their samples.

  powershell_cloudwatch_counter "CW_CPU" do
    ps_file_path "C:\\cw_cpu.ps1"
    interval 5
    sample_count 60
    name_space "System/Windows"
    metric_name "CPUUtilization"
    counter_path "\\Processor(_Total)\\% Processor Time"
  end
3-2. Create recipe that use powershell_cloudwatch_process resource like this:

powershell_cloudwatch_process is a custom resourece that collect count of the process that you specified process_name on the system. And put metric(Count) to Amazon CloudWatch.

  powershell_cloudwatch_process "process_powershell" do
    ps_file_path "C:\\cw_process_powershell.ps1"
    span_minutes 5
    name_space "System/Windows"
    metric_name "Process-powershell"
    process_name "powershell"
  end

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add_component_x)
  3. Write your change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request using Github

License and Authors

  • License: Apache 2.0
  • Author: Masashi Terui