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
- The zip file contains a folder called
diskusagereports_d7418b7
. Copy this to\\netmanager\webpages
and rename todiskusage
- Check the basic installation is OK by going to http://netmanager/diskusage/
- 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 Win 32 links at the cURL website. At the time of writing, you can get 7.60.0 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
):%0\..find.exe -ds / G:\Shared > %TMP%\files.txt
%0\..curl.exe -F "filelist=@%TMP%\files.txt" http://netmanager/diskusage/submit.php - 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:%0\..\find.exe -ds / G:\Shared > %TMP%\files.txt
%0\..\curl.exe -F "filelist=@%TMP%\files.txt" -F name=Shared http://netmanager/diskusage/submit.php
%0\..\find.exe -ds / G:\Staff > %TMP%\files.txt
%0\..\curl.exe -F "filelist=@%TMP%\files.txt" -F name=Staff http://netmanager/diskusage/submit.php - 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 $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
Allow from 10.0.0.0/24
Satisfy Any
AuthType Basic
AuthName "Disk Usage reports"
AuthExternal passwd
AuthBasicProvider external
Require user username1 username2 - 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