{noformat}
. /usr/local/ics/bin/ics_lib.sh
#radius пример
selfkiller -30:TERM -50:KILL & disown -a
lib_init || exit 1
SECONDS=""
LOGFILE="/var/log/event.sh.log"
LOG_LEVEL=ALL
exec 3>>$LOGFILE 4>/dev/null
exec 2>&3
exec 1>&3
if ! selflock 10; then
LOG WARN "reached time limit $$"
exit
fi
if [ $SECONDS -ge 9 ]; then
exit;
fi
SENDER=$1; shift
EVENT=$1; shift
DATA=$@
for VAR in $DATA; do
[[ "$VAR" = *"="* ]] && eval ${VAR%%=*}=\'${VAR#*=}\'
done
LOG INFO "$SENDER $EVENT $DATA"
case "$EVENT" in
"balance_negative")
if [ "$nas_ip" != "0.0.0.0" ]; then
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair=\"subscriber:command=account-logoff\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
"balance_positive")
true
;;
"login")
true
;;
"logout")
if [ "$nas_ip" != "0.0.0.0" ]; then
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair=\"subscriber:command=account-logoff\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
"try_double_login")
if [ "$nas_ip" != "0.0.0.0" ]; then
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair=\"subscriber:command=account-logoff\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
"user_data_changed_before")
if [ "$nas_ip" != "0.0.0.0" ]; then
usleep 200
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair=\"subscriber:command=account-logoff\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
"period_closed")
true
;;
"user_data_changed")
true
;;
"rate_set")
if [ "$nas_ip" != "0.0.0.0" -a "$ceil_in" != "-1" -a "$ceil_out" != "-1" ]; then
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair+=\"ip:sub-qos-policy-in=policy_in${ceil_in}kb\",Cisco-AVPair+=\"ip:sub-qos-policy-out=policy_out${ceil_out}kb\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
*)
:
;;
esac
{noformat}
. /usr/local/ics/bin/ics_lib.sh
#radius пример
selfkiller -30:TERM -50:KILL & disown -a
lib_init || exit 1
SECONDS=""
LOGFILE="/var/log/event.sh.log"
LOG_LEVEL=ALL
exec 3>>$LOGFILE 4>/dev/null
exec 2>&3
exec 1>&3
if ! selflock 10; then
LOG WARN "reached time limit $$"
exit
fi
if [ $SECONDS -ge 9 ]; then
exit;
fi
SENDER=$1; shift
EVENT=$1; shift
DATA=$@
for VAR in $DATA; do
[[ "$VAR" = *"="* ]] && eval ${VAR%%=*}=\'${VAR#*=}\'
done
LOG INFO "$SENDER $EVENT $DATA"
case "$EVENT" in
"balance_negative")
if [ "$nas_ip" != "0.0.0.0" ]; then
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair=\"subscriber:command=account-logoff\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
"balance_positive")
true
;;
"login")
true
;;
"logout")
if [ "$nas_ip" != "0.0.0.0" ]; then
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair=\"subscriber:command=account-logoff\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
"try_double_login")
if [ "$nas_ip" != "0.0.0.0" ]; then
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair=\"subscriber:command=account-logoff\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
"user_data_changed_before")
if [ "$nas_ip" != "0.0.0.0" ]; then
usleep 200
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair=\"subscriber:command=account-logoff\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
"period_closed")
true
;;
"user_data_changed")
true
;;
"rate_set")
if [ "$nas_ip" != "0.0.0.0" -a "$ceil_in" != "-1" -a "$ceil_out" != "-1" ]; then
echo "User-Name=\"$login\",Cisco-Account-Info=\"S$ip\",Cisco-AVPair+=\"ip:sub-qos-policy-in=policy_in${ceil_in}kb\",Cisco-AVPair+=\"ip:sub-qos-policy-out=policy_out${ceil_out}kb\"" | radclient -x $nas_ip:1700 coa 322223
fi
true
;;
*)
:
;;
esac
{noformat}