Shell script for collecting system information

Source: Internet
Author: User

#! /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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.