Last active
October 20, 2016 19:45
-
-
Save loisaidasam/7ac13f9d6cddcad87461ab7e4f69ac43 to your computer and use it in GitHub Desktop.
AWS Normalized instance hours cost using dot.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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