summaryrefslogtreecommitdiffstats
path: root/daemon/system-info.sh
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/system-info.sh')
-rwxr-xr-xdaemon/system-info.sh26
1 files changed, 15 insertions, 11 deletions
diff --git a/daemon/system-info.sh b/daemon/system-info.sh
index 1e334a3d..43f761c2 100755
--- a/daemon/system-info.sh
+++ b/daemon/system-info.sh
@@ -96,6 +96,11 @@ if [ "${CONTAINER}" = "unknown" ]; then
CONT_DETECTION="dockerenv"
fi
+ if [ -n "${KUBERNETES_SERVICE_HOST}" ]; then
+ CONTAINER="container"
+ CONT_DETECTION="kubernetes"
+ fi
+
fi
# -------------------------------------------------------------------------------------------------
@@ -391,7 +396,7 @@ else
# These translate to the prefixs of files in `/dev` indicating the device type.
# They are sorted by lowest used device major number, with dynamically assigned ones at the end.
# We use this to look up device major numbers in `/proc/devices`
- device_names='hd sd mfm ad ftl pd nftl dasd intfl mmcblk ub xvd rfd vbd nvme virtblk blkext'
+ device_names='hd sd mfm ad ftl pd nftl dasd intfl mmcblk mmc ub xvd rfd vbd nvme virtblk blkext'
for name in ${device_names}; do
if grep -qE " ${name}\$" /proc/devices; then
@@ -457,7 +462,7 @@ if [ "${VIRTUALIZATION}" != "none" ] && command -v curl > /dev/null 2>&1; then
# Try GCE computeMetadata v1
if [ "${CLOUD_TYPE}" = "unknown" ]; then
- if [ -n "$(curl --fail -s --connect-timeout 1 -m 3 --noproxy "*" -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1")" ]; then
+ if curl --fail -s --connect-timeout 1 -m 3 --noproxy "*" -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1" | grep -sq computeMetadata; then
CLOUD_TYPE="GCP"
CLOUD_INSTANCE_TYPE="$(curl --fail -s --connect-timeout 1 -m 3 --noproxy "*" -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/machine-type")"
[ -n "$CLOUD_INSTANCE_TYPE" ] && CLOUD_INSTANCE_TYPE=$(basename "$CLOUD_INSTANCE_TYPE")
@@ -466,16 +471,15 @@ if [ "${VIRTUALIZATION}" != "none" ] && command -v curl > /dev/null 2>&1; then
fi
fi
- # TODO: needs to be tested in Microsoft Azure
# Try Azure IMDS
- # if [ "${CLOUD_TYPE}" = "unknown" ]; then
- # AZURE_IMDS_DATA="$(curl --fail -s -m 5 -H "Metadata: true" --noproxy "*" "http://169.254.169.254/metadata/instance?version=2021-10-01")"
- # if [ -n "${AZURE_IMDS_DATA}" ]; then
- # CLOUD_TYPE="Azure"
- # 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")"
- # 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")"
- # fi
- # fi
+ if [ "${CLOUD_TYPE}" = "unknown" ]; then
+ 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")"
+ if [ -n "${AZURE_IMDS_DATA}" ] && echo "${AZURE_IMDS_DATA}" | grep -sq azEnvironment; then
+ CLOUD_TYPE="Azure"
+ 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")"
+ 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")"
+ fi
+ fi
fi
fi