DiskUsageReports
Jump To: Support > KB > Software > DiskUsageReports
Creating HTML disk usage reports with NetManager
This is a quick example of how you may automate disk usage reports and allow easy centralised access. It could be significantly improved.
- Edit
/etc/netmanager/netman.conf
and add the following:php_maxmemory="512M" php_maxuploadsize="256M"
- Run
/usr/libexec/build/php
- Download Disk Usage Reports as a zip file. On NetManager you can type:
ftp https://github.com/amekkawi/diskusagereports/archive/refs/heads/master.zip
- The zip file contains a folder called
diskusagereports-master
. Copy this to\\netmanager\webpages
and rename todiskusage
. On NetManager you can type:unzip -d ~www master.zip mv ~www/diskusagereports-master ~www/diskusage chown -R www ~www/diskusage
- Check the basic installation is OK by going to http://netmanager/diskusage/ (you will see Error: The settings file for the report was not found, but this can be ignored)
- Find a location to put scripts and utilities which can be run to generate the reports. For a single Windows fileserver, this can probably just be
C:\diskusage
, but you may want to use a central ITSupport share or such like. This will be referred to as the script location below. - Copy
\\netmanager\webpages\diskusage\scripts\find.exe
into the script location - Download cURL for Windows using one of the links at the cURL website. The latest win64 version can always be found here
- Open the cURL zip file and look for the bin folder. In there, you will see
curl.exe
. Copy this to the script location - Create a batch file call
genreport.bat
in the script location containing the following. Alter the location to the top level that you want to analyse (in this example it isG:\Shared
):set SUBMIT=http://netmanager/diskusage/submit.php
%0\..find.exe -ds / G:\Shared > %TMP%\files.txt
%0\..curl.exe -F "filelist=@%TMP%\files.txt" %SUBMIT%
%TMP%\files.txt - If you wish to run reports on multiple servers (or for different locations on a single server), you can specify a report name by adding
-F name=REPORTNAME
to thecurl.exe
line. The example below generates two different reports:set SUBMIT=http://netmanager/diskusage/submit.php
%0\..\find.exe -ds / G:\Shared > %TMP%\files.txt
%0\..\curl.exe -F "filelist=@%TMP%\files.txt" -F name=Shared %SUBMIT%
%0\..\find.exe -ds / G:\Staff > %TMP%\files.txt
%0\..\curl.exe -F "filelist=@%TMP%\files.txt" -F name=Staff %SUBMIT%
del %TMP%\files.txt - Create a file called
\\netmanager\webpages\diskusage\submit.php
(or ~www/diskusage/submit.php on NetManager) containing:<?php
if (!isset($_FILES['filelist'])) {
echo "No file given";
exit;
}
if (!is_uploaded_file($_FILES['filelist']['tmp_name'])) {
echo "File is not uploaded";
exit;
}
set_time_limit(0);
$d = dirname($_SERVER['SCRIPT_FILENAME']);
$cmd = "/usr/pkg/bin/php $d/scripts/process.php -mt 13107200 $d/data";
if (!empty($_REQUEST['name'])) {
$n = trim(basename($_REQUEST['name']));
$cmd .= "/$n";
}
$cmd .= " ".$_FILES['filelist']['tmp_name'];
exec($cmd, $output);
foreach ($output as $l) {
echo htmlentities($l)."<br/>\r\n";
} - Create a file ~www/diskusage/.htaccess on NetManager containing the following. Alter the
Allow from
line so it has a space-separated list of IP addresses which can view reports without having to log in (i.e. all fileservers, plus IT staff's PCs with statically configured IP addresses). Alter theRequire user
line to have a space-separated list of users who can view reports:Order Deny,Allow
Deny from all
# Add the IP addresses or ranges of the computers that can view reports without logging in
Allow from 10.0.0.0/24
Satisfy Any
AuthType Basic
AuthName "Disk Usage reports"
AuthExternal passwd
AuthBasicProvider external
# Add the users who can access reports from any computer
Require user username1 username2
<Files "submit.php">
Deny from all
# Add the IP addresses of the servers that will be submitting reports below
Allow from 10.0.0.5
</Files> - Run
genreport.bat
from the script location and then test it works at http://netmanager/diskusage/. If you have specified a report name with the-F name=REPORTNAME
option above, then you will need to go to http://netmanager/diskusage/?REPORTNAME (case-sensitive) - Set up scheduled tasks to run the batch file(s) on each server. Weekly is probably sufficient