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 21.3 to 22.1
macOS
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
Solaris
getFileContent
The following code:
echo "begin content:"
if [ -x /usr/xpg4/bin/sed ]; then
PRIV_CAT "${P}" | /usr/xpg4/bin/sed -e 's/[^[:print:][:blank:]]//g'
else
PRIV_CAT "${P}"
ch=`PRIV_CAT "${P}" | tail -1c`
if [ -z "`echo "${ch}" | tr -d '\n'`" ]; then
echo
fi
fi
fi
is replaced with:
echo "begin content:"
if [ -x /usr/xpg4/bin/sed ]; then
(PRIV_CAT "${P}" && echo) | /usr/xpg4/bin/sed -e 's/[^[:print:][:blank:]]//g'
else
PRIV_CAT "${P}" && echo
fi
fi
getDeviceInfo
The following code:
echo 'hostname:' $ihn
fqdn=`check-hostname 2>/dev/null | awk '{print $NF}'`
echo 'fqdn:' $fqdn
dns_domain=`echo $fqdn | cut -d. -f2-`
if [ "$dns_domain" = "" -a -r /etc/resolv.conf ]; then
dns_domain=`awk '/^(search|domain)/ { print $2; exit }' /etc/resolv.conf 2>/dev/null`
fi
is replaced with:
echo 'hostname:' $ihn
dns_domain=""
check_hostname=`check-hostname 2>/dev/null`
if [ $? -eq 0 ]; then
fqdn=`echo $check_hostname | awk '{print $NF}'`
echo 'fqdn:' $fqdn
dns_domain=`echo $fqdn | cut -d. -f2-`
fi
if [ "$dns_domain" = "" -a -r /etc/resolv.conf ]; then
dns_domain=`awk '/^(search|domain)/ { print $2; exit }' /etc/resolv.conf 2>/dev/null`
fi
AIX
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
IRIX
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
VMware ESX
initialise
The following code:
# see: https://cloud.google.com/compute/docs/storing-retrieving-metadata
TW_CLOUD_ID=`curl --connect-timeout 5 --max-time 10 --fail --header 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/id 2>/dev/null`
if [ -n "$TW_CLOUD_ID" ]; then
TW_CLOUD_PLATFORM=GCE
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail --header 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1"
return 0
fi
is replaced with:
# see: https://cloud.google.com/compute/docs/storing-retrieving-metadata
TW_CLOUD_ID=`curl --connect-timeout 5 --max-time 10 --fail --header Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1/instance/id 2>/dev/null`
if [ -n "$TW_CLOUD_ID" ]; then
TW_CLOUD_PLATFORM=GCE
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail --header Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1"
return 0
fi
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
getDeviceInfo
The following code:
fi
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)
is replaced with:
fi
fi
# Before SuSE trying to detect Novell Open Enterprise Server (OES),
# 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)
getHostInfo
The following code:
echo "candidate_vendor[]: Google"
# Get project IDs
numeric_project_id=`$TW_CLOUD_IMDS_CMD/project/numeric-project-id 2>/dev/null`
project_id=`$TW_CLOUD_IMDS_CMD/project/project-id 2>/dev/null`
is replaced with:
echo "candidate_vendor[]: Google"
# Get instance name
instance_name=`$TW_CLOUD_IMDS_CMD/instance/name 2>/dev/null`
if [ "$instance_name" != "" ]; then
echo "gce_instance_name: $instance_name"
fi
# Get project IDs
numeric_project_id=`$TW_CLOUD_IMDS_CMD/project/numeric-project-id 2>/dev/null`
project_id=`$TW_CLOUD_IMDS_CMD/project/project-id 2>/dev/null`
HP-UX
getProcessList
The following code:
if [ `uname -r | cut -d. -f3` -ge 11 ]; then
PS_X_OPT=x
fi
fi
env UNIX95=1 ps -e${PS_X_OPT}o pid,ppid,uid,user,args 2>/dev/null
is replaced with:
if [ `uname -r | cut -d. -f3` -ge 11 ]; then
PS_X_OPT=x
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\ +'
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
echo "`PRIV_CAT "${P}"`"
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
UnixWare
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
FreeBSD
The PATH has changed. The following code:
is replaced with:
The getPackageList method has been added.
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
getHostInfo
The following code:
PRIV_DMIDECODE /usr/sbin/dmidecode 2>/dev/null | awk '/DMI type 1,/,/^Handle 0x0*[2-9]+0*/ {
if( $1 ~ /Manufacturer:/ ) { sub(".*Manufacturer: *",""); printf( "candidate_vendor[]: %s\n", $0 ); }
if( $1 ~ /Product/ && $2 ~ /Name:/ ) { sub(".*Product Name: *",""); printf( "candidate_model[]: %s\n", $0 ); }
if( $1 ~ /Serial/ && $2 ~ /Number:/ ) { sub(".*Serial Number: *",""); printf( "serial: %s\n", $0 ); }
is replaced with:
PRIV_DMIDECODE /usr/local/sbin/dmidecode 2>/dev/null | awk '/DMI type 1,/,/^Handle 0x0*[2-9]+0*/ {
if( $1 ~ /Manufacturer:/ ) { sub(".*Manufacturer: *",""); printf( "candidate_vendor[]: %s\n", $0 ); }
if( $1 ~ /Product/ && $2 ~ /Name:/ ) { sub(".*Product Name: *",""); printf( "candidate_model[]: %s\n", $0 ); }
if( $1 ~ /Serial/ && $2 ~ /Number:/ ) { sub(".*Serial Number: *",""); printf( "serial: %s\n", $0 ); }
Linux
initialise
The following code:
# see: https://cloud.google.com/compute/docs/storing-retrieving-metadata
TW_CLOUD_ID=`curl --connect-timeout 5 --max-time 10 --fail --header 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/id 2>/dev/null`
if [ -n "$TW_CLOUD_ID" ]; then
TW_CLOUD_PLATFORM=GCE
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail --header 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1"
return 0
fi
is replaced with:
# see: https://cloud.google.com/compute/docs/storing-retrieving-metadata
TW_CLOUD_ID=`curl --connect-timeout 5 --max-time 10 --fail --header Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1/instance/id 2>/dev/null`
if [ -n "$TW_CLOUD_ID" ]; then
TW_CLOUD_PLATFORM=GCE
TW_CLOUD_IMDS_CMD="curl --connect-timeout 5 --max-time 10 --fail --header Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1"
return 0
fi
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
getDeviceInfo
The following code:
fi
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)
is replaced with:
fi
fi
# Before SuSE trying to detect Novell Open Enterprise Server (OES),
# 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)
getHostInfo
The following code:
echo "candidate_vendor[]: Google"
# Get project IDs
numeric_project_id=`$TW_CLOUD_IMDS_CMD/project/numeric-project-id 2>/dev/null`
project_id=`$TW_CLOUD_IMDS_CMD/project/project-id 2>/dev/null`
is replaced with:
echo "candidate_vendor[]: Google"
# Get instance name
instance_name=`$TW_CLOUD_IMDS_CMD/instance/name 2>/dev/null`
if [ "$instance_name" != "" ]; then
echo "gce_instance_name: $instance_name"
fi
# Get project IDs
numeric_project_id=`$TW_CLOUD_IMDS_CMD/project/numeric-project-id 2>/dev/null`
project_id=`$TW_CLOUD_IMDS_CMD/project/project-id 2>/dev/null`
VMware ESXi
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
Mainframe
The getNetworkConnection method has been added.
Tru64
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
Windows
getFileSystems
The following code:
}
"kind: LOCAL"
}
elseif ($_.DriveType -eq 4) {
"name: {0}" -f $_.ProviderName
"kind: REMOTE"
}
"fs_type: {0}" -f $_.FileSystem
$size = $_.Size / 1024
$free = $_.FreeSpace / 1024
}
# Need PowerShell 3.0 or later and Server 2012 or later to use Get-SmbShare
if ($PSVersionTable.PSVersion.Major -ge 3 -And Get-Command Get-SmbShare -errorAction SilentlyContinue) {
Get-SmbShare | ForEach-Object {
# Skip non Path shared (IPC$)
if (-Not $_.Path) {
is replaced with:
}
"kind: LOCAL"
"fs_type: {0}" -f $_.FileSystem
}
elseif ($_.DriveType -eq 4) {
"name: {0}" -f $_.ProviderName
"kind: REMOTE"
# Assume CIFS/SMB
"fs_type: cifs"
}
$size = $_.Size / 1024
$free = $_.FreeSpace / 1024
}
# Need PowerShell 3.0 or later and Server 2012 or later to use Get-SmbShare
$get_smbshare = false
if ($PSVersionTable.PSVersion.Major -ge 3) {
$command = Get-Command Get-SmbShare -errorAction SilentlyContinue
if ($command) {
$get_smbshare = true
}
}
if ($get_smbshare) {
Get-SmbShare | ForEach-Object {
# Skip non Path shared (IPC$)
if (-Not $_.Path) {
getFileMetadata
The following code:
if ($PSVersionTable.PSVersion.Major -ge 4) {
$hash = Get-FileHash -Path $filepath -Algorithm MD5
if ($hash) {
"md5sum: {0}" -f $hash.Hash.ToLower()
}
} else {
$hash = $null
}
if (-Not $hash) {
$content = Get-Content -Path $filepath -Raw
if ($content) {
"begin content:"
$content
}
}
$found = $true
is replaced with:
if ($PSVersionTable.PSVersion.Major -ge 4) {
try {
# MD5 will fail if Host has FIPS 140-2 mode enabled
$hash = Get-FileHash -Path $filepath -Algorithm MD5 -ErrorAction SilentlyContinue
if ($hash) {
"md5sum: {0}" -f $hash.Hash.ToLower()
}
} catch {
}
}
$found = $true
getHostInfo
The following code:
"candidate_vendor[]: Google"
# Get project IDs
try {
$numeric_project_id = Invoke-RestMethod -Headers @{"Metadata-Flavor" = "Google"} -Uri "http://metadata.google.internal/computeMetadata/v1/project/numeric-project-id" -Method get
...
$network = Invoke-RestMethod -Headers @{"Metadata-Flavor" = "Google"} -Uri "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/network" -Method get
# Build scope from network by replacing the numeric project ID with the string value
$scope -replace $numeric_project_id, $project_id
"scope: {0}" -f $scope
}
catch {
is replaced with:
"candidate_vendor[]: Google"
# Get GCE instance name
try {
$instance_name = Invoke-RestMethod -Headers @{"Metadata-Flavor" = "Google"} -Uri "http://metadata.google.internal/computeMetadata/v1/instance/name" -Method get
"gce_instance_name: {0}" -f $instance_name
}
catch {
# Ignore errors
}
# Get project IDs
try {
$numeric_project_id = Invoke-RestMethod -Headers @{"Metadata-Flavor" = "Google"} -Uri "http://metadata.google.internal/computeMetadata/v1/project/numeric-project-id" -Method get
...
$network = Invoke-RestMethod -Headers @{"Metadata-Flavor" = "Google"} -Uri "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/network" -Method get
# Build scope from network by replacing the numeric project ID with the string value
$scope = $network -replace $numeric_project_id, $project_id
"scope: {0}" -f $scope
}
catch {
NetBSD
PATH has changed. The following code:
is replaced with:
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
getHostInfo
The following code:
PRIV_DMIDECODE /usr/sbin/dmidecode 2>/dev/null | awk '/DMI type 1,/,/^Handle 0x0*[2-9]+0*/ {
if( $1 ~ /Manufacturer:/ ) { sub(".*Manufacturer: *",""); printf( "candidate_vendor[]: %s\n", $0 ); }
if( $1 ~ /Product/ && $2 ~ /Name:/ ) { sub(".*Product Name: *",""); printf( "candidate_model[]: %s\n", $0 ); }
if( $1 ~ /Serial/ && $2 ~ /Number:/ ) { sub(".*Serial Number: *",""); printf( "serial: %s\n", $0 ); }
is replaced with:
PRIV_DMIDECODE /usr/pkg/sbin/dmidecode 2>/dev/null | awk '/DMI type 1,/,/^Handle 0x0*[2-9]+0*/ {
if( $1 ~ /Manufacturer:/ ) { sub(".*Manufacturer: *",""); printf( "candidate_vendor[]: %s\n", $0 ); }
if( $1 ~ /Product/ && $2 ~ /Name:/ ) { sub(".*Product Name: *",""); printf( "candidate_model[]: %s\n", $0 ); }
if( $1 ~ /Serial/ && $2 ~ /Number:/ ) { sub(".*Serial Number: *",""); printf( "serial: %s\n", $0 ); }
OpenBSD
PATH has changed. The following code:
is replaced with:
getFileContent
The following code:
if [ $? -eq 0 ]; then
echo "begin content:"
PRIV_CAT "${P}" | sed -e 's/[^[:print:][:blank:]]//g;$a\'
fi
is replaced with:
if [ $? -eq 0 ]; then
echo "begin content:"
(PRIV_CAT "${P}" && echo) | sed -e 's/[^[:print:][:blank:]]//g'
fi
getHostInfo
The following code:
PRIV_DMIDECODE /usr/sbin/dmidecode 2>/dev/null | awk '/DMI type 1,/,/^Handle 0x0*[2-9]+0*/ {
if( $1 ~ /Manufacturer:/ ) { sub(".*Manufacturer: *",""); printf( "candidate_vendor[]: %s\n", $0 ); }
if( $1 ~ /Product/ && $2 ~ /Name:/ ) { sub(".*Product Name: *",""); printf( "candidate_model[]: %s\n", $0 ); }
if( $1 ~ /Serial/ && $2 ~ /Number:/ ) { sub(".*Serial Number: *",""); printf( "serial: %s\n", $0 ); }
is replaced with:
if( $1 ~ /Manufacturer:/ ) { sub(".*Manufacturer: *",""); printf( "candidate_vendor[]: %s\n", $0 ); }
if( $1 ~ /Product/ && $2 ~ /Name:/ ) { sub(".*Product Name: *",""); printf( "candidate_model[]: %s\n", $0 ); }
if( $1 ~ /Serial/ && $2 ~ /Number:/ ) { sub(".*Serial Number: *",""); printf( "serial: %s\n", $0 ); }