Centos6.x hardware statistics script
To collect the hardware information of a batch of machines, a script is temporarily searched on the internet, recorded, and used up later.
#! /Bin/bash
Line = '============'
# Linux release name
If [[-f/usr/bin/lsb_release]; then
OS = $ (/usr/bin/lsb_release-a | grep Description | awk-F: '{print $2}' | sed's/^ [t] * // G ')
Else
OS = $ (cat/etc/issue | sed-n '1p ')
Fi
Echo-e "$ {Line} \ nOS: \ n $ {OS} \ n $ {Line }"
######################################## ######################################## ######################
# Check whether the system is 64-bit: uname-m. If x86_64 is displayed, It is 64-bit.
OS _version = $ (uname-m)
Echo-e "OS _version: \ n $ {OS _version} \ n $ {Line }"
# System kernel version
Kernel_version = $ (uname-r)
Echo-e "Kernel_version: \ n $ {kernel_version} \ n $ {Line }"
# Cpu Model
CPU = $ (grep 'model name'/proc/cpuinfo | uniq | awk-F: '{print $2}' | sed's/^ [t] * // G' | sed's/+ // G ')
Echo-e "CPU model: \ n $ {CPU} \ n $ {Line }"
# Number of physical CPUs
Counts = $ (grep 'physical id'/proc/cpuinfo | sort | uniq | wc-l)
Echo-e "Total of physical CPU: \ n $ {Counts} \ n $ {Line }"
# Number of physical cpu Cores
Cores = $ (grep 'cpu cores'/proc/cpuinfo | uniq | awk-F: '{print $2}' | sed's/^ [t] * // G ')
Echo-e "Number of CPU cores \ n $ {Cores} \ n $ {Line }"
# Logical cpu count
PROCESSOR = $ (grep 'processor '/proc/cpuinfo | sort | uniq | wc-l)
Echo-e "Number of logical CPUs: \ n $ {PROCESSOR} \ n $ {Line }"
# Check whether the current CPU running mode is 64-bit or 32-bit
Mode = $ (getconf LONG_BIT)
Echo-e "Present Mode Of CPU: \ n $ {Mode} \ n $ {Line }"
# Check whether the CPU supports 64-Bit Technology: grep 'flags '/proc/cpuinfo. If the flags information contains the lm field, it supports 64-bit
Numbers = $ (grep 'lm '/proc/cpuinfo | wc-l)
If ($ {Numbers}> 0); then lm = 64
Else lm = 32
Fi
Echo-e "Support Mode Of CPU: \ n $ {lm} \ n $ {Line }"
######################################## ##############################
# Total Memtotal memory size
Total = $ (cat/proc/meminfo | grep 'memtotal' | awk-F: '{print $2}' | sed's/^ [t] * // G ')
Echo-e "Total Memory: \ n $ {Total} \ n $ {Line }"
# Maximum memory supported by the system
Max_Capacity = $ (dmidecode-t memory-q | grep 'maximum Capacity '| awk-F: '{print $2}' | sed's/^ [t] * // G ')
Echo-e "Maxinum Memory Capacity: \ n $ {Max_Capacity} \ n $ {Line }"
# View information about the memory type, frequency, number of items, and maximum supported Memory: dmidecode-t memory, or dmidecode | grep-A16 "Memory Device $"
# The following figure shows the number of memory records.
Number = $ (dmidecode | grep-A16 "Memory Device $" | grep Size | sort | sed's/^ [t] * // G' | grep-V' No Module installed '| wc-l)
Echo-e "Number of Physical Memory: \ n $ {Number} \ n $ {Line }"
# SwapTotal swap partition size
SwapTotal = $ (cat/proc/meminfo | grep 'swaptotal' | awk-F: '{print $2}' | sed's/^ [t] * // G ')
Echo-e "Total Swap: \ n $ {SwapTotal} \ n $ {Line }"
# Buffers size
Buffers = $ (cat/proc/meminfo | grep 'buffers' | awk-F: '{print $2}' | sed's/^ [t] * // G ')
Echo-e "Buffers: \ n $ {Buffers} \ n $ {Line }"
# Cached size
Cached = $ (cat/proc/meminfo | grep '<Cached>' | awk-F: '{print $2}' | sed's/^ [t] * // G ')
Echo-e "Cached: \ n $ {Cached} \ n $ {Line }"
# Idle memory + buffers/cache
Available = $ (free-m | grep-| awk-F: '{print $2}' | awk '{print $2 }')
Echo-e "Available Memory: \ n $ {Available} MB \ n $ {Line }"
# Display hard disk and size
Disk = $ (fdisk-l | grep 'disk' | awk-F, '{print $1}' | sed's/Disk identifier. * // G' | sed '/^ $/D ')
Echo-e "Amount Of Disks: \ n $ {Disk} \ n $ {Line }"
# Usage of each Mount Partition
Partion = $ (df-hlP | sed-n'2, $ p ')
Echo-e "Usage Of partions: \ n $ {Partion} \ n $ {Line }"