1.创建脚本
#!/bin/bash
#第一部分:系统信息===
sys_info(){
sys_type=(uname)sysversion=(uname)sysversion= (uname)sys_version=(uname)sysv​ersion=(cat /etc/redhat-release)
sys_core=(uname−r)sysdate=(uname−r)sysdate= (uname -r)sys_date=(uname−r)sysd​ate=(date +%F_%T)
sys_last_reboot=KaTeX parse error: Expected 'EOF', got '}̲' at position 80: …t position 2: 3}̲̲̲') sys_hostname…{sys_type}”
echo “系统版本号: ${sys_version}”
echo “系统内核: ${sys_core}”
echo “系统当前运行时间: ${sys_date}”
echo “系统最后重启时间: ${sys_last_reboot}”
echo “主机名称: KaTeX parse error: Expected ‘EOF’, got ‘}’ at position 17: …sys_hostname}"

#第二部分:网络信息====…(ifconfig |grep 192|awk ‘{print KaTeX parse error: Expected ‘EOF’, got ‘}’ at position 2: 2}̲’)
echo "本机主机的i…net”
ping baidu.com -c 1 >/dev/null
if [ KaTeX parse error: Expected 'EOF', got '}' at position 56: … “请查看你的网络!” fi }̲ #第三部分:硬件信息====…(lscpu|sed -n ‘4p’|awk ‘{print KaTeX parse error: Expected ‘EOF’, got ‘}’ at position 2: 2}̲’)
cpu_core=(cat /proc/cpuinfo |grep “core id”|sort |uniq |wc -l)
cpu_mode=KaTeX parse error: Expected 'EOF', got '}̲' at position 128: …t position 2: 2}̲̲̲') echo "cpu的个数…(free -m|grep Mem|awk ‘{print KaTeX parse error: Expected ‘EOF’, got ‘}’ at position 2: 2}̲’)
mem_free=(free -m|grep Mem|awk ‘{print KaTeX parse error: Expected ‘EOF’, got ‘}’ at position 2: 4}̲’)
echo “内存总量为:{mem_total}”
echo “剩余内存总量为:${mem_free}”
}
disk_info(){
var=(df -T|grep -v tmpfs|sed ‘1d’|awk ‘{print $3}’)
int=0
for i in ${var[@]}
do
size=expr $int + idoneechoi done echo “磁盘总量为:size”
}
while :
do
sys_info
net_info
cpu_info
mem_info
disk_info
sleep 1
done
效果如下:
系统巡查脚本

相关文章:

  • 2022-01-16
  • 2021-07-27
  • 2022-12-23
  • 2022-01-02
  • 2022-01-17
  • 2021-07-16
  • 2022-01-17
  • 2022-01-22
猜你喜欢
  • 2022-01-20
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2021-05-09
  • 2021-09-16
相关资源
相似解决方案