PPP user real ip logging

Hello, Mikrotik Users.

I want to log the VPN USER’s(PPTP, L2TP) real ip address.

This is my logging script. But I have some problem.


/system script add name=pppactivelist source= {
:local userid;
: local i;
: local realip;
: local vpnip;
: local uptime;
: local crttime;
: local crtdate;
: local logmsg;

:foreach i in=[/ppp active find] do={
:set userid [/ppp active get $i];
:set realip [/ppp active get $i caller-id];
:set vpnip [/ppp active get $i address];
:set uptime [/system active get $i uptime];
:set crtdate [/system clock get date];
:set crttime [/system clock get time];

:set longmsg “TIME: $crtdate $crttime, USER_ID: $userid, REAL-IP: $realip, VPN-IP: $vpnip, UP-TIME: $uptime”;

:log info (" $logmsg ");
}

}


/system scheduler
add disabled=no interval=1m name=pppactivelist on-event=pppactivelist start-time=startup



The Problem is that duplicated lines in log info exist.

I want to make a script schedule 3 minutes to record only new pptp user’s connection informations in remote log server.

Could you help me how to make a script?

I means that every new pptp user’s connection information should be logged in my remote log server.

Thank you for your reading.

/system logging
add action=memory disabled=no topics=pppoe,account

thank you for your reply. but, Our customers use PPTP, LPTP VPN service, not PPPoE service.

try ‘ppp’ or ‘pptp’ topic instead

try this script


{
:local userid;
: local i;
: local realip;
: local vpnip;
: local uptime;
: local crttime;
: local crtdate;
: local logmsg;
:local userid
:global tmp1

:foreach i in=[/ppp active find] do={
:set userid [/ppp active get $i name];
:set realip [/ppp active get $i caller-id];
:set vpnip [/ppp active get $i address];
:set uptime [/ppp active get $i uptime];
:set crtdate [/system clock get date];
:set crttime [/system clock get time];

:set logmsg “TIME: $crtdate $crttime, USER_ID: $userid; REAL-IP: $realip, VPN-IP: $vpnip, UP-TIME: $uptime”;
if ($tmp1!=$realip) do={:log info (" $logmsg ")};
:set tmp1 [/ppp active get $i caller-id];
}
}