npm install aws-sdk diskspace
var AWS = require('aws-sdk'); var diskspace = require('diskspace'); new AWS.MetadataService().request("/latest/meta-data/instance-id", function (err, data) { diskspace.check('C', function (err, total, free, status) { var instanceId = data; var value = (total - free) * 100 / total; var cloudwatch = new AWS.CloudWatch({region: 'ap-northeast-1'}); var params = { MetricData: [ { MetricName: 'DiskSpaceUtilization', Dimensions: [ { Name: 'InstanceId', Value: instanceId }, ], Timestamp: new Date (), Unit: 'Percent', Value: value }, ], Namespace: 'Windows System' /* required */ }; cloudwatch.putMetricData(params, function(err, data) { if (err) console.log(err, err.stack); // an error occurred else console.log(data); // successful response }); }); });