12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #!/bin/sh
- case "$1" in
- mkrcdir)
- mkdir -p /var/spool/asterisk/monitor/${2}
- mkdir -p /var/spool/asterisk/monitor/${2}/${3}
- ;;
- sysinfo)
- #waninfo=`/usr/bin/ifconfig eth0`
- wanip=`/usr/bin/ifconfig eth0 | grep 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
- wanmac=`/usr/bin/ifconfig eth0 | grep 'HWaddr' | awk '{print $5}'|tr '[a-f]' '[A-Z]'`
- #laninfo=`/usr/bin/ifconfig eth1`
- lanip=`/usr/bin/ifconfig eth1 | grep 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
- lanmac=`/usr/bin/ifconfig eth1 | grep 'HWaddr' | awk '{print $5}'|tr '[a-f]' '[A-Z]'`
- uptime=`uptime`
- if [ -z "`echo $uptime | grep 'day'`" ];then
- uptime=`echo $uptime | cut -d, -f1|awk '{print $3,$4}'`
- else
- uptime=`echo $uptime | cut -d, -f1,2|awk '{print $3,$4,$5,$6}'`
- fi
- echo "{\"wanip\":\"$wanip\", \"wanmac\":\"$wanmac\",\"lanip\":\"$lanip\",\"lanmac\":\"$lanmac\",\"uptime\":\"$uptime\"}"
- ;;
- handleinfo)
- ###CPUinfo
- CPULOG_1=$(awk '/cpu /{print $2" "$3" "$4" "$5" "$6" "$7" "$8}' /proc/stat)
- SYS_IDLE_1=$(echo $CPULOG_1 | awk '{print $4}')
- Total_1=$(echo $CPULOG_1 | awk '{print $1+$2+$3+$4+$5+$6+$7}')
- sleep 3
- CPULOG_2=$(awk '/cpu /{print $2" "$3" "$4" "$5" "$6" "$7" "$8}' /proc/stat)
- SYS_IDLE_2=$(echo $CPULOG_2 | awk '{print $4}')
- Total_2=$(echo $CPULOG_2 | awk '{print $1+$2+$3+$4+$5+$6+$7}')
- SYS_IDLE=`expr $SYS_IDLE_2 - $SYS_IDLE_1`
- Total=`expr $Total_2 - $Total_1`
- Used=`expr $Total - $SYS_IDLE`
- ###MEMinfo
- memtotal=`cat /proc/meminfo|grep MemTotal|awk '{print $2}'`
- memfree=`cat /proc/meminfo|grep MemAvailable|awk '{print $2}'`
- memused=`expr $memtotal - $memfree`
- ###system time
- currenttime=`date "+%s"`
- echo "{\"cputotal\":\"$Total\", \"cpuused\":\"$Used\",\"memtotal\":\"$memtotal\",\"memused\":\"$memused\",\"currenttime\":\"$currenttime\"}"
- ;;
- esac
|