#! /Bin/bash
IP = $ (ip A | grep "Inet" | awk '{print $2}' | awk-F/'{print $1}' | grep-V 127.0.0.1 | awk' begin {rs = '\ n'} {$1 = $1; print $0} '| SED's //,/G') # retrieve all IP addresses except 127.0.0.1 and separate them with commas (,).
Hostname = $ (hostname)
Cpu_num = $ (CAT/proc/cpuinfo | grep processor | WC-l)
Mem_size = $ (expr $ (free-G | grep "mem:" | awk '{print $2}') + 1)
Disk_size = $ (expr $ (DF | grep '/data. * '| awk' {print $ (NF-4)} '| awk' begin {sum = 0} {sum = sum + $1} end {print sum} ')/1048576) # Calculate the size of other mounting disks except the system disk. A large disk is often mounted on the server, and the system disk is not used.
Nic = $ (ip A | grep "Inet" | grep-V "lo $" | grep-V "secondary" | grep-V "WLAN. * "| grep-V" Vir. * "| awk '{print $ NF}') # Collect the names of all NICs except the local loopback and virtual NICs.
Adapter1 = $ (For nic in $ Nic
Do
Speed = $ (ethtool $ Nic | grep "Speed" | awk '{print $2 }')
Driver = $ (ethtool-I $ Nic | grep "driver" | awk '{print $2 }')
Driver_version = $ (ethtool-I $ Nic | grep "^ version" | awk '{print $2 }')
Printf '% S % s,' $ Nic $ speed $ driver $ driver_version
Done)
Adapter = $ (echo $ adapter1 | sed-n's/, $ // p') # list all network card information, including network card name, network card bandwidth, the NIC Driver and its driver version. The NIC information is separated by commas (,).
OS = $ (CAT/etc/issue | sed-N '1p' | awk '{print $1 $2 $3 }')
Kernel = $ (uname-R)
Int_ip = $ (ip A | grep "Inet" | grep-V Secondary | grep eth1 | awk '{print $2}' | awk-F/'{print $1 }') # retrieve the Intranet IP address and bind it to eth1.
Shell script for collecting system information