Created
July 25, 2018 19:59
-
-
Save fbettag/a465309c1a8d2fddd93e997d1f8dee44 to your computer and use it in GitHub Desktop.
rudder agent hook script to be placed into /var/rudder/hooks.d
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
#!/bin/sh | |
# All available metadata within the sdc: namespace gets converted into vars. | |
VARS="uuid server_uuid datacenter_name alias billing_id brand cpu_shares create_timestamp dns_domain hostname image_uuid last_modified limit_priv max_locked_memory max_lwps max_physical_memory max_swap owner_uuid quota state tmpfs zfs_io_priority zonename zonepath" | |
E="{" | |
# The sdc: namespace. | |
for key in $VARS | |
do | |
VALUE=$(mdata-get sdc:${key} 2>/dev/null|sed ':a;N;$!ba;s/\n/\\n/g') | |
[[ -n $VALUE ]] && E+="\"sdc:${key}\":\"${VALUE}\"," | |
done | |
# User defined customer_metadata. | |
for key in $(mdata-list) | |
do | |
VALUE=$(mdata-get ${key} 2>/dev/null|sed ':a;N;$!ba;s/\n/\\n/g') | |
[[ -n $VALUE ]] && E+="\"${key}\":\"${VALUE}\"," | |
done | |
E+="}" | |
echo -n $E|sed -e 's;,}$;};' | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment