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

    Captive Portal Last Activity

    Captive Portal
    2
    18
    1.5k
    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.
    • ahmetakkayaA
      ahmetakkaya
      last edited by

      Ekran Resmi 2021-07-31 13.16.08.png

      Captive Portal Last activity I want to use accounting.
      Does pfsense share this data?

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

        @ahmetakkaya said in Captive Portal Last Activity:

        Does pfsense share this data?

        It doesn't store that kind of data.
        But it does exist, ina somewhat raw form :

        Read this Troubleshooting Captive Portal, use the ipfw commands and you'll see the 'bytes passed'.

        Using the FreeRadius package combined with the portal gives you more control about connection duration, bandwidth allowed and quantity of data allowed..

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

        ahmetakkayaA 1 Reply Last reply Reply Quote 0
        • ahmetakkayaA
          ahmetakkaya @Gertjan
          last edited by

          @gertjan

          Hello there
          I can access usage information (kb,mb)
          I can't find the check-in and check-out times either.
          but I need instant session (Last Activity) time?

          GertjanG ahmetakkayaA 2 Replies Last reply Reply Quote 0
          • GertjanG
            Gertjan @ahmetakkaya
            last edited by

            @ahmetakkaya said in Captive Portal Last Activity:

            I can access usage information (kb,mb)

            What is kb.mb ?

            @ahmetakkaya said in Captive Portal Last Activity:

            I can't find the check-in and check-out times either.

            It's not hidden : Status > System Logs > Authentication > General

            @ahmetakkaya said in Captive Portal Last Activity:

            but I need instant session (Last Activity) time?

            Look here :
            e33a619e-f60a-4800-9b42-9e2a41fee8c1-image.png

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

            1 Reply Last reply Reply Quote 0
            • ahmetakkayaA
              ahmetakkaya @ahmetakkaya
              last edited by

              @ahmetakkaya

              last activity I want to use the information in an accounting controller

              Does pfsense share this information?

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

                @ahmetakkaya said in Captive Portal Last Activity:

                Does pfsense share this information?

                The log file is a classic 'ASCII' readable text file. It can be parsed out to get the info.
                Or, instead of using the build in pfSense User manger, use the FreeRadius package for identification and accounting. If you choose to to use FreeRadius + a SQL back-end, you have all the info in a 'radacct' SQL table.

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

                1 Reply Last reply Reply Quote 0
                • ahmetakkayaA
                  ahmetakkaya
                  last edited by ahmetakkaya

                  I could not reach the last activation information on the sql side in the data received from Accounting

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

                    @gertjan said in Captive Portal Last Activity:

                    It doesn't store that kind of data.

                    Correction : it actually does.

                    Sample PHP script that show the connected users and their last activity moment :

                    #!/usr/local/bin/php -q
                    <?php
                    	require_once("/etc/inc/util.inc");
                    	require_once("/etc/inc/functions.inc");
                    	require_once("/etc/inc/captiveportal.inc");
                    
                    	/* Read in captive portal db */
                    	/* Determine number of logged in users for all zones */
                    
                    	$count_cpusers = 0;
                    	/* Is portal activated ? */
                    	if (is_array($config['captiveportal']))
                    		/* For every zone, do */
                    		foreach ($config['captiveportal'] as $cpkey => $cp)
                    			/* Sanity check */
                    			if (is_array($config['captiveportal'][$cpkey])) 
                    				/* Is zone enabled ? */
                    				if (array_key_exists('enable', $config['captiveportal'][$cpkey])) {
                    					
                    					$cpzone = $cpkey;
                    					/* Zone selected -> count users and add */
                    					$connected_users = captiveportal_read_db();
                    					if (!empty($connected_users)) {
                    						foreach ($connected_users as $user) {
                    						// print_r($user);
                    						echo $user[4]." ";
                    						$last_act = captiveportal_get_last_activity($user[2]);
                    						echo htmlspecialchars(date("m/d/Y H:i:s\n", $last_act));
                    						}
                    					}
                    				}
                    
                    ?>
                    

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

                    ahmetakkayaA 1 Reply Last reply Reply Quote 0
                    • ahmetakkayaA
                      ahmetakkaya @Gertjan
                      last edited by

                      @gertjan said in Captive Portal Last Activity:

                      PHP script

                      The PHP script you shared is on the pfsense side

                      needed me by freeradius

                      Does pfsense share the latest activitiy information on freeradius?

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

                        @ahmetakkaya said in Captive Portal Last Activity:

                        The PHP script you shared is on the pfsense side

                        For an activate clients, In the radacct table a record with all the info about this connected client :

                        bc72e24e-e682-49bd-a129-1f9a544fd27d-image.png

                        My accounting updates this record every 600 (605) seconds.

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

                        ahmetakkayaA 1 Reply Last reply Reply Quote 0
                        • ahmetakkayaA
                          ahmetakkaya @Gertjan
                          last edited by

                          @gertjan

                          Ekran Alıntısı.JPG

                          this is my radacct table

                          There is user login time in the marked field
                          The variable at the bottom always shows the current time.
                          I couldn't find the activity information in the table?

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

                            @ahmetakkaya

                            I meant the "acctinputocters" and "acctoutpitoctests". The are updated every "accounting update", nomally 5 minutes.

                            This info is collected by pfSense, by reading these byte counters, using an ipfw command, then then handed over to FreeRadius.
                            Freeradius needs this info if you want to quota limit users.

                            Something like real time graphing: not that I know of.

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

                            1 Reply Last reply Reply Quote 0
                            • ahmetakkayaA
                              ahmetakkaya
                              last edited by

                              freeradius unfortunately does not send last activity information to remote sql accounting server ..

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

                                @ahmetakkaya said in Captive Portal Last Activity:

                                does not send last activity information

                                The record that I showed above will get updated every 600 seconds, of whatever time span you chose. When the connection gets closed, the record will have a STOP time set and the record will not get updated any more.

                                What do you mean by "activity information" ?

                                You want to know what the connected user does ? What they visits ?
                                A "Captive portal" is more about granting access to the net, and also "how long" and "how many bytes". Not what they are actually doing.
                                If you want to know what a user does, what he's looking at, you have become a MITM-man.

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

                                ahmetakkayaA 1 Reply Last reply Reply Quote 0
                                • ahmetakkayaA
                                  ahmetakkaya @Gertjan
                                  last edited by

                                  @gertjan

                                  I found the last activity information in the captive portal status menu on the pfsense webgui screen.

                                  I want to see it on the remote accounting portal page that I have created.

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

                                    @ahmetakkaya said in Captive Portal Last Activity:

                                    I want to see it on the remote accounting portal page that I have created.

                                    Then use the script I showed above ?
                                    The same info is synced to Freeradius, every time a 'accounting' is updated, but this which happens every 5 minutes or so :

                                    ae5fc22c-94d3-45cc-8a2f-79e09b8a3990-image.png

                                    So, it would be every minute ?! the SQL database is updated.

                                    The function "captiveportal_get_last_activity()" in the script questions the ipfw pipes info directly, it gets the time stamp of the latest packet-event. Identical to what pfSense does when it shows the last activity.

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

                                    ahmetakkayaA 1 Reply Last reply Reply Quote 0
                                    • ahmetakkayaA
                                      ahmetakkaya @Gertjan
                                      last edited by

                                      @gertjan

                                      I already have my settings as in the picture

                                      How can I query the last activity information on the accounting side or on the sql side?

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

                                        @ahmetakkaya said in Captive Portal Last Activity:

                                        @gertjan

                                        I already have my settings as in the picture

                                        How can I query the last activity information on the accounting side or on the sql side?

                                        I doubt the If the result of "captiveportal_get_last_activity()" is actually stored in the SQL database.
                                        The 'acctupdatetime' (updated every 'actinterval' = env 600 seconds) together with acctinputoctets and acctoutputoctets could used to see if there was any activity during the last 'actinterval' seconds.

                                        The radpostauth table contains an every minute a recheck of the login (if you enabled that feature).

                                        A real time updating of the results of the "ipfw" can't be transmitted to Freeradius. Run radius -X for your self to see what is send between the pfSense captive portal and Freeradius.

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

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