DHCP lease count



  • 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)



  • 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
    


  • I want online/active dhcp total?



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



  • 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



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



  • @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\*