OpenVPN
3
Вклад в тег
#!/bin/sh
export INDEXTXT=/etc/openvpn/easyrsa3/easyrsa3/pki/index.txt
export LOGFILE=/var/log/openvpn.log
echo -e "\nOpenVPN users last connection mac/ip list tool\n"
validusers=$(grep -E "V{символ табуляции}" $INDEXTXT|cut -d'=' -f2)
#echo Users last mac/ip addresses:
echo LastLogin Timestamp / User / mac / ip
for usr in ${validusers}
do
if [ $(grep -E "MULTI: Learn:" $LOGFILE|grep "$usr"|tail -1|wc -l) -gt 0 ]
then
echo $(grep -E "MULTI: Learn:" $LOGFILE|grep "$usr"|tail -1|cut -c 1-24) / $usr / $(grep -E "MULTI: Learn:" $LOGFILE|grep "$usr"|tail -1|cut -d':' -f6-11|cut -c 2-18) / $(grep -E "MULTI: Learn:" $LOGFILE|grep "$usr"|tail -1|cut -d'/' -f3|cut -d':' -f1)
fi
done