下面的脚本可以一次性获取嵌入式Linux系统上有用的系统信息,包括网络信息,存储信息,环境信息等等。 它一同支撑周期性工作,可以用于系统监测,比如检查内存泄露等。 注:由于我用的busybox中的top不支撑-n 选项,因此使用了后台工作,一定时辰后再杀死top进程的办法。 top 指令如果支撑-n 选项就非常简略了。 使用办法: $ sysinfo.sh -h usage: sysinfo.sh http://www.aaafaipiao.com/linked/20130315.do [options] show system information. Without option, it will show all information. options: -c : show how many times. -d: show disk information. -e: show environment. -g: show general information. -i : show information every seconds. -m: show memory information. -n: show network information. -p: show process information. -r: show release information. -h: show help #!/bin/sh trap my_exit SIGINT #---------------------------- variables -------------------------------------------------- PROG_NAME=`basename $0` SHOW_GENERAL=0 SHOW_DISK=0 SHOW_ENV=0 SHOW_MEM=0 SHOW_NET=0 SHOW_PROC=0 INTERVAL=-1 ALWAYS_LOOP=0 COUNT=-1 INDEX=1 NOT_SHOW_ALL=0 #---------------------------- functions -------------------------------------------------- my_exit() { killall top 2>/dev/null exit 0 } run_cmd() { echo $ $* eval $* echo } usage() { cat << END usage: $PROG_NAME [options] show system information. Without option, it will show all information. options: -c : show how many times. -d: show disk information. -e: show environment. -g: show general information. -i : show information every seconds. -m: show memory information. -n: show network information. -p: show process information. -h: show help END } set_show_all() { SHOW_GENERAL=1 SHOW_DISK=1 SHOW_ENV=1 SHOW_MEM=1 SHOW_NET=1 SHOW_PROC=1 } show_general() { echo " General " run_cmd cat /proc/version run_cmd cat /proc/uptime run_cmd cat /proc/cmdline run_cmd hostname run_cmd cat /proc/modules } show_disk() { echo " Disk " run_cmd cat /proc/mounts run_cmd cat /proc/mtd run_cmd df } show_env() { echo " Env " run_cmd env } show_mem() { echo " MEM " run_cmd cat /proc/vmstat run_cmd cat /proc/meminfo run_cmd top http://www.fp1111.info/linked/20130315.do
转载于:https://www.cnblogs.com/fpqqchao/archive/2013/03/16/2962450.html