系统检测
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# 判断是什么系统类型
if [ -f /etc/redhat-release ]; then
SYSTEM=0
else
SYSTEM=1
fi
function centos_info()
{
net_ip=`curl -s ip.sb`
intranet_ip=`ifconfig | grep inet | grep -vE 'inet6|127.0.0.1' | awk '{print $2}'`
echo -e "外网IP: \t"$net_ip
echo -e "内网IP: \t"$intranet_ip
cpu_num=`grep -c "model name" /proc/cpuinfo`
echo -e "cpu总核数: \t"$cpu_num
echo "$( date "+%Y-%m-%d %H:%M:%S" ):内存监控"
# MEM=$( vmstat 2 5 | )
}
function ubuntu_info()
{
IP=`ifconfig | grep inet | grep -vE 'inet6|127.0.0.1' | awk '{print $2}' | awk -F":" '{print $2}'`
echo -e "IP地址:"$IP
}
if [ $SYSTEM -eq 0 ]; then
centos_info
else
ubuntu_info
fi
本文由作者按照
CC BY 4.0
进行授权