- 论坛徽章:
- 0
|
主要是对MIB不熟悉脚本不过才几十行
大家帮忙看看 改进改进
- #!/bin/bash
- ######################################
- #
- #Create By dennis_cao
- #Mail: [email]dennis__cao@hotmail.com[/email]
- #2008/05/28
- #Blog:[url]www.mlives.cn[/url]
- ######################################
- tput clear
- IPLIST=`cat /root/IP.txt`
- for IP in $IPLIST
- do
- SDISK=(`snmpdf -v 1 -c public $IP|grep -i label |awk '{print $1,$9}'`)
- CSPACE=`echo -n ${SDISK[1]}|awk '{print $1}'`
- DSPACE=`echo -n ${SDISK[3]}|awk '{print $1}'`
- ALLMEM=`snmpwalk -v 1 -c public $IP hrMemorySize|awk '{print $4}'`
- USEDMEM=`snmpwalk -v 1 -c public $IP hrSWRunPerfMEM|awk '{(total+=$4)};END{print total}'`
- ALLCPU=`snmpwalk -v 1 -c public$IP hrSWRunPerfCPU|awk '{(total+=$4)};END{print total}'`
- FREECPU=`snmpwalk -v 1 -c public$IP hrSWRunPerfCPU.1|awk '{(total+=$4)};END{print total}'`
- ALLPROCESS=`snmpwalk -v 1 -c public $IP hrSystemProcesses|awk '{print $4}'`
- ALLUSER=`snmpwalk -v 1 -c public $IP hrSystemNumUsers|awk '{print $4}'`
- PORT=`snmpwalk -v 1 -c public$IP tcp|grep TCP-MIB::tcpConnLocalPort|awk '{print $4}'|grep '\<21\>'`
- IN=`snmpwalk -v 1 -c public $IP ifInOctets|sed -n '2p'|awk '{print $4}'`
- OUT=`snmpwalk -v 1 -c public $IP ifOutOctets|sed -n '2p'|awk '{print $4}'`
- ((ALL=$IN+$OUT))
- sleep 20s
- IN1=`snmpwalk -v 1 -c snail $IP ifInOctets|sed -n '2p'|awk '{print $4}'`
- OUT1=`snmpwalk -v 1 -c snail $IP ifOutOctets|sed -n '2p'|awk '{print $4}'`
- ((ALL1=$IN1+$OUT1))
- PNET=`bc <<EOF
- scale=1
- ($ALL1-$ALL)*8/1024/1024/20`
- MP=`bc <<EOF
- scale=2
- $USEDMEM/$ALLMEM*100
- EOF`
- MPRECENT=`echo $MP|awk -F. '{print $1}'`
- CFREE=`bc <<EOF
- scale=2
- $FREECPU/$ALLCPU*100
- EOF`
- CFPRECENT=`echo $CFREE|awk -F. '{print $1}'`
- echo '#####################################################'
- echo
- echo " $IP "
- echo
- echo '####################################################'
- echo -en "The Used Space Of $IP C:\ is ${SDISK[1]} \n"
- echo -en "The Used SPace Of $IP D:\ is ${SDISK[3]} \n"
- echo -en "The Process Of $IP is $ALLPROCESS \n"
- echo -en "The User Numbers Of $IP is $ALLUSER \n"
- echo -en "The Port 21 Of $IP Is $PORT \n"
- echo -en "The Used Memory Of $IP is $MPRECENT% \n"
- echo -en "The Free Cpu of $IP is $CFPRECENT%\n"
- echo -en "The NIC 20s Average Values Is $PNET Mbps \n"
复制代码 |
|