- R
- awscli
[pataiji@mbp ~]$ spot-price -t m4.large -s '2017-01-01'
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.02180 0.02540 0.03230 0.03375 0.03990 0.10000
#!/bin/sh | |
echo_help() { | |
echo "usage: spot-price -t instance-types -s start-time [-e end-time] [-p profile] [-r region]" 1>&2 | |
exit 1 | |
} | |
main_args='' | |
sub_args="--product-descriptions 'Linux/UNIX'" | |
while getopts p:t:s:e:r: opts | |
do | |
case "$opts" in | |
p) | |
main_args="$main_args --profile '$OPTARG'" | |
;; | |
r) | |
main_args="$main_args --region '$OPTARG'" | |
;; | |
t) | |
sub_args="$sub_args --instance-types '$OPTARG'" | |
;; | |
s) | |
sub_args="$sub_args --start-time '$OPTARG'" | |
;; | |
e) | |
sub_args="$sub_args --end-time '$OPTARG'" | |
;; | |
*) | |
echo_help | |
;; | |
esac | |
done | |
shift $((OPTIND - 1)) | |
(echo "$sub_args" | grep -q -- --instance-types && echo "$sub_args" | grep -q -- --start-time) || echo_help | |
cmd="aws ${main_args} ec2 describe-spot-price-history ${sub_args}" | |
eval "$cmd" | jq '.SpotPriceHistory[].SpotPrice' | sed 's/"//g' | summary |
#!/usr/bin/env Rscript | |
# http://unix.stackexchange.com/questions/13731/is-there-a-way-to-get-the-min-max-median-and-average-of-a-list-of-numbers-in | |
d<-scan("stdin", quiet=TRUE) | |
summary(d) |