Captive portal + Free Radius, Corrupted tracking files after power failure
-
Hello,
I'm using captive portal + Free Radius to control monthly quota.
I'm using pfSense version 2.4.5-RELEASE-p1 (amd64)When I have power failure, I found that all files that track usage are empty (file size is 0.00 Kib)
These file are in "/var/log/radacct/datacounter/monthly"Every time I have power failure, I have to go to system log and get the last reported usage for each captive portal user, and write the used traffic manually to the corresponding file for each user.
Is there any solution for this problem?
Thanks in advance
-
@malhabibi said in Captive portal + Free Radius, Corrupted tracking files after power failure:
Hello,
I'm using captive portal + Free Radius to control monthly quota.
I'm using pfSense version 2.4.5-RELEASE-p1 (amd64)Is there any solution for this problem?
Sounds to me like you need a UPS (universal power supply) on your pfSense system so that it will shutdown in an orderly manner during these power glitches/outages.
-
@jdeloach Thanks for reply.
Sure, UPS is the ideal solution. but I'm looking for free/cheap solution (for example: applying a patch).
I wonder what is the root cause of having the tracking files to be cleared, It seems that the files are deleted and recreated in an incorrect way every time the system restart after a power failure. -
Can anyone point me out to the file name and location that containing the code for manipulating data counter files?
-
Look here /usr/local/etc/raddb/scripts
These files get called by FreeRadius from here /usr/local/etc/raddb/sites-enabled/default - see the accounting :: datacounterdaily datacounterweekly etc.See also /usr/local/etc/raddb/mods-enabled/datacounter_acct.
To be sure that you do not suffer from file system issues : see one of the latest Netgate Videos (Youtube).
A cron task resets the files in /var/log/radacct/datacounter/...
-
@Gertjan said in Captive portal + Free Radius, Corrupted tracking files after power failure:
@Gertjan Thanks for reply
Look here /usr/local/etc/raddb/scripts
I made a change to "/usr/local/etc/raddb/scripts/datacounter_acct.sh" as follow:
and it works fine
I simulate file corruption by empty counter files (making file size = zero), it's then restored from backup-$USERNAME.log file -
If it works for you, it's all
to me.
I advise you to install the Cron pfSense package.
You'll be seeing all the cron tasks - the things that are started using a pre programmed time condition.
You will find these :These 3 tasks run at the start of the day, the week, and month to reset the used-octets.
Not really "reset", the files used-octets-* are simply deleted.
And as you can see in the scripts (above) : they get recreated on the fly.If your files used-octets-* do not get emptied - but actually get filled with "0" it might be this line :
echo 0 > "/var/log/radacct/datacounter/$TIMERANGE/used-octets-$USERNAME"
Add a echo "used-octets-$USERNAME was emptied" line to see if this line gets executed. Check the logs to see the log line.
-
If your files used-octets-* do not get emptied - but actually get filled with "0" it might be this line :
echo 0 > "/var/log/radacct/datacounter/$TIMERANGE/used-octets-$USERNAME"
Add a echo "used-octets-$USERNAME was emptied" line to see if this line gets executed. Check the logs to see the log line.
used-octets-* are empty, it's not filled with "0"
Unfortunately, with the 1st power failure, I got both used-octets-* and backup-*.log empty (all files size is zero)
I wish I could catch the root cause.