|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +mkdir -p /Inventory |
| 4 | +sudo chmod -R 777 /Inventory/ |
| 5 | +mkdir -p /tmp/asset |
| 6 | +touch /tmp/asset/`hostname`.txt |
| 7 | +touch /tmp/temptext |
| 8 | +TEMP=/tmp/temptext |
| 9 | +LOG=`ls /tmp/asset/*.txt` |
| 10 | +echo "## Host Information" > $LOG |
| 11 | +echo "Host Name : `hostname` " >> $LOG |
| 12 | +echo "`sudo /sbin/ifconfig -a |grep "inet" | awk 'BEGIN { FS = ":" } ; { print $2 }'`" >> $TEMP |
| 13 | +echo "IP Address : `egrep '^10' $TEMP |awk '{ print $1}'`" >> $LOG |
| 14 | +echo "IP Address: `hostname -I`" >> $LOG |
| 15 | +echo "ip a |grep inet |grep -v "::" |awk '{print $2}'" >> $LOG |
| 16 | +echo "iDrac Details: `racadm getniccfg |grep "IP Address" |grep -v "::"`" >> $LOG |
| 17 | +echo "Server Type: `servertype=$(lscpu | grep Hypervisor | wc -l); if [ $servertype -gt 0 ]; then echo "VitualMachine"; else echo "Physical"; fi`" >> $LOG |
| 18 | +echo -en '\n' >> $LOG |
| 19 | +
|
| 20 | +## Collecting Hardware Details ## |
| 21 | +echo " " >> $LOG |
| 22 | +echo "## Hardware Information" >> $LOG |
| 23 | +echo " " >> $LOG |
| 24 | +echo "Serial Number : `sudo lshal |grep system.hardware.serial`" >> $LOG |
| 25 | +echo "Serial Number : `sudo /usr/sbin/dmidecode -s system-serial-number`" >> $LOG |
| 26 | +echo "Serial Number : `sudo cat /sys/class/dmi/id/product_serial`" >> $LOG |
| 27 | +echo "Model Number : `sudo lshal |grep system.hardware.product`" >> $LOG |
| 28 | +echo "Model Number : `sudo /usr/sbin/dmidecode |grep "SKU Number"`" >> $LOG |
| 29 | +echo "Model Number : `sudo cat /sys/class/dmi/id/product_name`" >> $LOG |
| 30 | +echo "Hardware Vendor : `sudo lshal |grep system.hardware.vendor`" >> $LOG |
| 31 | +echo "Hardware Vendor : `sudo cat /sys/class/dmi/id/chassis_vendor`" >> $LOG |
| 32 | +echo "Hardware Info : `sudo dmesg |grep DMI`" >> $LOG |
| 33 | +
|
| 34 | +## Redhat Version ## |
| 35 | +echo " " >> $LOG |
| 36 | +echo "## OS Version" >> $LOG |
| 37 | +head -n1 /etc/issue >> $LOG |
| 38 | +cat /etc/redhat-release >> $LOG |
| 39 | +echo "Kernel Version: `uname -r`">> $LOG |
| 40 | +echo "OS Version: `hostnamectl | egrep "Operating System" | cut -d ' ' -f5-`" >> $LOG |
| 41 | +
|
| 42 | +## CPU Info ## |
| 43 | +echo " " >> $LOG |
| 44 | +echo " " >> $LOG |
| 45 | +echo "## CPU Information" >> $LOG |
| 46 | +grep "model name" /proc/cpuinfo |uniq >> $LOG |
| 47 | +COUNTT=$(cat /proc/cpuinfo |grep "model name" | wc -l) |
| 48 | +echo "$COUNTT Cores" >> $LOG |
| 49 | +
|
| 50 | +## RAM/MEMORY Info ## |
| 51 | +echo " " >> $LOG |
| 52 | +echo " " >> $LOG |
| 53 | +echo "## Memory Information" >> $LOG |
| 54 | +grep MemTotal /proc/meminfo >> $LOG |
| 55 | +y=`grep MemTotal /proc/meminfo |awk '{ print $2 }'` |
| 56 | +mb="$(( $y / 1024 ))" |
| 57 | +gb="$(( $mb / 1024 ))" |
| 58 | +echo "RAM : $gb GB" >> $LOG |
| 59 | +
|
| 60 | +## Swap Information ## |
| 61 | +echo " " >> $LOG |
| 62 | +echo "## Swap Information" >> $LOG |
| 63 | +y1=$(free -k |grep Swap |awk '{print $2}') |
| 64 | +mb1="$(( $y1 / 1024 ))" |
| 65 | +gb1="$(( $mb1 / 1024 ))" |
| 66 | +echo "Swap Size: $gb1 GB" >> $LOG |
| 67 | +
|
| 68 | +## Disk Information ## |
| 69 | +echo " " >> $LOG |
| 70 | +echo "## Disk Information" >> $LOG |
| 71 | +lsblk |grep -E 'part|disk' $LOG |
| 72 | +
|
| 73 | +## LVM Information ## |
| 74 | +echo " " >> $LOG |
| 75 | +echo "## Physical Volumes" >> $LOG |
| 76 | +pvs >> $LOG |
| 77 | +
|
| 78 | +echo " " >> $LOG |
| 79 | +echo "## Volume Groups" >> $LOG |
| 80 | +vgs >> $LOG |
| 81 | +
|
| 82 | +echo " " >> $LOG |
| 83 | +echo "## Logical Volumes" >> $LOG |
| 84 | +lvs >> $LOG |
| 85 | +echo " " >> $LOG |
| 86 | +
|
| 87 | +## Partition Information ## |
| 88 | +echo "## DF Command Output" >> $LOG |
| 89 | +echo " " >> $LOG |
| 90 | +df -Ph -x tmpfs -x devtmpfs| sed s/%//g | awk '{ if($5 > 0) print $0;}' >> $LOG |
| 91 | +
|
| 92 | +echo " " >> $LOG |
| 93 | +echo "## Port Information" >> $LOG |
| 94 | +ss -alntup |column -t |grep -E 'tcp|udp' >> $LOG |
| 95 | +
|
| 96 | +echo " " >> $LOG |
| 97 | +echo "## Service Information" >> $LOG |
| 98 | +systemctl list-units --type=service --state=active |grep -vE 'systemd|selinux' >> $LOG |
| 99 | +
|
| 100 | +echo " " >> $LOG |
| 101 | +echo "## Docker Containers" >> $LOG |
| 102 | +sudo docker ps -a >> $LOG |
| 103 | +
|
| 104 | +sudo cp /tmp/asset/`hostname`.txt /Inventory/`hostname`-`date "+%Y-%m-%d"`.txt |
0 commit comments