Linux Script acquisition System Information (selected from experimental building experiment)

Source: Internet
Author: User

After executing the getinfo.sh script, no parameters are required and the output reads as follows:
$ bash getinfo.sh
CPU Num:2
Memory total:2.8g
Memory free:329m
Disk size:10g
System bit:32
Process:32
Software num:944
ip:192.168.1.9

Explain:
Number of CPUs (CPU num)
Total Memory, Unit G
Available memory (Memorty free), in units of M
Total size of file system mounted to/root directory (disk size) in G
System bit number
Number of processes currently running on the system (process)
To view the number of installed packages (software num)
IP address of the eth0 (IP)

The shell script is as follows:
#!/bin/bash
A=cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
b=free -m | grep Mem | awk ‘{print $2}‘
C=free -m | grep Mem | awk ‘{print $4}‘
D=df -h | sed -n 3p | awk ‘{print $1}‘
E=getconf LONG_BIT
f=ps auxw | wc -l
H=yum list installed | wc -l
I=ifconfig eth0 | sed -n 2p | awk -F ":" ‘{print $2}‘ | awk ‘{print $1}‘
echo "\ $bash getinfo.sh"
echo "CPU num: $a"
echo "Memory Total:${b}m"
echo "Memory Free:${c}m"
echo "Disk size: $d"
echo "System bit: $e"
echo "Process: $f"
echo "Software num: $h"
echo "IP: $i"

Linux Script acquisition System Information (selected from experimental building experiment)

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.