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)