Browse files

Updating for node-cloudwatch in .json

  • Loading branch information...
1 parent b7e8ed9 commit be944830a3fdad8352e85f4e23653393bfef7d81 Frank LoVecchio committed Jan 2, 2012
Showing with 5 additions and 124 deletions.
  1. +0 −117 libs/node-cloudwatch.js
  2. +2 −5 modules/dao.js
  3. +3 −2 package.json
View
117 libs/node-cloudwatch.js
@@ -1,117 +0,0 @@
-var crypto = require('crypto'), querystring = require('querystring'), http = require('http');
-
-AmazonCloudwatchClient = function() {
-
-};
-
-AmazonCloudwatchClient.prototype.configureHttp = function(requestMethod, query) {
- var options = {
- host : 'monitoring.amazonaws.com',
- port : 80,
- path : query,
- method : requestMethod,
- headers : {
- 'Host' : 'monitoring.us-east-1.amazonaws.com',
- 'Content-Length' : 0
- }
- };
-
- return options;
-};
-
-AmazonCloudwatchClient.prototype.timestampBuilder = function() {
- pad = function(n) {
- if (n < 10) {
- return '0' + n;
- } else {
- return n;
- }
- };
-
- var now = new Date();
- var year = now.getUTCFullYear();
- var month = pad(now.getUTCMonth() + 1);
- var day = pad(now.getUTCDate());
- var hours = pad(now.getUTCHours());
- var minutes = pad(now.getUTCMinutes());
- return '' + year + '-' + month + '-' + day + 'T' + hours + ':' + minutes
- + ':00Z';
-};
-
-AmazonCloudwatchClient.prototype.queryBuilder = function(command, parameters) {
- var map = {
- AWSAccessKeyId : process.env['AWS_ACCESS_KEY_ID'],
- Action : command,
- SignatureMethod : 'HmacSHA256',
- Timestamp : this.timestampBuilder(),
- SignatureVersion : 2,
- Version : '2010-08-01'
- };
-
- for (key in parameters) {
- map[key] = typeof parameters[key] === 'function' ? parameters[key]()
- : parameters[key];
- }
-
- var names = (function() {
- var _results;
- _results = [];
-
- for (key in map) {
- parameters[key] = map[key];
- _results.push(key);
- }
- return _results;
- })();
-
- names.sort();
-
- var query = [];
- for (_i = 0, _len = names.length; _i < _len; _i++) {
- name = names[_i];
- query.push(querystring.escape(name) + '='
- + querystring.escape(map[name]));
- }
-
- var toSign = 'GET\n' + ('monitoring.us-east-1.amazonaws.com\n') + '/\n'
- + query.join("&");
- var hmac = crypto
- .createHmac('sha256', process.env['AWS_SECRET_ACCESS_KEY']);
- hmac.update(toSign);
- var digest = querystring.escape(hmac.digest('base64'));
- query.push('Signature=' + digest);
- return query;
-};
-
-AmazonCloudwatchClient.prototype.request = function(action, requestParams,
- callback) {
- var query = this.queryBuilder(action, requestParams);
- var options = this.configureHttp('GET', '/?' + query.join("&"));
- this.makeRequest(options, function(response) {
- callback(response);
- });
-};
-
-AmazonCloudwatchClient.prototype.makeRequest = function(options, callback) {
- var restRequest = http.request(options, function(response) {
-
- var responseData = '';
-
- response.on('data', function(chunk) {
- responseData = responseData + chunk.toString();
- });
-
- response.on('end', function() {
- callback(responseData.trim());
- });
- });
-
- restRequest.on('error', function(exception) {
- /* Write this to log */
- });
-
- restRequest.write('');
- restRequest.end();
-};
-
-exports.AmazonCloudwatchClient = AmazonCloudwatchClient;
View
7 modules/dao.js
@@ -5,7 +5,7 @@ var fs = require('fs'),
/* Path to dependencies from file */
var modules = {
- cloudwatch: '../libs/node-cloudwatch'
+ cloudwatch: 'node-cloudwatch'
};
DaoManagerModule = function (constants, utilities, logger, dao) {
@@ -15,11 +15,8 @@ DaoManagerModule = function (constants, utilities, logger, dao) {
Module.logger = logger;
Module.dao = dao;
- /* Setup dependencies */
-
+ /* Setup dependencies */
for (var name in modules) {
- /* Debug */
- /* console.log('Evaluating dependency in location: ' + location + ', with name: ' + name + ', path:' + modules[name]); */
eval('var ' + name + ' = require(\'' + modules[name] + '\')');
}
View
5 package.json
@@ -3,15 +3,16 @@
"version": "0.6.0",
"description": "Amazon CloudWatch environment monitor",
"keywords": ["amazon", "cloudwatch", "client", "node", "monitor"],
- "repository": "git://github.com/franklovecchio/node-cloudwatch.git",
- "author": "Frank LoVecchio <frank@m2m.io> (http://franklovecchio.com)",
+ "repository": "git://github.com/franklovecchio/node-monitor.git",
+ "author": "Frank LoVecchio <franklovecchio@gmail.com> (http://franklovecchio.com)",
"dependencies": {
"querystring": "",
"xml2json": "",
"crypto": "",
"step": "",
"nodeunit": "",
"async": "",
+ "node-cloudwatch": "0.0.3",
"long-stack-traces": "",
"github": "",
"forever": "",

0 comments on commit be94483

Please sign in to comment.