Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Captive portal + Free Radius, Corrupted tracking files after power failure

    Scheduled Pinned Locked Moved Captive Portal
    8 Posts 3 Posters 821 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      malhabibi
      last edited by

      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

      J 1 Reply Last reply Reply Quote 0
      • J
        jdeloach @malhabibi
        last edited by

        @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.

        M 1 Reply Last reply Reply Quote 1
        • M
          malhabibi @jdeloach
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • M
            malhabibi
            last edited by

            Can anyone point me out to the file name and location that containing the code for manipulating data counter files?

            1 Reply Last reply Reply Quote 0
            • GertjanG
              Gertjan
              last edited by

              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/...

              No "help me" PM's please. Use the forum, the community will thank you.
              Edit : and where are the logs ??

              M 1 Reply Last reply Reply Quote 1
              • M
                malhabibi @Gertjan
                last edited by

                @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:
                b4748510-2c6a-4d56-b545-cef58bf10fcf-image.png

                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

                1 Reply Last reply Reply Quote 0
                • GertjanG
                  Gertjan
                  last edited by

                  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 :

                  f6de3573-bf9a-4085-8ac0-2f82f5ec88f8-image.png

                  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.

                  No "help me" PM's please. Use the forum, the community will thank you.
                  Edit : and where are the logs ??

                  M 1 Reply Last reply Reply Quote 1
                  • M
                    malhabibi @Gertjan
                    last edited by

                    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.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.