Cloud

Oracle Cloud Infrastructure - Linux Status Script

This script is a customized login banner or dashboard utility specifically designed for an Oracle Cloud Infrastructure (OCI) instance. It is likely intended to be placed in a .bashrc or .bash_profile file to greet a user with hardware specs upon logging in via SSH.

Ensure jq is installed to parse JSON response from metadata service.
# User specific environment and startup programs

# ================================
# Instance Information
# ================================
echo ""
echo "==================================================================="
echo "  Oracle Cloud Instance Information"
echo "==================================================================="

# Public IP
PUBLIC_IP=$(curl -s ifconfig.me)
printf "  %-25s %s\n" "Public IP:" "$PUBLIC_IP"

# Get Instance Metadata
METADATA=$(curl -s -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/instance/)

# Extract Memory, OCPUs and Bandwidth 
MEMORY=$(echo "$METADATA" | jq -r '.shapeConfig.memoryInGBs')
OCPUS=$(echo "$METADATA" | jq -r '.shapeConfig.ocpus')
BANDWIDTH=$(echo "$METADATA" | jq -r '.shapeConfig.networkingBandwidthInGbps')

printf "  %-25s %s\n" "Memory:" "${MEMORY} GB"
printf "  %-25s %s\n" "OCPUs:" "${OCPUS}"
printf "  %-25s %s\n" "Network Bandwidth:" "${BANDWIDTH} Gbps"

# Show Uptime
UPTIME=$(uptime -p | sed 's/up //')
printf "  %-25s %s\n" "Uptime:" "$UPTIME"

echo "==================================================================="
echo ""
EOF