#!/bin/bash
#日期:2020-2-19
#描述:系统基础信息
mkdir /var/log/everyone &>/dev/null
system_status="/var/log/everyone/today.txt"
date=`date +"%Y-%m-%d %H:%M:%S"`
user=`who -H`
hostname=`hostname`
ip=`ifconfig | awk 'NR==2 {print $2}'`
system=`cat /etc/redhat-release`
cpu=`lscpu`
memory=`free -h`
disk=`df -h`
running_time=`uptime`
login_user=`last -n 10`
firewall=`systemctl status firewalld.service | awk 'NR==3 {print $2}'`
selinux=`cat /etc/sysconfig/selinux | awk 'NR==7 {print $1}'`
echo "-----------------------
现在时间:$date
登录系统用户:
$user
主机名:$hostname
主机IP:$ip
系统类型:$system
cpu属性:
$cpu
内存信息:
$memory
硬盘信息:
$disk
系统运行时间:$running_time
最近十个登录用户:
$login_user
防火墙状态:$firewall
selinux启动状态:$selinux
-------------------" > $system_status
查看指定输出文件,查看执行效果
[root@linus ~]# cat /var/log/everyone/today.txt
-----------------------
现在时间:2020-02-20 00:00:39
登录系统用户:
名称 线路 时间 备注
root tty2 2020-02-19 23:42
root pts/0 2020-02-19 23:45 (192.168.1.11)
主机名:linus.linux
主机IP:192.168.1.124
系统类型:CentOS Linux release 7.4.1708 (Core)
cpu属性:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 2
座: 2
NUMA 节点: 1
厂商 ID: GenuineIntel
CPU 系列: 6
型号: 158
型号名称: Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz
步进: 10
CPU MHz: 2302.988
BogoMIPS: 4608.00
超管理器厂商: VMware
虚拟化类型: 完全
L1d 缓存: 32K
L1i 缓存: 32K
L2 缓存: 256K
L3 缓存: 8192K
NUMA 节点0 CPU: 0-3
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec arat
内存信息:
total used free shared buff/cache available
Mem: 1.8G 265M 1.1G 9.1M 381M 1.3G
Swap: 2.0G 0B 2.0G
硬盘信息:
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos_linus-root 50G 4.4G 46G 9% /
devtmpfs 897M 0 897M 0% /dev
tmpfs 912M 0 912M 0% /dev/shm
tmpfs 912M 9.1M 903M 1% /run
tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 1014M 179M 836M 18% /boot
/dev/mapper/centos_linus-home 47G 33M 47G 1% /home
tmpfs 183M 12K 183M 1% /run/user/42
tmpfs 183M 0 183M 0% /run/user/0
系统运行时间: 00:00:39 up 19 min, 2 users, load average: 0.00, 0.02, 0.08
最近十个登录用户:
root pts/0 192.168.1.11 Wed Feb 19 23:45 still logged in
root tty2 Wed Feb 19 23:42 still logged in
reboot system boot 3.10.0-693.el7.x Wed Feb 19 23:41 - 00:00 (00:19)
root pts/0 192.168.1.11 Mon Feb 10 14:49 - 14:28 (23:38)
root pts/5 Mon Feb 10 04:41 - 04:41 (00:00)
root pts/5 Mon Feb 10 04:40 - 04:40 (00:00)
root pts/5 Mon Feb 10 04:38 - 04:38 (00:00)
root pts/5 Mon Feb 10 04:36 - 04:36 (00:00)
root pts/4 Mon Feb 10 04:34 - crash (9+19:06)
root pts/4 Mon Feb 10 04:34 - 04:34 (00:00)
wtmp begins Thu Dec 5 22:58:01 2019
防火墙状态:inactive
selinux启动状态:SELINUX=enforcing
-------------------