Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 8cd36ce204
Fetching contributors…

Cannot retrieve contributors at this time

executable file 791 lines (693 sloc) 22.46 kB
#!/bin/bash
#
# Copyright (c) 2012 Joyent Inc., All rights reserved.
#
# Output some info representing the system. Default: JSON
#
# IMPORTANT:
#
# - Don't use anything here that you don't include in the live image!
#
# - This data gets cached in /tmp/.sysinfo.* and *DOES NOT* automatically
# have the cache refreshed. If you change something where the change
# needs to be visible to sysinfo, make sure you run this with either
# the -f or -u flag after changing the system's state.
#
#set -o xtrace
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/smartdc/bin:/opt/local/bin:/opt/local/sbin
CACHE_FILE_PARSABLE="/tmp/.sysinfo.parsable"
CACHE_FILE_JSON="/tmp/.sysinfo.json"
CACHE="true"
UNAME_S=$(uname -s)
ZONENAME=$(zonename)
FORCE=
PARSABLE=
UPDATE_ONLY=
while getopts fnpu? name
do
case $name in
f)
# Force re-running commands (don't read the cached values)
FORCE="true"
;;
p)
# Output key=value format, not json
PARSABLE="true"
;;
u)
# Update cache *only*, do not output.
FORCE="true"
UPDATE_ONLY="true"
;;
?)
printf "Usage: %s: [-f] [-p] [-u]\n" $0
exit 2
;;
esac
done
if [[ ${UNAME_S} != "SunOS" ]]; then
echo "This program is for use in SmartOS only."
exit 1
fi
if [[ ${EUID} != 0 ]]; then
echo "This program can only be run as root."
exit 1
fi
# If we're not forcing update and we have a cached version, use that!
if [[ -z ${FORCE} ]]; then
if [[ -z ${PARSABLE} && -s ${CACHE_FILE_JSON} ]]; then
exec cat ${CACHE_FILE_JSON}
exit 3
elif [[ -s ${CACHE_FILE_PARSABLE} ]]; then
exec cat ${CACHE_FILE_PARSABLE}
exit 3
fi
fi
# configfile here is only used on headnode
configfile="$(svcprop -p 'joyentfs/usb_copy_path' svc:/system/filesystem/smartdc:default 2>/dev/null)/config"
if [[ ! -f ${configfile} ]]; then
configfile="/mnt/$(svcprop -p 'joyentfs/usb_mountpoint' svc:/system/filesystem/smartdc:default 2>/dev/null)/config"
fi
# helper to set global "normalized" to the expanded version of MAC ($1)
function normalize_mac()
{
local mac=$1
if [ -z "${mac}" ]; then
echo "FATAL: unable to normalize empty mac!"
exit 1
fi
normalized=`echo ${mac} | awk -F':' '{ print $1, $2, $3, $4, $5, $6 }' | { read o1 o2 o3 o4 o5 o6 junk
printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${o1} 0x${o2} 0x${o3} 0x${o4} 0x${o5} 0x${o6}
}`
# ensure results are 'normal'
echo "${normalized}" | grep "[a-fA-F0-9]\{2\}\:[a-fA-F0-9]\{2\}\:[a-fA-F0-9]\{2\}\:[a-fA-F0-9]\{2\}\:[a-fA-F0-9]\{2\}\:[a-fA-F0-9]\{2\}" >/dev/null 2>&1
if [ "$?" != "0" ]; then
echo "FATAL: failed to normalize MAC '${mac}'"
exit 1
fi
}
function get_smbios_system_info()
{
# This puts the variables we're pulling out into the local environment
eval $(smbios -t SMB_TYPE_SYSTEM | tr -d "\"" \
| egrep "Manufacturer: |Product: |Serial Number: |UUID: " \
| sed -e 's/^ *//' \
| sed -e 's/: /="/' \
| sed -e 's/ *$/"/' \
| sed -e 's/Serial Number/Serial_Number/')
# overwrite UUID if config dictates otherwise
tmp_uuid=$(/usr/bin/bootparams | grep "^override_uuid=" | cut -f2 -d'=')
if [[ -n $tmp_uuid ]]; then
UUID=$tmp_uuid
fi
#echo "${UUID}"
#echo "${Product}"
#echo "${Serial_Number}"
#echo "${Manufacturer}"
}
function get_nonglobal_info()
{
UUID=$(/usr/sbin/mdata-get sdc:uuid)
QUOTA=$(/usr/sbin/zfs get -Ho value quota /)
}
function get_memory_mib()
{
# Get (misnamed in prtconf) memory size in Mebibytes
Memory_in_MiB=`prtconf 2>/dev/null \
| grep "Memory size: [0-9]* Megabytes" \
| cut -d' ' -f3`
#echo "${Memory_in_MiB}"
}
function get_smartos_cpu_info()
{
if [[ ${ZONENAME} == "global" ]]; then
CPU_Version=`smbios -t SMB_TYPE_PROCESSOR | grep -v "Version: 0000000000" \
| grep "Version: " \
| head -n1 \
| tr -s ' ' \
| sed -e 's/^ *Version: //' \
| sed -e 's/ *$//'`
CPU_Count=`smbios -t SMB_TYPE_PROCESSOR | grep -v "Version: 0000000000" \
| grep "Version: " \
| wc -l \
| tr -d ' '`
isainfo=$(isainfo -x)
if [[ -n $(echo " ${isainfo} " | /usr/bin/grep " vmx ") ]]; then
CPU_Virtualization="vmx"
elif [[ -n $(echo " ${isainfo} " | /usr/bin/grep " amd_svm ") ]]; then
CPU_Virtualization="svm"
else
CPU_Virtualization="none"
fi
fi
CPU_Cores=`psrinfo \
| grep "^[0-9]" \
| wc -l \
| tr -d ' '`
#echo "${CPU_Version}"
#echo "${CPU_Count}"
#echo "${CPU_Cores}"
}
function get_live_image_buildstamp()
{
# Add joyent buildstamp to SYSTEM_INFO
Live_Image=$(uname -v | sed -e "s/.*_//")
#echo "${Live_Image}"
}
function get_system_type()
{
Uname_System=${UNAME_S}
}
function get_vm_capable()
{
# XXX all compute nodes should now support VMs
VM_Capable="true"
}
function get_hostname()
{
Hostname=$(hostname)
}
function get_zpool_disks()
{
local zpool=$1
Zpool_disks=
for disk in $(/usr/bin/disklist -n); do
local disk_in_pool=$(/usr/sbin/zpool status ${zpool} | grep ${disk})
if [[ -n ${disk_in_pool} ]]; then
Zpool_disks="${Zpool_disks},${disk}"
fi
done
Zpool_disks=${Zpool_disks/#,/}
}
function get_zpool_profile()
{
local zpool=$1
local profiles=( mirror raidz3 raidz2 raidz )
Zpool_profile="striped"
for profile in ${profiles[*]}; do
if [[ -n $(/usr/sbin/zpool status ${zpool} | grep ${profile}) ]]; then
Zpool_profile=${profile}
break
fi
done
}
function get_zpool()
{
if [[ $(zpool list) != "no pools available" ]]; then
Zpool=$(svcprop -p "config/zpool" svc:/system/smartdc/init);
local used=$(zfs get -Hp -o value used ${Zpool})
local available=$(zfs get -Hp -o value available ${Zpool})
local size=$(( $used + $available ))
Zpool_size=$(($size / 1024 / 1024 / 1024))
get_zpool_disks ${Zpool}
get_zpool_profile ${Zpool}
fi
}
function get_disks()
{
ORIGIFS=$IFS
# set $IFS to end-of-line
IFS=`echo -en "\n\b"`
count=1
for line in $(/usr/bin/disklist -s 2>/dev/null); do
Disks[${count}]=${line}
((count++))
done
# set $IFS back
IFS=$ORIGIFS
}
function get_nic_mappings()
{
admin_nic=`/usr/bin/bootparams 2>/dev/null | grep "^admin_nic=" | cut -d '=' -f2-`
if [[ -z ${admin_nic} ]] && [[ -f ${configfile} ]]; then
admin_nic=`grep "^admin_nic=" ${configfile} | cut -f2- -d'='`
fi
if [[ -n ${admin_nic} ]]; then
normalize_mac ${admin_nic}
ADMIN_NIC=${normalized}
fi
external_nic=`/usr/bin/bootparams 2>/dev/null | grep "^external_nic=" | cut -d '=' -f2-`
if [[ -z ${external_nic} ]] && [[ -f ${configfile} ]]; then
external_nic=`grep "^external_nic=" ${configfile} | cut -f2- -d'='`
fi
if [[ -n ${external_nic} ]]; then
normalize_mac ${external_nic}
EXTERNAL_NIC=${normalized}
fi
internal_nic=`/usr/bin/bootparams 2>/dev/null | grep "^internal_nic=" | cut -d '=' -f2-`
if [[ -z ${internal_nic} ]] && [[ -f ${configfile} ]]; then
internal_nic=`grep "^internal_nic=" ${configfile} | cut -f2- -d'='`
fi
if [[ -n ${internal_nic} ]]; then
normalize_mac ${internal_nic}
INTERNAL_NIC=${normalized}
fi
#echo "${ADMIN_NIC}"
#echo "${EXTERNAL_NIC}"
#echo "${INTERNAL_NIC}"
}
function get_smartos_network_interfaces()
{
count=1
nic_tag_count=1
NicTagList="admin"
seen_nic_tag_admin="true"
# ignore 'LINK SLOT ADDRESS INUSE CLIENT' line
for line in $(pfexec /sbin/dladm show-phys -m \
| grep -v "^LINK " | awk '{ print $1,$3 }' | tr ' ' '='); do
nicnames=
fields=(${line//=/ })
iface=${fields[0]}
normalize_mac ${fields[1]}
mac=${normalized}
ip4addr=$(ifconfig ${iface} 2>/dev/null \
| grep "inet " | awk '{ print $2 }')
if [[ -n "${ADMIN_NIC}" ]] && [[ "${ADMIN_NIC}" == "${mac}" ]]; then
nicnames="admin"
NIC_admin=${iface}
fi
if [[ -n "${EXTERNAL_NIC}" ]] && [[ "${EXTERNAL_NIC}" == "${mac}" ]]; then
[[ -n ${nicnames} ]] && nicnames="${nicnames},"
nicnames="${nicnames}external"
NicTagList="${NicTagList},external"
NIC_external=${iface}
fi
if [[ -n "${INTERNAL_NIC}" ]] && [[ "${INTERNAL_NIC}" == "${mac}" ]]; then
[[ -n ${nicnames} ]] && nicnames="${nicnames},"
nicnames="${nicnames}internal"
NicTagList="${NicTagList},internal"
NIC_internal=${iface}
fi
for tag in "${NicTagsMacs[@]}"; do
tag_fields=(${tag//=/ })
tag_name=${tag_fields[0]}
normalize_mac ${tag_fields[1]}
tag_mac=${normalized}
if [[ "${tag_mac}" == "${mac}" ]]; then
[[ -n ${nicnames} ]] && nicnames="${nicnames},"
nicnames="${nicnames}${tag_name}"
NicTags[${nic_tag_count}]="${tag_name}=${iface}"
((nic_tag_count++))
fi
# Build up the list of tags
eval "seen_nic_tag=\${seen_nic_tag_${tag_name}}"
if [[ -z "${seen_nic_tag}" ]]; then
NicTagList="${NicTagList},${tag_name}"
eval "seen_nic_tag_${tag_name}=true"
fi
done
NetworkInterfaces[${count}]=${iface}
eval "Network_Interface_${iface}_MAC_Address=${mac}"
eval "Network_Interface_${iface}_IPv4_Address=${ip4addr}"
if [[ -n ${nicnames} ]]; then
eval "Network_Interface_${iface}_NIC_Names=${nicnames}"
fi
((count++))
done
for line in $(dladm show-phys -p -olink,state); do
fields=(${line//:/ })
iface=${fields[0]}
link_status=${fields[1]}
eval "Network_Interface_${iface}_Link_Status=${link_status}"
done
#echo "${NIC_admin}"
#echo "${NIC_external}"
#echo "${NIC_internal}"
#for iface in "${NetworkInterfaces[@]}"
#do
# eval "mac=\${Network_Interface_${iface}_MAC_Address}"
# eval "ipv4=\${Network_Interface_${iface}_IPv4_Address}"
# eval "nicnames=\${Network_Interface_${iface}_NIC_Names}"
# echo "mac: ${mac} ---- ${ipv4} ---- ${nicnames}"
#done
}
function get_smartos_vnics()
{
count=1
# ignore 'LINK SLOT ADDRESS INUSE CLIENT' line
for line in $(pfexec /sbin/dladm show-vnic -z '' \
| grep -v "^LINK " | awk '{ print $1,$2,$4,$6 }' | tr ' ' '='); do
fields=(${line//=/ })
iface=${fields[0]}
over=${fields[1]}
normalize_mac ${fields[2]}
mac=${normalized}
vlan=${fields[3]}
link_status=$(pfexec /sbin/dladm show-link -p -o state ${iface})
ip4addr=$(ifconfig ${iface} 2>/dev/null \
| grep "inet " | awk '{ print $2 }')
VirtualNetworkInterfaces[${count}]=${iface}
eval "Virtual_Network_Interface_${iface}_MAC_Address=${mac}"
eval "Virtual_Network_Interface_${iface}_IPv4_Address=${ip4addr}"
eval "Virtual_Network_Interface_${iface}_Link_Status=${link_status}"
eval "Virtual_Network_Interface_${iface}_VLAN=${vlan}"
eval "Virtual_Network_Interface_${iface}_Host_Interface=${over}"
((count++))
done
}
function get_nic_tags()
{
count=1
for line in $(/usr/bin/bootparams 2>/dev/null \
| grep "^[a-zA-Z0-9_]*_nic=" \
; grep "^[a-zA-Z0-9_]*_nic=" ${configfile} 2>/dev/null); do
fields=(${line//=/ })
key=${fields[0]}
if [[ $key != "admin_nic" ]] \
&& [[ $key != "external_nic" ]] \
&& [[ $key != "internal_nic" ]]; then
NicTagsMacs[${count}]=$(echo ${line} | sed -e 's/_nic//')
((count++))
fi
done
}
function get_bootparams()
{
WHICH_GREP="/usr/xpg4/bin/grep"
count=1
for line in $(/usr/bin/bootparams); do
fields=(${line//=/ })
key=$(echo ${fields[0]} | sed -e "s/\-/\_/g")
if ! (echo "${key}" | ${WHICH_GREP} \
-e "^tty" \
-e "^atapi" \
-e "^ata_dma" \
-e "^keyboard_" \
-e "^bios_boot_device" \
-e "^lba_access_" \
-e "^boot_ncpus" \
-e "^boot_file" \
-e "^whoami" \
-e "^mfg_name" \
-e "^impl_arch_name" \
-e "_max_ncpus$" \
>/dev/null); then
Bootparams[${count}]=${line}
((count++))
fi
done
}
function get_boot_time()
{
# This is all there is to it.
Boot_Time=$(/usr/bin/kstat -p -m unix -n system_misc -s boot_time | cut -f2)
}
function get_dc_info()
{
if [[ -f /.dcinfo ]]; then
Datacenter_Name=$(source /.dcinfo; echo "${SDC_DATACENTER_NAME}")
# Headnode ID is only valid if it's an integer.
Headnode_ID=$(source /.dcinfo; echo "${SDC_DATACENTER_HEADNODE_ID}" \
| grep "^[0-9]*$")
fi
}
function output_parsable()
{
cat <<END
Live_Image='${Live_Image}'
System_Type='${Uname_System}'
Boot_Time='${Boot_Time}'
END
if [[ -n ${Datacenter_Name} ]]; then
cat <<END
Datacenter_Name='${Datacenter_Name}'
END
fi
if [[ -n ${Headnode_ID} ]]; then
cat <<END
Headnode_ID=${Headnode_ID}
END
fi
if [[ ${ZONENAME} == "global" ]]; then
cat <<END
Manufacturer='${Manufacturer}'
Product='${Product}'
Serial_Number='${Serial_Number}'
VM_Capable='${VM_Capable}'
CPU_Type='${CPU_Version}'
CPU_Virtualization='${CPU_Virtualization}'
CPU_Physical_Cores=${CPU_Count}
Nic_Tags=${NicTagList}
END
else
echo "Zfs_Quota='${QUOTA}'"
fi
cat <<END
UUID='${UUID}'
Hostname='${Hostname}'
CPU_Total_Cores=${CPU_Cores}
MiB_of_Memory=${Memory_in_MiB}
END
for entry in "${Disks[@]}"; do
fields=(${entry//=/ })
disk=${fields[0]}
size=${fields[1]}
gb_size=$((${size} / 1000000000))
echo "Disk_${disk}_size_in_GB=${gb_size}"
done
[[ -n ${NIC_admin} ]] && echo "NIC_admin='${NIC_admin}'"
[[ -n ${NIC_external} ]] && echo "NIC_external='${NIC_external}'"
[[ -n ${NIC_internal} ]] && echo "NIC_internal='${NIC_internal}'"
for tag in "${NicTags[@]}"; do
tag_fields=(${tag//=/ })
tag_name=${tag_fields[0]}
int=${tag_fields[1]}
echo "NIC_${tag_name}='${int}'"
done
for iface in "${NetworkInterfaces[@]}"; do
mac_var="Network_Interface_${iface}_MAC_Address"
ipv4_var="Network_Interface_${iface}_IPv4_Address"
nicnames_var="Network_Interface_${iface}_NIC_Names"
link_status_var="Network_Interface_${iface}_Link_Status"
detected_tag_var="Network_Interface_${iface}_Detected_Nic_Tag"
eval "mac=\${${mac_var}}"
eval "ipv4=\${${ipv4_var}}"
eval "nicnames=\${${nicnames_var}}"
link_status="unknown"
eval "link_status=\${${link_status_var}}"
eval "detected_tag=\${${detected_tag_var}}"
echo "${mac_var}='${mac}'"
echo "${ipv4_var}='${ipv4}'"
echo "${nicnames_var}='${nicnames}'"
echo "${link_status_var}='${link_status}'"
if [[ -n "${detected_tag}" ]] ; then
echo "${detected_tag_var}='${detected_tag}'"
fi
done
for iface in "${VirtualNetworkInterfaces[@]}"; do
mac_var="Virtual_Network_Interface_${iface}_MAC_Address"
ipv4_var="Virtual_Network_Interface_${iface}_IPv4_Address"
link_status_var="Virtual_Network_Interface_${iface}_Link_Status"
vlan_var="Virtual_Network_Interface_${iface}_VLAN"
host_var="Virtual_Network_Interface_${iface}_Host_Interface"
eval "mac=\${${mac_var}}"
eval "ipv4=\${${ipv4_var}}"
eval "link_status=\${${link_status_var}}"
eval "vlan=\${${vlan_var}}"
eval "host=\${${host_var}}"
echo "${mac_var}='${mac}'"
echo "${ipv4_var}='${ipv4}'"
echo "${link_status_var}='${link_status}'"
echo "${vlan_var}='${vlan}'"
if [[ ${ZONENAME} == "global" ]]; then
echo "${host_var}='${host}'"
fi
done
for entry in "${Bootparams[@]}"; do
fields=(${entry//=/ })
key=$(echo ${fields[0]} | sed -e "s/\-/\_/g")
val=${fields[1]}
echo "Bootparam_${key}='${val}'"
done
}
function output_json()
{
cat <<END
{
"Live Image": "${Live_Image}",
"System Type": "${Uname_System}",
"Boot Time": "${Boot_Time}",
END
if [[ -n ${Datacenter_Name} ]]; then
cat <<END
"Datacenter Name": "${Datacenter_Name}",
END
fi
if [[ -n ${Headnode_ID} ]]; then
cat <<END
"Headnode ID": ${Headnode_ID},
END
fi
if [[ ${ZONENAME} == "global" ]]; then
cat <<END
"Manufacturer": "${Manufacturer}",
"Product": "${Product}",
"Serial Number": "${Serial_Number}",
"VM Capable": ${VM_Capable},
"CPU Type": "${CPU_Version}",
"CPU Virtualization": "${CPU_Virtualization}",
"CPU Physical Cores": ${CPU_Count},
END
else
echo " \"ZFS Quota\": \"${QUOTA}\","
fi
cat <<END
"UUID": "${UUID}",
"Hostname": "${Hostname}",
"CPU Total Cores": ${CPU_Cores},
"MiB of Memory": "${Memory_in_MiB}",
END
if [[ ${ZONENAME} == "global" ]]; then
if [[ -n ${Zpool} ]]; then
echo ' "Zpool": "'${Zpool}'",'
echo ' "Zpool Disks": "'${Zpool_disks}'",'
echo ' "Zpool Profile": "'${Zpool_profile}'",'
echo ' "Zpool Size in GiB":' ${Zpool_size}','
fi
echo ' "Disks": {'
printed=0
for entry in "${Disks[@]}"; do
fields=(${entry//=/ })
disk=${fields[0]}
size=${fields[1]}
gb_size=$((${size} / 1000000000))
((printed++))
trailing_comma=","
[[ ${printed} -eq ${#Disks[*]} ]] && trailing_comma=''
echo " \"${disk}\": {\"Size in GB\": ${gb_size}}${trailing_comma}"
done
cat <<END
},
"Boot Parameters": {
END
printed=0
for entry in "${Bootparams[@]}"; do
fields=(${entry//=/ })
key=$(echo ${fields[0]} | sed -e "s/\-/\_/g")
val=${fields[1]}
((printed++))
trailing_comma=","
[[ ${printed} -eq ${#Bootparams[*]} ]] && trailing_comma=''
echo " \"${key}\": \"$val\"${trailing_comma}"
done
cat <<END
},
"Network Interfaces": {
END
printed=0
for iface in "${NetworkInterfaces[@]}"; do
mac_var="Network_Interface_${iface}_MAC_Address"
ipv4_var="Network_Interface_${iface}_IPv4_Address"
nicnames_var="Network_Interface_${iface}_NIC_Names"
link_status_var="Network_Interface_${iface}_Link_Status"
detected_tag_var="Network_Interface_${iface}_Detected_Nic_Tag"
nic_names_fmt=
detected_fmt=
eval "mac=\${${mac_var}}"
eval "ipv4=\${${ipv4_var}}"
eval "nicnames=\${${nicnames_var}}"
eval "link_status=\${${link_status_var}}"
eval "detected_tag=\${${detected_tag_var}}"
if [[ -n "${detected_tag}" ]] ; then
detected_fmt="\"Detected NIC Name\": \"${detected_tag}\", "
fi
nic_names_array=$(echo "${nicnames}" | sed -e "s/,/\", \"/g")
if [[ -n ${nic_names_array} ]]; then
nic_names_fmt="\"${nic_names_array}\""
fi
((printed++))
trailing_comma=","
[[ ${printed} -eq ${#NetworkInterfaces[*]} ]] && trailing_comma=''
echo -n " \"${iface}\": {"
echo -n "\"MAC Address\": \"${mac}\", "
echo -n "\"ip4addr\": \"${ipv4}\", "
echo -n "\"Link Status\": \"${link_status}\", "
echo -n "${detected_fmt}"
echo -n "\"NIC Names\": [${nic_names_fmt}]}"
echo "${trailing_comma}"
done
echo " },"
fi
cat << END
"Virtual Network Interfaces": {
END
printed=0
for iface in "${VirtualNetworkInterfaces[@]}"; do
mac_var="Virtual_Network_Interface_${iface}_MAC_Address"
ipv4_var="Virtual_Network_Interface_${iface}_IPv4_Address"
link_status_var="Virtual_Network_Interface_${iface}_Link_Status"
vlan_var="Virtual_Network_Interface_${iface}_VLAN"
parent_var="Virtual_Network_Interface_${iface}_Host_Interface"
eval "mac=\${${mac_var}}"
eval "ipv4=\${${ipv4_var}}"
eval "link_status=\${${link_status_var}}"
eval "vlan=\${${vlan_var}}"
eval "host=\${${host_var}}"
((printed++))
trailing_comma=","
[[ ${printed} -eq ${#VirtualNetworkInterfaces[*]} ]] && trailing_comma=''
echo -n " \"${iface}\": {"
echo -n "\"MAC Address\": \"${mac}\", "
echo -n "\"ip4addr\": \"${ipv4}\", "
echo -n "\"Link Status\": \"${link_status}\", "
if [[ ${ZONENAME} == "global" ]]; then
echo -n "\"Host Interface\": \"${host}\", "
fi
echo -n "\"VLAN\": \"${vlan}\"}"
echo "${trailing_comma}"
done
cat <<END
}
}
END
}
if [[ ${ZONENAME} == "global" ]]; then
get_smbios_system_info
get_vm_capable
get_zpool
get_disks
get_bootparams
else
get_nonglobal_info
fi
get_memory_mib
get_smartos_cpu_info
get_live_image_buildstamp
get_system_type
get_hostname
get_nic_mappings
get_nic_tags
get_smartos_network_interfaces
get_smartos_vnics
get_boot_time
get_dc_info
# whenever we update the cache, update both
if [[ ${CACHE} == "true" ]]; then
output_parsable >> ${CACHE_FILE_PARSABLE}.new.$$ \
&& chmod 600 ${CACHE_FILE_PARSABLE}.new.$$ \
&& mv ${CACHE_FILE_PARSABLE}.new.$$ ${CACHE_FILE_PARSABLE}
output_json >> ${CACHE_FILE_JSON}.new.$$ \
&& chmod 600 ${CACHE_FILE_JSON}.new.$$ \
&& mv ${CACHE_FILE_JSON}.new.$$ ${CACHE_FILE_JSON}
fi
# if we also want output, give it now
if [[ -z ${UPDATE_ONLY} ]]; then
if [[ ${PARSABLE} == "true" ]]; then
if [[ -z ${CACHE} ]]; then
# We shouldn't read/write cache
output_parsable
else
cat ${CACHE_FILE_PARSABLE} \
|| output_parsable
fi
else
if [[ -z ${CACHE} ]]; then
# We shouldn't read/write cache
output_json
else
cat ${CACHE_FILE_JSON} \
|| output_json
fi
fi
fi
exit 0
Jump to Line
Something went wrong with that request. Please try again.