查看系统运行状态脚本

绿色脚本

[root@haha ~]# cat tools.sh 
#!/bin/bash
menu(){
    
    
cat<<eof
+++++++系统管理工具箱++++++++
	h 显示命令帮助
	f 显示磁盘分区
	d 显示磁盘挂载
	m 查看内存使用
	u 产看系统负载
	q 退出程序
+++++++++++++++++++++++++++++
eof
}

fdisk(){
    
    
	df -hT
}

diskinfo(){
    
    
	df -hT | awk '/^\/dev/{
    
    print $1"\t\t"$3"\t\t\t"$4"\t\t\t"
$5}'}

memtop10(){
    
    
	ps -aux --sort -pmem | head -11 | awk '{
    
    print $1"\t"$2"\t
"$4"\t"$11}'}

cputop10(){
    
    
	ps -aux --sort -pcpu | head -11 | awk '{
    
    print $1"\t"$2"\t
"$3"\t"$11}'}

while true
do
	menu
	read -p "please input your choose:" OP
	case $OP in
		h)
			clear
			;;
		f)
			fdisk
			;;
		d)
			diskinfo
			;;
		m)
			memtop10
			;;
		u)
			cputop10
			;;
		q)
			exit
			;;
		*)
			echo "input error"
	esac
done

猜你喜欢

转载自blog.csdn.net/weixin_52441468/article/details/114480962