Educational ICT Virtualisation Specialist

Twitter LinkedIn E-mail
Precedence Technologies Ltd
Technology House, 36a Union Lane
Cambridge, CB4 1QB, United Kingdom
T: +44 (0)8456 446 800 / +44 (0)1223 359900
E: enquiries@precedence.co.uk
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.

  1. Edit /etc/netmanager/netman.conf and add the following:
    php_maxmemory="512M"
    php_maxuploadsize="256M"
    
  2. Run /usr/libexec/build/php
  3. Download Disk Usage Reports as a zip file
  4. The zip file contains a folder called diskusagereports_d7418b7. Copy this to \\netmanager\webpages and rename to diskusage
  5. Check the basic installation is OK by going to http://netmanager/diskusage/
  6. 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.
  7. Copy \\netmanager\webpages\diskusage\scripts\find.exe into the script location
  8. 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
  9. Open the cURL zip file and look for the bin folder. In there, you will see curl.exe. Copy this to the script location
  10. 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 is G:\Shared):
    %0\..find.exe -ds / G:\Shared > %TMP%\files.txt
    %0\..curl.exe -F "filelist=@%TMP%\files.txt" http://netmanager/diskusage/submit.php
  11. 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 the curl.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
  12. 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";
    }
  13. 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 the Require 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
  14. 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)
  15. Set up scheduled tasks to run the batch file(s) on each server. Weekly is probably sufficient
© Copyright Precedence Technologies 1999-2024
Page last modified on August 15, 2019, at 04:55 PM by sborrill