22 lines
908 B
Bash
22 lines
908 B
Bash
|
#!/bin/bash
|
||
|
eval "$(jq -r '@sh "id=\(.input)"')"
|
||
|
|
||
|
aws cloudwatch list-metrics --namespace CWAgent --metric-name disk_inodes_free \
|
||
|
--dimensions Name=InstanceId,Value=$id Name=path,Value=/ | \
|
||
|
jq '.Metrics[] | .Dimensions[] | select ((.Name=="device") or (.Name=="fstype")) | { (.Name): (.Value)}' | \
|
||
|
jq -s 'add // {"device":"unknown", "fstype":"unknown"}'
|
||
|
|
||
|
|
||
|
exit 0
|
||
|
|
||
|
DEVICE=$(aws cloudwatch list-metrics --namespace CWAgent --metric-name disk_inodes_free \
|
||
|
--dimensions Name=InstanceId,Value=$id Name=path,Value=/ \
|
||
|
--query 'Metrics[].Dimensions[?Name==`device`].Value' --output text)
|
||
|
|
||
|
FSTYPE=$(aws cloudwatch list-metrics --namespace CWAgent --metric-name disk_inodes_free \
|
||
|
--dimensions Name=InstanceId,Value=$id Name=path,Value=/ \
|
||
|
--query 'Metrics[].Dimensions[?Name==`fstype`].Value' --output text)
|
||
|
|
||
|
jq -n --arg device "$DEVICE" --arg fstype "$FSTYPE" '{"device":$device,"fstype":$fstype}'
|
||
|
|