Web Interface: Show Disk Free Space by CPU usage


#1

For me, it would be handy to have a place to see disk free space. I just had an issue yesterday where PI Hole would not update and wasn’t showing the graphs only to find out the disk was full.

I realize that the area up top is crowded, so what I would do is get rid of the “Status” title (or make it smaller) and add the disk space below memory usage.

From this page:
http://php.net/manual/en/function.disk-free-space.php

Something like this:

$bytes = disk_free_space("/"); 
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
echo $bytes . '<br />';
echo sprintf('%1.2f' , $bytes / pow($base,$class)) . ' ' . $si_prefix[$class] . '<br />';

Thanks for a great product!


#2

Here is my take on it:

In the folder: /var/www/html/admin/scripts/pi-hole/php
edit the file: header.php

Delete line 306 (which is as follows):

Status

Insert the following lines after line 381 (right before the ):

                 <br/>
                 <?php
                    $bytes = disk_free_space("/");
                    $si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
                    $base = 1024;
                    $class = min((int)log($bytes , $base) , count($si_prefix) - 1);
                    //echo $bytes . '<br />';
                    echo "<a><i class=\"fa fa-circle\" style=\"color:";
                    if ($bytes < 10000000) { // I chose 10mb you could do larger... maybe 100mb?
                        echo "#FF0000";
                    }
                    else
                    {
                        echo "#7FFF00";
                    }
                    echo "\"></i>Disk Free: ";
                    echo sprintf('%1.2f' , $bytes / pow($base,$class)) . ' ' . $si_prefix[$class] . '</a>';
               ?>

#3

If you have some working code, this would be better served by opening a pull request on our repo.


#4

Good idea. Done and done. Thanks again for an awesome program!


#5

So we don’t in into guilding the code or adding features that will lead to what’s known as feature creep, can you give us a little bit about how knowing the current free space will help us create a better Pi-hole ad blocker?


#6

Sure. A few weeks ago I was looking at the status and the graphs were not updating, I rebooted the device thinking that maybe something was just hung. That didn’t help at all.

I tried various things through the UI but nothing helped. I logged onto the device and did some things there, I finally noticed that the file system was full. I cleared as much space as I could and rebooted. Everything worked fine after that

If the status had shown the disk usage I would have solved my problem a lot sooner.

I would say this information is just as important as Memory, CPU and Temp. (Personally I don’t care about temp but whatever, I’m sure some ppl do).

I have my local copy updated and monitor the disk usage all the time.


#7

Thanks for the explanation. The one issue that I come up with is selecting the partition to display. A lot of the installs are on systems with multiple partitions and we’d need a way to know which one to select for display. We’ll discuss that among the dev’s and see what we can come up with.


#8

I can see the usefulness of the feature, especially if Pi-hole is running constantly for years and accumulating data. However, I probably wouldn’t expect it to show on the main page; perhaps a banner (or some other settings page) appears if detects the disk is getting full.


#9

I think that something similar to rpi-monitor would be convenient for some of that additional info


#10

Thank you for considering this change.

I would not mind a server health page somewhere that would be easily accessible. Even the Settings page wouldn’t be bad.

If you’re concerned about UI space… you could always put in a title on the logo div that shows some information when you hover over it… Hidden features like this can be annoying but once you get used to it its fine.

div class=“pull-left image” title=“Disk Usage: 2.9gb
Something: Else
Even: More
Lots: of Info”

Thank you again for a great program.


#11

I think showing disk space is out-of-scope and something that can be checked/displayed by other utilities. Similar discussions took place about adding uptime in the same place and a similar conclusion was reached.


#12