--- /dev/null
+#!/bin/sh
+
+. ${CIRROS_LIB:=/lib/cirros/shlib_cirros} ||
+ { echo "failed to read ${CIRROS_LIB}" 1>&2; exit 1; }
+
+Usage() {
+ cat <<EOF
+Usage: ${0##*/} [ options ]
+
+ output status of the system.
+ Normally this would be used for debugging, or to console
+ to show user information.
+
+ options:
+ -v | --verbose : be more verbose
+EOF
+}
+
+cleanup() {
+ [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
+}
+
+cirros_status() {
+ local short_opts="hv"
+ local long_opts="help,verbose"
+ local getopt_out=""
+ getopt_out=$(getopt --name "${0##*/}" \
+ --options "${short_opts}" --long "${long_opts}" -- "$@") &&
+ eval set -- "${getopt_out}" ||
+ { bad_Usage; return; }
+
+ local cur="" next="" mode="" VERBOSITY
+
+ while [ $# -ne 0 ]; do
+ cur=${1}; next=${2};
+ case "$cur" in
+ -h|--help) Usage ; exit 0;;
+ -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
+ --) shift; break;;
+ esac
+ shift;
+ done
+
+ [ $# -eq 0 ] || { bad_Usage "no arguments expected"; return; }
+
+ TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") ||
+ { error "failed to make tempdir"; return 1; }
+ trap cleanup EXIT
+
+ local container=""
+ container=$(lxc-is-container -v) || container="none"
+ echo "=== system information ==="
+ # Example: Red Hat Inc. OpenStack Nova
+ echo -n "Platform: "
+ dmesg | grep DMI: | sed -n 's/.*[ ]\+DMI:[ ]*\(.\+\), BIOS.*/\1/p'
+ echo "Container: ${container}"
+
+ lscpu | awk '$1 == "Architecture:" { arch=$2 };
+ $1 == "Socket(s):" { sockets=$2 };
+ $0 ~ /^Core.*per socket:/ { cores=$4 };
+ $0 ~ /^Thread.*core:/ { threads=$4 };
+ $1 == "CPU(s):" { cpus=$2; } ;
+ $1" "$2 == "CPU MHz:" { mhz=$3 };
+ $1 == "Virtualization:" { virt=$2 };
+ END {
+ printf("Arch: %s\nCPU(s): %s @ %s MHz\nCores/Sockets/Threads: %s/%s/%s\n",
+ arch, cpus, mhz, cores, sockets, threads);
+ printf("Virt-type: %s\n", virt);
+ }' \
+ arch="na" cpus="na" mhz="na" cores="na" sockets="na" threads="na"
+
+ awk '$1 == "MemTotal:" { printf("RAM Size: %dMB\n", $2/1024)}' /proc/meminfo
+
+ if [ "$container" = "none" ]; then
+ echo "Disks:"
+ asroot lsblk --ascii --list --bytes --output NAME,MAJ:MIN,SIZE,LABEL,MOUNTPOINT
+ fi
+
+ echo "=== sshd host keys ==="
+ echo "-----BEGIN SSH HOST KEY KEYS-----"
+ asroot dropbearkey -f /etc/dropbear/dropbear_rsa_host_key -y | grep ^ssh-rsa
+ asroot dropbearkey -f /etc/dropbear/dropbear_dss_host_key -y | grep ^ssh-dss
+ echo "-----END SSH HOST KEY KEYS-----"
+
+ local oifs="$IFS" x="" val=""
+ echo "=== network info ==="
+ ip addr show > "$TEMP_D/ip-addr-show"
+ ipinfo < "$TEMP_D/ip-addr-show"
+ IFS="|"; set -- $_RET; IFS="$oifs"
+ for x in "$@"; do
+ echo "if-info: $x"
+ done
+ ip route | sed 's,^,ip-route:,'
+
+ if assert_datasource; then
+ echo "=== datasource: $_DATASOURCE_NAME $_DATASOURCE_MODE ==="
+ for x in instance-id name availability-zone local-hostname \
+ launch-index; do
+ ds_get_item "$x" && val="$_RET" || val="N/A"
+ echo "$x: ${val}"
+ done
+ else
+ echo "=== datasource: None None ==="
+ fi
+
+ local cur="" avail="" msg=""
+ cirros_version_available && avail="$_RET"
+ cirros_version && cur="$_RET"
+ msg="current=$cur"
+ [ "$avail" != "0.0" ] && msg="$msg latest=$avail"
+
+ read_uptime && [ -n "$_RET" ] && msg="$msg uptime=$_RET"
+ echo "=== cirros: $msg ==="
+
+ if ! check_ping_gateway; then
+ echo "=== pinging gateway failed, debugging connection ==="
+ debug_connection
+ fi
+
+ return 0
+}
+
+cirros_status "$@"
+
+# vi: ts=4 noexpandtab