码迷,mamicode.com
首页 > 其他好文 > 详细

pptp记录日志

时间:2016-02-17 19:01:00      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

/etc/ppp/ip-up

#!/bin/bash
# This file should not be modified -- make local changes to
# /etc/ppp/ip-up.local instead

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
log=/var/log/tmp.log

echo "##################################" >> $log
echo "Now User $PEERNAME is connected!!!" >> $log
echo "##################################" >> $log
echo "time: `date -d today +%F_%T`" >> $log
echo "clientIP: $6" >> $log
echo "username: $PEERNAME" >> $log
echo "device: $1" >> $log
echo "vpnIP: $4" >> $log
echo "assignIP: $5" >> $log

LOGDEVICE=$6
REALDEVICE=$1

[ -f /etc/sysconfig/network-scripts/ifcfg-${LOGDEVICE} ] && /etc/sysconfig/network-scripts/ifup-post --realdevice ${REALDEVICE} ifcfg-${LOGDEVICE}

/etc/ppp/ip-up.ipv6to4 ${LOGDEVICE}

[ -x /etc/ppp/ip-up.local ] && /etc/ppp/ip-up.local "$@"

exit 0

 

/etc/ppp/ip-down

#!/bin/bash
# This file should not be modified -- make local changes to
# /etc/ppp/ip-down.local instead

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
log=/var/log/tmp.log

echo "#####################################" >> $log
echo "Now User $PEERNAME is disconnected!!!" >> $log
echo "#####################################" >> $log
echo "time: `date -d today +%F_%T`" >> $log
echo "clientIP: $6" >> $log
echo "username: $PEERNAME" >> $log
echo "device: $1" >> $log
echo "vpnIP: $4" >> $log
echo "assignIP: $5" >> $log
echo "connect time: $CONNECT_TIME s" >> $log
echo "bytes sent: $BYTES_SENT B" >> $log
echo "bytes rcvd: $BYTES_RCVD B" >> $log
sum_bytes=$(($BYTES_SENT+$BYTES_RCVD))
sum=`echo "scale=2;$sum_bytes/1024/1024"|bc`
echo "bytes sum: $sum MB" >> $log
ave=`echo "scale=2;$sum_bytes/1024/$CONNECT_TIME"|bc`
echo "average speed: $ave KB/s" >> $log

LOGDEVICE=$6
REALDEVICE=$1

/etc/ppp/ip-down.ipv6to4 ${LOGDEVICE}

[ -x /etc/ppp/ip-down.local ] && /etc/ppp/ip-down.local "$@"

/etc/sysconfig/network-scripts/ifdown-post --realdevice ${REALDEVICE}     ifcfg-${LOGDEVICE}

exit 0

 

pptp记录日志

标签:

原文地址:http://www.cnblogs.com/cmsd/p/5196204.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!