TA的每日心情 | 擦汗 2014-10-31 10:02 |
---|
签到天数: 4 天 连续签到: 2 天 [LV.2]测试排长
|
- #!/bin/sh
- #system_monitor
- day=`date +%m%d%Y`
- file=${0%/*}/sysinfo$day
- if [ -f $file ]; then
- echo "ok">/dev/null
- else
- echo " date cpu mem load average io sessions inodes">>$file
- echo " user system idle free 1 5 15 read write">>$file
- echo "">>$file
- fi
- time=`date '+%m%d %H:%M:%S '`
- inodes=`df -i |grep app |awk '{print $5}'`
- io=`iostat -k |head -7 |grep sda |awk '{print $3"|"$4}'`
- iowait=`iostat -k |head -4 |tail -1|awk '{print $4}'`
- load=`uptime |grep load|sed s/\,//g|awk '{printf"%10s %6s %6s", $(NF-2),$(NF-1),$NF}'`
- cpu=`vmstat 1 2 | sed -n '$p' |awk '{printf "%8s %6s %9s", $13,$14,$15}'`
- real=`vmstat |grep -v [cpu][swap]|awk '{printf "%12s",$4}'`
- httpd_number=`ps -ef|grep httpd|grep -v grep|wc -l|awk '{printf "%9d",$1}'`
- app_number=`ps -ef |grep "java"|grep -v grep | wc -l`
- oracle_number=`ps -ef|grep "LOCAL=NO"|grep -v grep|wc -l|awk '{printf "%9d",$1}'`
- echo "$time $cpu$real$load $io|$iowait$httpd_number+$app_number+$oracle_number|$inodes" >>$file
复制代码
请大家帮忙看看这段SH脚本代码,为什么运行时候会提示不是目录的问题呢,谢谢了!如图
|
|