#!/bin/sh case "$1" in mkrcdir) mkdir -p /var/spool/asterisk/monitor/${2} mkdir -p /var/spool/asterisk/monitor/${2}/${3} ;; sysinfo) #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]'` #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]'` ftotal=`df -h|grep overlay|tr -s ' '|cut -d ' ' -f 2` fused=`df -h|grep overlay|tr -s ' '|cut -d ' ' -f 3` 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 "{\"ftotal\":\"$ftotal\", \"fused\":\"$fused\",\"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