Skip to content

Instantly share code, notes, and snippets.

@loisaidasam
Last active October 20, 2016 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loisaidasam/7ac13f9d6cddcad87461ab7e4f69ac43 to your computer and use it in GitHub Desktop.
Save loisaidasam/7ac13f9d6cddcad87461ab7e4f69ac43 to your computer and use it in GitHub Desktop.
AWS Normalized instance hours cost using dot.js
/**
* Add actual cost in `Normalized instance hours` column
*
* Q: How do you calculate the Normalized Instance Hours displayed on the
* console ?
*
* On the AWS Management Console, every cluster has a Normalized Instance Hours
* column that displays the approximate number of compute hours the cluster has
* used. Normalized Instance Hours are hours of compute time based on the
* standard of 1 hour of m1.small usage = 1 hour normalized compute time.
*
* As of 2016-10-20, m1.small costs $0.044/hr
*/
function addNormalizedInstanceHoursCost() {
var tbody = $('.GF2SJOLOO');
// console.log(tbody);
if (! tbody) {
console.log("Didn't find tbody w/ class `GF2SJOLOO`");
return;
}
var trs = tbody.find('tr');
if (! trs) {
console.log("Didn't find tbody trs");
return;
}
console.log("Adding normalized instance hours costs for " + trs.length + " clusters ...");
$.each(trs, function(index, tr) {
var td = $(this).find('td').last();
var hours = td.text();
var cost = (0.044 * hours).toFixed(2);
var tdStr = hours + " ($" + cost + ")";
td.text(tdStr);
})
}
function main() {
console.log("Running `~/.js/console.aws.amazon.com.js ...");
// These things load asynchronously, so wait a few ticks before kicking it off
window.setTimeout(addNormalizedInstanceHoursCost, 3000);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment