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

    Does anyone know how to get count of logged users in Captive Portal ?

    Scheduled Pinned Locked Moved Captive Portal
    3 Posts 2 Posters 427 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
      msalavee
      last edited by

      Does anyone know how to get count of logged users in Captive portal with zabbix or CLI?

      Att,

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

        @msalavee

        A while back I wrote this.

        Later on : same thing but somewhat 'better' :

        /root/captiveportal_count_online_users.php

        #!/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 */
        						$count_cpusers += count(captiveportal_read_db());
        					}
        		echo "users.value ".$count_cpusers."\n";
        
        ?>
        

        Test :

        [24.03-RELEASE][root@pfSense.bhf.tld]/root: php -q /root/captiveportal_count_online_users.php
        users.value 11
        

        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 0
        • M
          msalavee @Gertjan
          last edited by

          @Gertjan said in Does anyone know how to get count of logged users in Captive Portal ?:

          php -q /root/captiveportal_count_online_users.php

          PERFECT!

          Tks,

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