Shell checks the system hardware information of online servers.

Source: Internet
Author: User
Checks the system hardware information of online servers, including: IP address (intranet, all), remote control card IP address, cpu information (number of cores), memory, hard disk, machine code, manufacturer, and product name #! /Bin/sh # Check the system hardware information of the online server #2012/01/05 ip = 'ifconfig | awk' {print $1, $2} '| grep-e 'link'-e 'inetaddr:' | awk '{if ($2 ~ /Link /)

Checks system hardware information of online servers, including IP addresses (intranet, all), IP addresses of remote control cards, cpu information (cores), memory, hard disks, machine codes, manufacturers, and product names.
#! /Bin/sh
# Checking System hardware information of online servers
#2012/01/05
Ip = 'ifconfig | awk' {print $1, $2} '| grep-e 'link'-e' inet addr:' | awk '{if ($2 ~ /Link/) {ORS = ""; print $1} else if ($1 ~ /Inet/) {ORS = "", "; split ($2, a,": "); print": "a [2]}''
Ipfirst = 'echo $ ip | awk-F, '{print $1}' | awk-F: '{print $ NF }''
Ipall = 'IP a s | awk-F' [\ t/] + ''/^ * inet/& $ NF !~ /Lo/{printf "% s: % s,", $ NF, $3} '| sed's/, $ //''
# CPU type/clock speed/number of cores
Cpu = 'sed-r's/[\ t] + // G'/proc/cpuinfo | awk-F ": + "'/^ model name/{a [$2] ++} END {for (I in a) printf" % s (x % s) \ n ", I, a [I]}''
# Memory size per entry * quantity
Memory = 'dmidecode | grep-A6 '^ Memory devic' | sed-r's/^ [\ t] + //' | awk'/^ Size. * MB/{a [$2/1024] ++} END {for (I in a) printf "% sx % s,", I, a [I]} '| sed's/, $ //''
# Hard Disk size, in GB
Disk = 'fdisk-l 2>/dev/null | awk'/^ Disk/{printf "%. 0f + ", $3} '| sed's/+ $ //''
# Server machine code
SN = 'dmidecode | grep-A6 'System information' | sed-rn's/^ \ s * Serial Number: \ s ([0-9A-Za-z] +) \ s * $/\ 1/P''
# Manufacturer
Manufacturer = 'dmidecode | grep-A6 'System information' | sed-rn's/^ \ s * Manufacturer: \ s + (. +) \ s * $/\ 1/p''
# Product Name
Product = 'dmidecode | grep-A6 'System information' | sed-rn's/^ \ s * Product Name: \ s + (. +) \ s * $/\ 1/p''
# Remote control card IP
Drac_ip = 'ipmitool-I open lan print 1 | grep "IP Address" | awk-F: '{print $2}' | sed's ///''

Echo "{$ HOSTNAME}" "{$ ipfirst}" "{$ ipall}" "{$ cpu}" "{$ memory}" "{$ disk}" "{$ SN} "" {$ Manufacturer} "" {$ Product} "{$ drac_ip }"

Run/etc/init. d/ipmi start before running the script. Otherwise, drac_ip will not be available.
The running result is:
{Web01} {192.168.103.168} {eth0: 192.168.103.168} {Intel (R) Xeon (R) CPU X5560 @ 2.80 GHz (x16 )} {8x2} {3999 + 299} {BTNKY2X} {Dell Inc .} {PowerEdge R710} {192.168.1.168}
Virtual Machine (the last entry is blank because there is no remote control card)
{Lx_web_s1} {192.168.0.5} {eth0: 192.168.0.5, tun0: 10.8.0.1} {Intel (R) Core (TM) i5-2430M CPU @ 2.40 GHz (x1 )} {0.5x1} {21 }{}{ VMware, Inc .} {VMware Virtual Platform }{}

There are many implementation methods. If you have any additional information, please share with us.

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.