Last active
March 16, 2017 21:42
-
-
Save rbenigno/22d311a688b84aad31a03afe07169857 to your computer and use it in GitHub Desktop.
Gather storage info from a Linux server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To run with redirect to a file: | |
# bash ./storage_info.sh &> discover_$(hostname).txt | |
print_h1(){ | |
printf '\n# %s\n\n' "$@" | |
} | |
print_h2(){ | |
printf '\n## %s\n\n' "$@" | |
} | |
print_h3(){ | |
printf '\n### %s\n\n' "$@" | |
} | |
print_h1 "$(hostname)" | |
print_h2 "Current mounts (findmnt)" | |
print_h3 "Common Filesystem Mounts" | |
findmnt -t ext3,ext4,xfs,oracleasmfs,nfs | |
print_h3 "All mounts" | |
findmnt | |
print_h2 "LVM State" | |
print_h3 "pvs"; sudo pvs | |
print_h3 "vgs"; sudo vgs | |
print_h3 "lvs"; sudo lvs | |
print_h2 "Block devices" | |
print_h3 "blkid"; blkid | |
print_h3 "lsblk"; lsblk | |
print_h2 "/etc/fstab" | |
cat /etc/fstab | |
print_h2 "Grub configuration" | |
print_h3 "/boot/grub/device.map" | |
cat /boot/grub/device.map | |
print_h3 "/boot/grub/grub.conf" | |
sudo cat /boot/grub/grub.conf | |
print_h2 "PowerPath devices (powermt)" | |
if [ -x "$(command -v powermt)" ]; then | |
sudo powermt display dev=all | |
else | |
echo "powermt not found" | |
fi | |
print_h2 "EMC LUN Partition tables" | |
if [ -x "$(command -v powermt)" ]; then | |
dev_list=$(sudo powermt display dev=all | grep 'Pseudo name' | awk -F '=' '{print $2}') | |
for x in $dev_list; do | |
sudo parted /dev/$x print | |
done | |
else | |
echo "powermt not found" | |
fi | |
print_h2 "DM-Multipath devices" | |
if [ -x "$(command -v multipath)" ]; then | |
sudo multipath -l | |
else | |
echo "multipath not found" | |
fi | |
print_h2 "Oracle ASM disk mappings" | |
if [ -x "$(command -v oracleasm)" ]; then | |
asmdisks=$(sudo oracleasm listdisks) | |
if [[ ! -z $asmdisks ]]; then | |
for asmdisk in $asmdisks; do | |
major="$(sudo oracleasm querydisk -d $asmdisk | awk -F[ '{ print $2 }'| awk -F] '{ print $1 }' | awk -F, '{ print $1 }')" | |
minor="$(sudo oracleasm querydisk -d $asmdisk | awk -F[ '{ print $2 }'| awk -F] '{ print $1 }' | awk -F, '{ print $2 }')" | |
disk_name=$(ls -l /dev/* | grep ^b | grep -E "$major,\s+$minor\s" | awk '{ print $10 }') | |
printf "ASM disk: %10s = %-20s\n" "$asmdisk" "$disk_name" | |
done | |
fi | |
else | |
echo "oracleasm not found" | |
fi | |
print_h2 "Storage related info from lshw" | |
if [ -x "$(command -v lshw)" ]; then | |
print_h3 "lshw (short)"; sudo lshw -C storage,disk,volume -short | |
print_h3 "lshw (json)"; sudo lshw -C storage,disk,volume -json | |
else | |
echo "lshw not found" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment