Fix Azure IMDS (#14686)
* Fix Azure IMDS * Update system-info.sh * Update system-info.sh * Update daemon/system-info.sh Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud> --------- Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Shyam Sreevalsan committed
Mar 8, 2023 at 16:56 UTC
5c18b5d0c693cd115a25c0447c6bbeb0f931bb01
1 file changed
+8
-9
daemon/system-info.sh
+8
-9
@@ -466,16 +466,15 @@ if [ "${VIRTUALIZATION}" != "none" ] && command -v curl > /dev/null 2>&1; then
466
fi
467
fi
468
469
- # TODO: needs to be tested in Microsoft Azure
469
# Try Azure IMDS
471
- # if [ "${CLOUD_TYPE}" = "unknown" ]; then
472
- # AZURE_IMDS_DATA="$(curl --fail -s -m 5 -H "Metadata: true" --noproxy "*" "http://169.254.169.254/metadata/instance?version=2021-10-01")"
473
- # if [ -n "${AZURE_IMDS_DATA}" ]; then
474
- # CLOUD_TYPE="Azure"
475
- # CLOUD_INSTANCE_TYPE="$(curl --fail -s -m 5 -H "Metadata: true" --noproxy "*" "http://169.254.169.254/metadata/instance/compute/vmSize?version=2021-10-01&format=text")"
476
- # CLOUD_INSTANCE_REGION="$(curl --fail -s -m 5 -H "Metadata: true" --noproxy "*" "http://169.254.169.254/metadata/instance/compute/location?version=2021-10-01&format=text")"
477
- # fi
478
- # fi
470
+ if [ "${CLOUD_TYPE}" = "unknown" ]; then
471
+ AZURE_IMDS_DATA="$(curl --fail -s --connect-timeout 1 -m 3 -H "Metadata: true" --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-10-01")"
472
+ if [ -n "${AZURE_IMDS_DATA}" ]; then
473
+ CLOUD_TYPE="Azure"
474
+ CLOUD_INSTANCE_TYPE="$(curl --fail -s --connect-timeout 1 -m 3 -H "Metadata: true" --noproxy "*" "http://169.254.169.254/metadata/instance/compute/vmSize?api-version=2021-10-01&format=text")"
475
+ CLOUD_INSTANCE_REGION="$(curl --fail -s --connect-timeout 1 -m 3 -H "Metadata: true" --noproxy "*" "http://169.254.169.254/metadata/instance/compute/location?api-version=2021-10-01&format=text")"
476
+ fi
477
+ fi
478
fi
479
fi
480