Changes to Discovery commands
The following sections show the discovery command changes between BMC Discovery versions.
The following changes are not shown:
- Entirely new discovery platforms
- Changes to comments only
- Commands which have been removed and not replaced
- Changes to echo only statements
Discovery command changes from 23.1 to 23.3
Linux
getPackageList
The following code:
is replaced with:
getIPAddresses
The following code is added:
if [ "$TW_CLOUD_PLATFORM" = "ALIBABA" ]; then
public_ipv4_addr=`$TW_CLOUD_IMDS_CMD/eipv4 2>/dev/null`
if [ ! -z "$public_ipv4_addr" ]; then
echo "public0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500"
echo " inet $public_ipv4_addr netmask 0.0.0.0 broadcast 0.0.0.0 scope tw:internet"
echo " ether 00:00:00:00:00:00"
fi
fi
fi
The following code is added:
if [ "$TW_CLOUD_PLATFORM" = "ALIBABA" ]; then
public_ipv4_addr=`$TW_CLOUD_IMDS_CMD/eipv4 2>/dev/null`
if [ ! -z "$public_ipv4_addr" ]; then
echo "0: public0: <UP> mtu 1500 state UP"
echo " link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff"
echo " inet $public_ipv4_addr/0 brd 0.0.0.0 scope tw:internet public0"
fi
fi
fi
getNetworkInterfaces
The following code is added:
if [ "$TW_CLOUD_PLATFORM" = "ALIBABA" ]; then
public_ipv4_addr=`$TW_CLOUD_IMDS_CMD/eipv4 2>/dev/null`
if [ ! -z "$public_ipv4_addr" ]; then
echo "0: public0: <UP> link/ether 00:00:00:00:00:00"
fi
fi
fi
The following code:
for i in `ip -o link show 2>/dev/null | egrep '^[0-9]+:' | awk -F: '{print $2;}'`
do
if [ -d /sys/class/net/$i ]; then
echo begin /sys/class/net/$i:
is replaced with:
for i in `ip -o link show 2>/dev/null | grep -E '^[0-9]+:' | awk -F: '{print $2;}'`
do
if [ -d /sys/class/net/$i ]; then
echo begin /sys/class/net/$i:
The following code is added:
if [ "$TW_CLOUD_PLATFORM" = "ALIBABA" ]; then
public_ipv4_addr=`$TW_CLOUD_IMDS_CMD/eipv4 2>/dev/null`
if [ ! -z "$public_ipv4_addr" ]; then
echo "public0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500"
echo " ether 00:00:00:00:00:00"
fi
fi
fi
The following code:
for i in `ifconfig -a 2>/dev/null | egrep '^[a-z]' | awk -F: '{print $1;}'`
do
if [ -d /sys/class/net/$i ]; then
echo begin /sys/class/net/$i:
is replaced with:
for i in `ifconfig -a 2>/dev/null | grep -E '^[a-z]' | awk -F: '{print $1;}'`
do
if [ -d /sys/class/net/$i ]; then
echo begin /sys/class/net/$i:
getDeviceInfo
The following code:
# Linux distribution based on SuSE Linux Enterprise Server.
if [ "$os" = "" -a -r /etc/novell-release ]; then
os=`cat /etc/novell-release | egrep -v '^#'`
fi
# SuSE lsb_release does not provide service pack so prefer SuSE-release file
# However, this file is being deprecated so we will fallback to os-release
# (see below)
if [ "$os" = "" -a -r /etc/SuSE-release ]; then
os=`cat /etc/SuSE-release | grep -Ev '^#'`
fi
if [ "$os" = "" -a -r /etc/photon-release ]; then
os=`cat /etc/photon-release`
fi
if [ "$os" = "" -a -r /etc/debian_version ]; then
ver=`cat /etc/debian_version`
os="Debian Linux $ver"
if [ -r /etc/system-release ]; then
igel_os=`grep 'IGEL OS' /etc/system-release`
if [ "$igel_os" != "" ]; then
os=$igel_os
fi
fi
fi
if [ "$os" = "" -a -x /usr/bin/lsb_release ]; then
# We'd like to use -ds but that puts quotes in the output!
is replaced with:
# Linux distribution based on SuSE Linux Enterprise Server.
if [ "$os" = "" -a -r /etc/novell-release ]; then
os=`cat /etc/novell-release | egrep -v '^#'`
fi
# SuSE lsb_release does not provide service pack so prefer SuSE-release file
# However, this file is being deprecated so we will fallback to os-release
# (see below)
if [ "$os" = "" -a -r /etc/SuSE-release ]; then
os=`cat /etc/SuSE-release | grep -Ev '^#'`
fi
if [ "$os" = "" -a -r /etc/photon-release ]; then
os=`cat /etc/photon-release`
fi
if [ "$os" = "" -a -r /etc/debian_version ]; then
ver=`cat /etc/debian_version`
os="Debian Linux $ver"
if [ -r /etc/system-release ]; then
igel_os=`grep 'IGEL OS' /etc/system-release`
if [ "$igel_os" != "" ]; then
os=$igel_os
fi
fi
fi
if [ "$os" = "" -a -x /usr/bin/lsb_release ]; then
# We'd like to use -ds but that puts quotes in the output!
The following code:
if [ "$os" = "" -a -r /etc/debian_version ]; then
ver=`cat /etc/debian_version`
os="Debian Linux $ver"
if [ -r /etc/system-release ]; then
igel_os=`grep 'IGEL OS' /etc/system-release`
if [ "$igel_os" != "" ]; then
os=$igel_os
fi
fi
fi
if [ "$os" = "" -a -r /etc/mandrake-release ]; then
os=`cat /etc/mandrake-release`
fi
if [ "$os" = "" -a -r /etc/os-release ]; then
# Use os-release for SuSE (if SuSE-release wasn't present, above), Container Linux, Google COS
os_id=`egrep ^ID= /etc/os-release | cut -s -f2 '-d"'`
if [ "$os_id" = "" ]; then
os_id=`egrep ^ID= /etc/os-release | cut -f2 -d=`
fi
if [ "$os_id" = "sles" -o "$os_id" = "opensuse" -o "$os_id" = "sle_hpc" -o "$os_id" = "coreos" -o "$os_id" = "cos" ]; then
os=`egrep ^PRETTY_NAME /etc/os-release | cut -f2 '-d"'`
if [ "$os_id" = "cos" ]; then
extra=`egrep '(VERSION|BUILD_ID)=' /etc/os-release`
os="$os $extra"
fi
fi
is replaced with:
if [ "$os" = "" -a -r /etc/mandrake-release ]; then
os=`cat /etc/mandrake-release`
fi
if [ "$os" = "" -a -r /etc/os-release ]; then
# Use os-release for SuSE (if SuSE-release wasn't present, above), Container Linux, Google COS
os_id=`grep -E ^ID= /etc/os-release | cut -s -f2 '-d"'`
if [ "$os_id" = "" ]; then
os_id=`grep -E ^ID= /etc/os-release | cut -f2 -d=`
fi
if [ "$os_id" = "sles" -o "$os_id" = "opensuse" -o "$os_id" = "sle_hpc" -o "$os_id" = "coreos" -o "$os_id" = "cos" ]; then
os=`grep -E ^PRETTY_NAME /etc/os-release | cut -f2 '-d"'`
if [ "$os_id" = "cos" ]; then
extra=`grep -E '(VERSION|BUILD_ID)=' /etc/os-release`
os="$os $extra"
fi
fi
initialise
The following code:
# Try IMDSv2 first
TOKEN=`curl --connect-timeout 5 --max-time 10 --fail -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 1800" 2>/dev/null`
if [ ! -z "$TOKEN" ]; then
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail -H \"X-aws-ec2-metadata-token: $TOKEN\" http://169.254.169.254/latest/meta-data"
else
# Try IMDSv1
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail http://169.254.169.254/latest/meta-data"
fi
TW_CLOUD_ID=`$TW_CLOUD_IMDS_CMD/instance-id 2>/dev/null | egrep '^i-[0-9a-f]+$'`
if [ -n "$TW_CLOUD_ID" ]; then
if [ $TW_DETECT_OPENSTACK -eq 1 ]; then
# We need to check for OpenStack EC2-compatible metadata
is replaced with:
# Try IMDSv2 first
TOKEN=`curl --connect-timeout 5 --max-time 10 --fail -X PUT "http://169.254.169.254/latest/api/token" --header X-aws-ec2-metadata-token-ttl-seconds:1800 2>/dev/null`
if [ ! -z "$TOKEN" ]; then
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail --header X-aws-ec2-metadata-token:$TOKEN http://169.254.169.254/latest/meta-data"
else
# Try IMDSv1
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail http://169.254.169.254/latest/meta-data"
fi
TW_CLOUD_ID=`$TW_CLOUD_IMDS_CMD/instance-id 2>/dev/null | grep -E '^i-[0-9a-f]+$'`
if [ -n "$TW_CLOUD_ID" ]; then
if [ $TW_DETECT_OPENSTACK -eq 1 ]; then
# We need to check for OpenStack EC2-compatible metadata
The following code:
TOKEN=`curl --connect-timeout 5 --max-time 10 --fail -X PUT "http://100.100.100.200/latest/api/token" -H "X-aliyun-ecs-metadata-token-ttl-seconds: 1800" 2>/dev/null`
if [ ! -z "$TOKEN" ]; then
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail -H \"X-aws-ec2-metadata-token: $TOKEN\" http://100.100.100.200/latest/meta-data"
else
# Not in security hardening mode
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail http://100.100.100.200/latest/meta-data"
is replaced with:
TOKEN=`curl --connect-timeout 5 --max-time 10 --fail -X PUT "http://100.100.100.200/latest/api/token" -H "X-aliyun-ecs-metadata-token-ttl-seconds: 1800" 2>/dev/null`
if [ ! -z "$TOKEN" ]; then
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail --header X-aliyun-ecs-metadata-token:$TOKEN http://100.100.100.200/latest/meta-data"
else
# Not in security hardening mode
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail http://100.100.100.200/latest/meta-data"
getMACAddresses
The following code:
is replaced with:
getHostInfo
The following code:
if [ "${ram}" != "" ]; then
echo 'ram:' ${ram}
fi
is replaced with:
if [[ -z $ram && -f /usr/sbin/lparstat ]]; then
ram=`/usr/sbin/lparstat -i | grep "Online Memory" | awk '{print $4 "KB"}'`
fi
if [ "${ram}" != "" ]; then
echo 'ram:' ${ram}
fi
The following code:
if [ -r /proc/sysinfo -a -d /proc/dasd ]; then
echo "candidate_vendor[]:" `egrep '^Manufacturer:' /proc/sysinfo | awk '{print $2;}'`
type=`egrep '^Type:' /proc/sysinfo | awk '{print $2;}'`
model=`egrep '^Model:' /proc/sysinfo | awk '{print $2;}'`
echo "candidate_model[]: $type-$model"
echo "zlinux_sequence:" `egrep '^Sequence Code:' /proc/sysinfo | awk '{print $3;}'`
echo "zlinux_vm_name:" `egrep '^VM00 Name:' /proc/sysinfo | awk '{print $3;}'`
echo "zlinux_vm_software:" `egrep '^VM00 Control Program:' /proc/sysinfo | awk '{print $4, $5;}'`
fi
is replaced with:
if [ -r /proc/sysinfo -a -d /proc/dasd ]; then
echo "candidate_vendor[]:" `grep -E '^Manufacturer:' /proc/sysinfo | awk '{print $2;}'`
type=`grep -E '^Type:' /proc/sysinfo | awk '{print $2;}'`
model=`grep -E '^Model:' /proc/sysinfo | awk '{print $2;}'`
echo "candidate_model[]: $type-$model"
echo "zlinux_sequence:" `grep -E '^Sequence Code:' /proc/sysinfo | awk '{print $3;}'`
echo "zlinux_vm_name:" `grep -E '^VM00 Name:' /proc/sysinfo | awk '{print $3;}'`
echo "zlinux_vm_software:" `grep -E '^VM00 Control Program:' /proc/sysinfo | awk '{print $4, $5;}'`
fi
The following code:
echo "aws_instance_id: $TW_CLOUD_ID"
# Use instance type as model
model=`$TW_CLOUD_IMDS_CMD/instance-type 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$model" != "" ]; then
echo "model: $model"
else
is replaced with:
echo "aws_instance_id: $TW_CLOUD_ID"
# Use instance type as model
model=`$TW_CLOUD_IMDS_CMD/instance-type 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$model" != "" ]; then
echo "model: $model"
else
The following code:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
is replaced with:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
The following code:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
is replaced with:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
FreeBSD
PATH has changed
- Was: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
- Now: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
initialise
The following code:
if [ -n "$TW_CLOUD_ID" ]; then
# We need to check for OpenStack EC2-compatible metadata
# https://docs.openstack.org/nova/latest/user/metadata.html#metadata-ec2-format
is replaced with:
if [ -n "$TW_CLOUD_ID" ]; then
# We need to check for OpenStack EC2-compatible metadata
# https://docs.openstack.org/nova/latest/user/metadata.html#metadata-ec2-format
getHostInfo
The following code:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
is replaced with:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
VMware ESX
getPackageList
The following code:
is replaced with:
getIPAddresses
The following code is added:
if [ "$TW_CLOUD_PLATFORM" = "ALIBABA" ]; then
public_ipv4_addr=`$TW_CLOUD_IMDS_CMD/eipv4 2>/dev/null`
if [ ! -z "$public_ipv4_addr" ]; then
echo "public0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500"
echo " inet $public_ipv4_addr netmask 0.0.0.0 broadcast 0.0.0.0 scope tw:internet"
echo " ether 00:00:00:00:00:00"
fi
fi
fi
getIPAddresses
The following code is added:
if [ "$TW_CLOUD_PLATFORM" = "ALIBABA" ]; then
public_ipv4_addr=`$TW_CLOUD_IMDS_CMD/eipv4 2>/dev/null`
if [ ! -z "$public_ipv4_addr" ]; then
echo "0: public0: <UP> mtu 1500 state UP"
echo " link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff"
echo " inet $public_ipv4_addr/0 brd 0.0.0.0 scope tw:internet public0"
fi
fi
fi
getNetworkInterfaces
The following code is added:
if [ "$TW_CLOUD_PLATFORM" = "ALIBABA" ]; then
public_ipv4_addr=`$TW_CLOUD_IMDS_CMD/eipv4 2>/dev/null`
if [ ! -z "$public_ipv4_addr" ]; then
echo "0: public0: <UP> link/ether 00:00:00:00:00:00"
fi
fi
fi
The following code:
for i in `ip -o link show 2>/dev/null | egrep '^[0-9]+:' | awk -F: '{print $2;}'`
do
if [ -d /sys/class/net/$i ]; then
echo begin /sys/class/net/$i:
is replaced with:
for i in `ip -o link show 2>/dev/null | grep -E '^[0-9]+:' | awk -F: '{print $2;}'`
do
if [ -d /sys/class/net/$i ]; then
echo begin /sys/class/net/$i:
getNetworkInterfaces
The following code is added:
if [ "$TW_CLOUD_PLATFORM" = "ALIBABA" ]; then
public_ipv4_addr=`$TW_CLOUD_IMDS_CMD/eipv4 2>/dev/null`
if [ ! -z "$public_ipv4_addr" ]; then
echo "public0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500"
echo " ether 00:00:00:00:00:00"
fi
fi
fi
The following code:
for i in `ifconfig -a 2>/dev/null | egrep '^[a-z]' | awk -F: '{print $1;}'`
do
if [ -d /sys/class/net/$i ]; then
echo begin /sys/class/net/$i:
is replaced with:
for i in `ifconfig -a 2>/dev/null | grep -E '^[a-z]' | awk -F: '{print $1;}'`
do
if [ -d /sys/class/net/$i ]; then
echo begin /sys/class/net/$i:
getDeviceInfo
The following code:
# Linux distribution based on SuSE Linux Enterprise Server.
if [ "$os" = "" -a -r /etc/novell-release ]; then
os=`cat /etc/novell-release | egrep -v '^#'`
fi
# SuSE lsb_release does not provide service pack so prefer SuSE-release file
# However, this file is being deprecated so we will fallback to os-release
# (see below)
if [ "$os" = "" -a -r /etc/SuSE-release ]; then
os=`cat /etc/SuSE-release | egrep -v '^#'`
fi
if [ "$os" = "" -a -r /etc/photon-release ]; then
os=`cat /etc/photon-release`
fi
if [ "$os" = "" -a -x /usr/bin/lsb_release ]; then
# We'd like to use -ds but that puts quotes in the output!
is replaced with:
# Linux distribution based on SuSE Linux Enterprise Server.
if [ "$os" = "" -a -r /etc/novell-release ]; then
os=`cat /etc/novell-release | grep -Ev '^#'`
fi
# SuSE lsb_release does not provide service pack so prefer SuSE-release file
# However, this file is being deprecated so we will fallback to os-release
# (see below)
if [ "$os" = "" -a -r /etc/SuSE-release ]; then
os=`cat /etc/SuSE-release | grep -Ev '^#'`
fi
if [ "$os" = "" -a -r /etc/photon-release ]; then
os=`cat /etc/photon-release`
fi
if [ "$os" = "" -a -r /etc/debian_version ]; then
ver=`cat /etc/debian_version`
os="Debian Linux $ver"
if [ -r /etc/system-release ]; then
igel_os=`grep 'IGEL OS' /etc/system-release`
if [ "$igel_os" != "" ]; then
os=$igel_os
fi
fi
fi
if [ "$os" = "" -a -x /usr/bin/lsb_release ]; then
# We'd like to use -ds but that puts quotes in the output!
The following code:
if [ "$os" = "" -a -r /etc/debian_version ]; then
ver=`cat /etc/debian_version`
os="Debian Linux $ver"
if [ -r /etc/system-release ]; then
igel_os=`grep 'IGEL OS' /etc/system-release`
if [ "$igel_os" != "" ]; then
os=$igel_os
fi
fi
fi
if [ "$os" = "" -a -r /etc/mandrake-release ]; then
os=`cat /etc/mandrake-release`
fi
if [ "$os" = "" -a -r /etc/os-release ]; then
# Use os-release for SuSE (if SuSE-release wasn't present, above), Container Linux, Google COS
os_id=`egrep ^ID= /etc/os-release | cut -s -f2 '-d"'`
if [ "$os_id" = "" ]; then
os_id=`egrep ^ID= /etc/os-release | cut -f2 -d=`
fi
if [ "$os_id" = "sles" -o "$os_id" = "opensuse" -o "$os_id" = "sle_hpc" -o "$os_id" = "coreos" -o "$os_id" = "cos" ]; then
os=`egrep ^PRETTY_NAME /etc/os-release | cut -f2 '-d"'`
if [ "$os_id" = "cos" ]; then
extra=`egrep '(VERSION|BUILD_ID)=' /etc/os-release`
os="$os $extra"
fi
fi
is replaced with:
if [ "$os" = "" -a -r /etc/mandrake-release ]; then
os=`cat /etc/mandrake-release`
fi
if [ "$os" = "" -a -r /etc/os-release ]; then
# Use os-release for SuSE (if SuSE-release wasn't present, above), Container Linux, Google COS
os_id=`grep -E ^ID= /etc/os-release | cut -s -f2 '-d"'`
if [ "$os_id" = "" ]; then
os_id=`grep -E ^ID= /etc/os-release | cut -f2 -d=`
fi
if [ "$os_id" = "sles" -o "$os_id" = "opensuse" -o "$os_id" = "sle_hpc" -o "$os_id" = "coreos" -o "$os_id" = "cos" ]; then
os=`grep -E ^PRETTY_NAME /etc/os-release | cut -f2 '-d"'`
if [ "$os_id" = "cos" ]; then
extra=`grep -E '(VERSION|BUILD_ID)=' /etc/os-release`
os="$os $extra"
fi
fi
initialise
The following code:
# Try IMDSv2 first
TOKEN=`curl --connect-timeout 5 --max-time 10 --fail -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 1800" 2>/dev/null`
if [ ! -z "$TOKEN" ]; then
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail -H \"X-aws-ec2-metadata-token: $TOKEN\" http://169.254.169.254/latest/meta-data"
else
# Try IMDSv1
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail http://169.254.169.254/latest/meta-data"
fi
TW_CLOUD_ID=`$TW_CLOUD_IMDS_CMD/instance-id 2>/dev/null | egrep '^i-[0-9a-f]+$'`
if [ -n "$TW_CLOUD_ID" ]; then
if [ $TW_DETECT_OPENSTACK -eq 1 ]; then
# We need to check for OpenStack EC2-compatible metadata
is replaced with:
# Try IMDSv2 first
TOKEN=`curl --connect-timeout 5 --max-time 10 --fail -X PUT "http://169.254.169.254/latest/api/token" --header X-aws-ec2-metadata-token-ttl-seconds:1800 2>/dev/null`
if [ ! -z "$TOKEN" ]; then
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail --header X-aws-ec2-metadata-token:$TOKEN http://169.254.169.254/latest/meta-data"
else
# Try IMDSv1
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail http://169.254.169.254/latest/meta-data"
fi
TW_CLOUD_ID=`$TW_CLOUD_IMDS_CMD/instance-id 2>/dev/null | grep -E '^i-[0-9a-f]+$'`
if [ -n "$TW_CLOUD_ID" ]; then
if [ $TW_DETECT_OPENSTACK -eq 1 ]; then
# We need to check for OpenStack EC2-compatible metadata
The following code:
TOKEN=`curl --connect-timeout 5 --max-time 10 --fail -X PUT "http://100.100.100.200/latest/api/token" -H "X-aliyun-ecs-metadata-token-ttl-seconds: 1800" 2>/dev/null`
if [ ! -z "$TOKEN" ]; then
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail -H \"X-aws-ec2-metadata-token: $TOKEN\" http://100.100.100.200/latest/meta-data"
else
# Not in security hardening mode
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail http://100.100.100.200/latest/meta-data"
is replaced with:
TOKEN=`curl --connect-timeout 5 --max-time 10 --fail -X PUT "http://100.100.100.200/latest/api/token" -H "X-aliyun-ecs-metadata-token-ttl-seconds: 1800" 2>/dev/null`
if [ ! -z "$TOKEN" ]; then
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail --header X-aliyun-ecs-metadata-token:$TOKEN http://100.100.100.200/latest/meta-data"
else
# Not in security hardening mode
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail http://100.100.100.200/latest/meta-data"
getMACAddresses
The following code:
is replaced with:
getHostInfo
The following code:
if [ "${ram}" != "" ]; then
echo 'ram:' ${ram}
fi
is replaced with:
if [[ -z $ram && -f /usr/sbin/lparstat ]]; then
ram=`/usr/sbin/lparstat -i | grep "Online Memory" | awk '{print $4 "KB"}'`
fi
if [ "${ram}" != "" ]; then
echo 'ram:' ${ram}
fi
The following code:
if [ -r /proc/sysinfo -a -d /proc/dasd ]; then
echo "candidate_vendor[]:" `egrep '^Manufacturer:' /proc/sysinfo | awk '{print $2;}'`
type=`egrep '^Type:' /proc/sysinfo | awk '{print $2;}'`
model=`egrep '^Model:' /proc/sysinfo | awk '{print $2;}'`
echo "candidate_model[]: $type-$model"
echo "zlinux_sequence:" `egrep '^Sequence Code:' /proc/sysinfo | awk '{print $3;}'`
echo "zlinux_vm_name:" `egrep '^VM00 Name:' /proc/sysinfo | awk '{print $3;}'`
echo "zlinux_vm_software:" `egrep '^VM00 Control Program:' /proc/sysinfo | awk '{print $4, $5;}'`
fi
is replaced with:
if [ -r /proc/sysinfo -a -d /proc/dasd ]; then
echo "candidate_vendor[]:" `grep -E '^Manufacturer:' /proc/sysinfo | awk '{print $2;}'`
type=`grep -E '^Type:' /proc/sysinfo | awk '{print $2;}'`
model=`grep -E '^Model:' /proc/sysinfo | awk '{print $2;}'`
echo "candidate_model[]: $type-$model"
echo "zlinux_sequence:" `grep -E '^Sequence Code:' /proc/sysinfo | awk '{print $3;}'`
echo "zlinux_vm_name:" `grep -E '^VM00 Name:' /proc/sysinfo | awk '{print $3;}'`
echo "zlinux_vm_software:" `grep -E '^VM00 Control Program:' /proc/sysinfo | awk '{print $4, $5;}'`
fi
# Can we get information from the BIOS? We use lshal if available as that
The following code:
echo "aws_instance_id: $TW_CLOUD_ID"
# Use instance type as model
model=`$TW_CLOUD_IMDS_CMD/instance-type 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$model" != "" ]; then
echo "model: $model"
else
is replaced with:
echo "aws_instance_id: $TW_CLOUD_ID"
# Use instance type as model
model=`$TW_CLOUD_IMDS_CMD/instance-type 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$model" != "" ]; then
echo "model: $model"
else
The following code:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
is replaced with:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
The following code:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
is replaced with:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
Windows
runWMIQuery
The following code:
# Convert to string form matching proxy output
$match = ($_.Value | Select-String -Pattern "(\S+)\s+\((\S+)\s+=\s+(.*)\)");
if ($match) {
"{0}: \\{1}\{2}:{3}.{4}={5}" -f ($_.Name, $env:ComputerName, $namespace, $match.Matches.Groups[1].Value, $match.Matches.Groups[2].Value, $match.Matches.Groups[3].Value)
}
else {
"{0}: [{1}] {2}" -f $_.Name, $_.Value.GetType().Name, $_.Value
is replaced with:
# Convert associators to string form matching proxy output
$match = ($_.Value | Select-String -Pattern "(\S+)\s+\((\S+)\s+=\s+(.*)\)");
if ($match) {
"{0}: \\{1}\{2}:{3}.{4}={5}" -f ($_.Name, $env:ComputerName, $namespace, $match.Matches.Groups[1].Value, $match.Matches.Groups[2].Value, $match.Matches.Groups[3].Value)
}
# Handle CimInstance object instance properties to match proxy
elseif ($_.GetType().Name -eq "CimInstance") {
# Convert object to JSON format
"{0}: [{1}] JSON:{2}" -f $_.Name, $_.Value.GetType().Name, ($_.Value.CimInstanceProperties | ConvertTo-JSON -Compress)
}
else {
"{0}: [{1}] {2}" -f $_.Name, $_.Value.GetType().Name, $_.Value
getIPAddresses
The following code is added:
elseif ($TW_CLOUD_PLATFORM -eq "ALIBABA") {
try {
$public_ipv4_addr = Invoke-RestMethod -TimeoutSec 5 -Headers $TW_CLOUD_IMDS_HEADERS -Uri "http://100.100.100.200/latest/meta-data/eipv4" -ErrorAction SilentlyContinue
if ($public_ipv4_addr) {
"interface_id: public0";
"ip_addr: {0}" -f $public_ipv4_addr;
"netmask: 0.0.0.0";
"address_type: IPv4";
"scope: tw:internet";
"";
}
}
catch {
}
}
initialise
The following code:
};
try {
$global:TW_CLOUD_ID = Invoke-RestMethod -TimeoutSec 5 -Headers $global:TW_CLOUD_IMDS_HEADERS -Uri "http://100.100.100.200/latest/api/token/instance-id" -ErrorAction SilentlyContinue;
}
catch {
# Ignore errors
is replaced with:
};
try {
$global:TW_CLOUD_ID = Invoke-RestMethod -TimeoutSec 5 -Headers $global:TW_CLOUD_IMDS_HEADERS -Uri "http://100.100.100.200/latest/meta-data/instance-id" -ErrorAction SilentlyContinue;
}
catch {
# Ignore errors
getNetworkInterfaces
The following code is added:
elseif ($TW_CLOUD_PLATFORM -eq "ALIBABA") {
try {
$public_ipv4_addr = Invoke-RestMethod -TimeoutSec 5 -Headers $TW_CLOUD_IMDS_HEADERS -Uri "http://100.100.100.200/latest/meta-data/eipv4" -ErrorAction SilentlyContinue
if ($public_ipv4_addr) {
"interface_id: public0";
"name: public0";
"mac_addr: 00:00:00:00:00:00";
"adapter_type: Ethernet 802.3";
}
}
catch {
}
}
Solaris
getHostInfo
The following code:
# available we try a few obvious fallbacks including any "Chassis Serial Number"
# from prtdiag
if [ -x /opt/SUNWsneep/bin/sneep ]; then
serial=`/opt/SUNWsneep/bin/sneep 2>/dev/null`
if [ "$serial" != "unknown" ]; then
echo "serial: $serial"
fi
is replaced with:
# available we try a few obvious fallbacks including any "Chassis Serial Number"
# from prtdiag
sneepcmd=""
if [ -x /opt/SUNWsneep/bin/sneep ]; then
sneepcmd=/opt/SUNWsneep/bin/sneep
elif [ -x /usr/sbin/sneep ]; then
sneepcmd=/usr/sbin/sneep
fi
if [ "$sneepcmd" != "" ]; then
serial=`$sneepcmd 2>/dev/null`
if [ "$serial" != "unknown" ]; then
echo "serial: $serial"
fi
elif [ -x /usr/sbin/sneep ]; then
serial=`/usr/sbin/sneep 2>/dev/null`
if [ "$serial" != "unknown" ]; then
echo "serial: $serial"
fi
OpenBSD
PATH has changed
- Was: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
- Now: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
initialise
The following code:
if [ -n "$TW_CLOUD_ID" ]; then
# We need to check for OpenStack EC2-compatible metadata
# https://docs.openstack.org/nova/latest/user/metadata.html#metadata-ec2-format
is replaced with:
if [ -n "$TW_CLOUD_ID" ]; then
# We need to check for OpenStack EC2-compatible metadata
# https://docs.openstack.org/nova/latest/user/metadata.html#metadata-ec2-format
getHostInfo
The following code:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
is replaced with:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
AIX
getIPAddresses
The following code:
ifconfig -a 2>/dev/null
else
ifconfig -a 2>/dev/null | egrep -v "$wparaddrs"
fi
fi
is replaced with:
ifconfig -a 2>/dev/null
else
ifconfig -a 2>/dev/null | grep -Ev "$wparaddrs"
fi
fi
getNetworkConnectionList
The following code:
if [ `uname -W` -eq 0 ]; then
netstat -an -f inet -@ 2>/dev/null | egrep "Global|Proto" | sed -e 's/Global //'
netstat -an -f inet6 -@ 2>/dev/null | egrep "Global|Proto" | sed -e 's/Global //'
else
netstat -an -f inet 2>/dev/null
netstat -an -f inet6 2>/dev/null
is replaced with:
if [ `uname -W` -eq 0 ]; then
netstat -an -f inet -@ 2>/dev/null | grep -E "Global|Proto" | sed -e 's/Global //'
netstat -an -f inet6 -@ 2>/dev/null | grep -E "Global|Proto" | sed -e 's/Global //'
else
netstat -an -f inet 2>/dev/null
netstat -an -f inet6 2>/dev/null
getProcessList
The following code:
ps -eo pid,ppid,uid,user,wpar,args | egrep "Global|PID" | sed -e 's/Global //'
else
# pipe through cat to remove tty columns limit
ps -eo pid,ppid,uid,user,args | cat
is replaced with:
ps -eo pid,ppid,uid,user,wpar,args | grep -E "Global|PID" | sed -e 's/Global //'
else
# pipe through cat to remove tty columns limit
ps -eo pid,ppid,uid,user,args | cat
getHostInfo
The following code:
if [ -x /usr/sbin/prtconf ]; then
/usr/sbin/prtconf > /tmp/tideway.$$ 2>/dev/null
echo 'model:' `egrep '^System Model:' /tmp/tideway.$$ | cut -f2 -d: | sed -e 's/IBM,//'`
echo 'kernel:' `egrep '^Kernel Type:' /tmp/tideway.$$ | cut -f2 -d:`
partition_id=`egrep '^LPAR Info:' /tmp/tideway.$$ | cut -f2 -d: | awk '
{
if ( ($1 ~ /^[[:digit:]]+$/ ) && ( toupper($2) !~ /NULL/ ) ) {
print $2":"$1
is replaced with:
if [ -x /usr/sbin/prtconf ]; then
/usr/sbin/prtconf > /tmp/tideway.$$ 2>/dev/null
echo 'model:' `grep -E '^System Model:' /tmp/tideway.$$ | cut -f2 -d: | sed -e 's/IBM,//'`
echo 'kernel:' `grep -E '^Kernel Type:' /tmp/tideway.$$ | cut -f2 -d:`
partition_id=`grep -E '^LPAR Info:' /tmp/tideway.$$ | cut -f2 -d: | awk '
{
if ( ($1 ~ /^[[:digit:]]+$/ ) && ( toupper($2) !~ /NULL/ ) ) {
print $2":"$1
The following code:
fi
if [ $wparid -eq 0 ]; then
serial=`egrep '^Machine Serial Number:' /tmp/tideway.$$ | cut -f2 -d:`
# Don't output serial number if it isn't available. Also work around
# bug in prtconf on AIX 5.3 where there's no newline after the serial
# number output if it isn't available.
is replaced with:
fi
if [ $wparid -eq 0 ]; then
serial=`grep -E '^Machine Serial Number:' /tmp/tideway.$$ | cut -f2 -d:`
# Don't output serial number if it isn't available. Also work around
# bug in prtconf on AIX 5.3 where there's no newline after the serial
# number output if it isn't available.
NetBSD
PATH has changed:
- Was: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
- Now: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
initialise
The following code:
fi
TW_CLOUD_ID=`$TW_CLOUD_IMDS_CMD/instance-id 2>/dev/null | egrep '^i-[0-9a-f]+$'`
if [ -n "$TW_CLOUD_ID" ]; then
# We need to check for OpenStack EC2-compatible metadata
# https://docs.openstack.org/nova/latest/user/metadata.html#metadata-ec2-format
is replaced with:
fi
TW_CLOUD_ID=`$TW_CLOUD_IMDS_CMD/instance-id 2>/dev/null | grep -E '^i-[0-9a-f]+$'`
if [ -n "$TW_CLOUD_ID" ]; then
# We need to check for OpenStack EC2-compatible metadata
# https://docs.openstack.org/nova/latest/user/metadata.html#metadata-ec2-format
getHostInfo
The following code:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | egrep '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
is replaced with:
primary_mac=`$TW_CLOUD_IMDS_CMD/mac 2>/dev/null`
if [ "$primary_mac" != "" ]; then
scope=`$TW_CLOUD_IMDS_CMD/network/interfaces/macs/$primary_mac/vpc-id 2>/dev/null | grep -E '^vpc-[0-9a-f]+$'`
if [ "$scope" != "" ]; then
echo "scope: $scope"
fi
HP-UX
getProcessList
The following code:
fi
fi
env UNIX95=1 ps -e${PS_X_OPT}o pid,ppid,uid,user,args 2>/dev/null | egrep -v '^\ *[0-9]\ +[0-9]\ [0-9]\ +srp\ +'
is replaced with:
fi
fi
env UNIX95=1 ps -e${PS_X_OPT}o pid,ppid,uid,user,args 2>/dev/null | grep -Ev '^\ *[0-9]\ +[0-9]\ [0-9]\ +srp\ +'
getPatchList
The following code:
is replaced with: