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

    DHCP lease count

    Scheduled Pinned Locked Moved DHCP and DNS
    7 Posts 2 Posters 4.4k 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.
    • I
      it_support
      last edited by

      how can i show the count of online dhcp lease like below?

      ![DHCP Lease.JPG](/public/imported_attachments/1/DHCP Lease.JPG)
      ![DHCP Lease.JPG_thumb](/public/imported_attachments/1/DHCP Lease.JPG_thumb)

      1 Reply Last reply Reply Quote 0
      • B
        bryan.paradis
        last edited by

        You want graphical row numbers or do you want an online/active dhcp total?

        For total leases in file

        cat /var/dhcpd/var/db/dhcpd.leases | grep -c lease
        
        1 Reply Last reply Reply Quote 0
        • I
          it_support
          last edited by

          I want online/active dhcp total?

          1 Reply Last reply Reply Quote 0
          • B
            bryan.paradis
            last edited by

            @it_support:

            I want online/active dhcp total?

            
            cat /var/dhcpd/var/db/dhcpd.leases | grep -c "binding state active;"
            
            

            online gets a bit tougher because it checks arpdata.

            1 Reply Last reply Reply Quote 0
            • B
              bryan.paradis
              last edited by

              If you are on 2.1 backup your status_dhcp_leases.php and put the attached version in its place. Or if you are on a different version you can try placing this code chunk in after the parsing switch statement.

              
              $countactive = 0;
              $countonline = 0;
              
              foreach ($leases as $item) {
                if ($item['act'] === 'active') {
                  $countactive++;
                }
                if ($item['online'] === 'online') {
                  $countonline++;
                }
              }
              echo "Active: " . $countactive . "
              ";
              echo "Online: " . $countonline;
              
              

              ![2014-02-26 14_04_26-pfsense.localdomain - Status_ DHCP leases.png](/public/imported_attachments/1/2014-02-26 14_04_26-pfsense.localdomain - Status_ DHCP leases.png)
              ![2014-02-26 14_04_26-pfsense.localdomain - Status_ DHCP leases.png_thumb](/public/imported_attachments/1/2014-02-26 14_04_26-pfsense.localdomain - Status_ DHCP leases.png_thumb)
              status_dhcp_leases.php.txt

              1 Reply Last reply Reply Quote 0
              • I
                it_support
                last edited by

                where the dhcp lease file located? i mean status_dhcp_leases.php file

                1 Reply Last reply Reply Quote 0
                • B
                  bryan.paradis
                  last edited by

                  @it_support:

                  where the dhcp lease file located? i mean status_dhcp_leases.php file

                  /usr/local/www/
                  

                  if you need to find things on command line you can use find

                  find / -name filename
                  

                  if you need wildcards use

                  find / -name \*filename\*
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.