Skip to content

Instantly share code, notes, and snippets.

@cmonaghan
cmonaghan / tfc.sh
Last active September 22, 2022 19:14
Query idle terraform cloud agent count and send as metric to datadog
#!/bin/bash
# Before running this script, be sure to set the secrets
# export TFC_TOKEN=secret_token
# export DD_API_KEY=another_secret
# export AGENT_POOL_ID=some_id
idle_agent_count=$(curl \
--header "Authorization: Bearer $TFC_TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request GET \

Keybase proof

I hereby claim:

  • I am cmonaghan on github.
  • I am cmonaghan (https://keybase.io/cmonaghan) on keybase.
  • I have a public key ASB-hLgi902dRvjEanMT6IfZHdlDNHriY4RcqtcndvFcOwo

To claim this, I am signing this object:

@cmonaghan
cmonaghan / readifyNumbers
Created January 19, 2014 02:19
Here is a simple way to convert large numbers into an easily readable string. This is useful for displaying large numbers to the user. For example: 200000 --> "200k" 1200000 --> "1.2M" 54100000000 --> "54.1B"
var readifyNumbers = function(number) {
/* READIFYNUMBERS ASSUMPTIONS:
- Numbers will have typeof number or string
- No commas (expects format to be: 1500000)
*/
// throw error for any parameter input that is not a number and cannot be converted into a number
if (Number(number).toString() === 'NaN') {
throw 'Error. The readifyNumbers input parameter must be a number.';
}