Ubuntu下获取系统信息shell脚本
2018-01-04 20:05
316 查看
#!/bin/bash # 获取系统信息 # 获取cpu数量 get_cpu_num(){ grep "cpu cores" /proc/cpuinfo | head -n1 | awk '{ print $NF }' } # 获取总内存 get_memory_total(){ free -h | awk 'NR==2{ print $2 }' } # 获取可用内存 get_memory_free(){ free -m | awk 'NR==2{ print $NF }' } # 获取挂载到根目录的文件系统的总大小 get_disk_size(){ df -h | grep -E "^.*/$" | awk '{ print $2 }' } # 获取系统位数 get_system_bit(){ getconf LONG_BIT } # 获取当前系统正在运行的进程数 get_process(){ ps aux | tail -n +2 | wc -l } # 获取已安装的软件包数量 get_software_num(){ dpkg -l | tail -n +6 | wc -l } # 获取ip get_ip(){ ip a s | grep -w "inet" | awk 'NR==2{ print $2 }' | awk -F/ '{ print $1 }' } echo "cpu num: $(get_cpu_num)" echo "memory total: $(get_memory_total)" echo "memory free: $(get_memory_free)M" echo "disk size: $(get_disk_size)" echo "system bit: $(get_system_bit)" echo "process: $(get_process)" echo "software num: $(get_software_num)" echo "ip: $(get_ip)"
相关文章推荐
- 获取系统信息#Shell脚本
- 获取服务器信息shell脚本:内存大小,cpu型号,系统发行版本,硬盘个数及大小等
- shell脚本获取系统相关信息
- Openwrt系统中shell脚本获取配置文件信息解读
- 获取服务器信息的Shell脚本分享(ubuntu、centos测试通过)
- 获取服务器信息shell脚本:内存大小,cpu型号,系统发行版本,硬盘个数及大小等
- 获取服务器信息的Shell脚本分享(ubuntu、centos测试通过)
- 获取服务器信息shell脚本:内存大小,cpu型号,系统发行版本,硬盘个数及大小等
- shell脚本之获取终端信息
- 利用Python脚本获取Windows和Linux的系统版本信息 推荐
- shell查看系统基本信息脚本
- shell脚本循环调用top来获取进程的资源信息
- linux系统使用python获取内存使用信息脚本分享
- IBM AIX系统硬件信息查看命令(shell脚本)
- shell脚本之获取终端信息
- 获取系统信息脚本
- shell之获取系统信息
- ASP脚本获取客户端系统信息
- Ubuntu系统编写shell脚本程序一次安装多个软件包
- 使用shell脚本获取系统运行状态