Get CentOS Server Information shell script

Source: Internet
Author: User
Tags centos server
This script has been tested on ubuntu and centos. The script is as follows :#! /Bin/bashLine = & amp; #39 ;==============& amp; #39; # linux release name if [[-f/usr/bin/lsb_release]; thios = $ (/usr/bin/lsb_release-a | grepDescription | awk-F: & amp; #39; {print $2} & #39;

This script has been tested on ubuntu and centos. The script is as follows:

#! /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 '\ '| 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 }"


Bytes ----------------------------------------------------------------------------------------

Test result display:

==============
OS:
Red Hat Enterprise Linux Server release 5.6 (Tikanga)
==============
OS _version:
I686
==============
Kernel_version:
2.6.18-238. el5
==============
CPU model:
AMD A6-3400M APU with Radeon (tm) HD Graphics
==============
Total of physical CPU:
2
==============
Number of CPU cores
2
==============
Number of logical CPUs:
4
==============
Present Mode Of CPU:
32
==============
Support Mode Of CPU:
64
==============
Total Memory:
514744 kB
==============
Maxinum Memory Capacity:
1024 GB
==============
Number of Physical Memory:
1
==============
Total Swap:
1044216 kB
==============
Buffers:
101936 kB
==============
Cached:
267356 kB
==============
Available Memory:
369 MB
==============
Amount Of Disks:
Disk/dev/sda: 107.3 GB
==============
Usage Of partions:
/Dev/sda3 96G 4.6G 87G 6%/
/Dev/sda1 99 M 12 M 83 M 13%/boot
Tmpfs 252 M 0 252 M 0%/dev/shm
/Dev/hdc 3.0G 3.0G 0 100%/media/RHEL_5.6 i386 DVD
==============

This article is from the "Linux technology" blog, please be sure to keep this source http://chenronghua.blog.51cto.com/7972352/1309854


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.