(DEFINE-FILE-INFO READTABLE "XCL" PACKAGE "INTERLISP")
(FILECREATED "19-Feb-88 19:27:57" {QV}<BURWELL>LISP>NSALLOCATION.\;3 6361   

      |changes| |to:|  (FNS NSALLOCATION.STATS NSALLOCATION)

      |previous| |date:| "19-Feb-88 18:05:54" {QV}<BURWELL>LISP>NSALLOCATION.\;1)


; Copyright (c) 1988 by Xerox Corporation.  All rights reserved.

(PRETTYCOMPRINT NSALLOCATIONCOMS)

(RPAQQ NSALLOCATIONCOMS ((FNS NSALLOCATION NSALLOCATION.STATS)))
(DEFINEQ

(NSALLOCATION
  (LAMBDA (|FileServers| |ReportFile| |Filter|)              (* \; "Edited 19-Feb-88 18:10 by bbb")

    (LET ((|NSDiskSizeInPages| 433907)
          |ReportFileStream|)
         (CL:WITH-OPEN-FILE (|ReportFileStream| |ReportFile| :DIRECTION :OUTPUT)
                (|if| |Filter|
                    |then| (|printout| |ReportFileStream| "Using Filter " |Filter| T T))
                (|printout| |ReportFileStream| .FONT '(TERMINAL 12) "File Service" .TAB 20 
                       "# Pages Used" .TAB 35 "as %" .TAB 45 "# Pages Used" .TAB 60 "as %" .TAB 70 
                       "# Pages" .TAB 80 "as %" .TAB 90 "Total % Used" T)
                (|printout| |ReportFileStream| "Name" .TAB 20 "Unrestricted" .TAB 35 "of disk" .TAB 
                       45 "Restricted" .TAB 60 "of alloc" .TAB 70 "alloc" .TAB 80 "of disk" .TAB 90 
                       "of disk" T)
                (|printout| |ReportFileStream| "----------------" .TAB 20 "------------" .TAB 35 
                       "-------" .TAB 45 "------------" .TAB 60 "--------" .TAB 70 "-------" .TAB 80 
                       "-------" .TAB 90 "------------" T)
                (|printout| |ReportFileStream| T)
                (|for| |Server| |in| |FileServers| |bind| |Result| |PagesUnrestricted| 
                                                         |PagesRestricted| |PagesAllocated| 
                                                         |PercentUnrestricted| 
                                                         |PercentRestrictedofAllocated| 
                                                         |PercentAllocated| |TotalPercentUsed|
                   |when| (SETQ |Result| (NSALLOCATION.STATS |Server| |Filter|))
                   |do| (SETQ |PagesUnrestricted| (CAR (NTH |Result| 1)))
                        (SETQ |PagesRestricted| (CAR (NTH |Result| 2)))
                        (SETQ |PagesAllocated| (CAR (NTH |Result| 3)))
                        (SETQ |PercentUnrestricted| (TIMES (FQUOTIENT |PagesUnrestricted| 
                                                                  |NSDiskSizeInPages|)
                                                           100.0))
                        (SETQ |PercentRestrictedofAllocated| (TIMES (FQUOTIENT |PagesRestricted| 
                                                                           |PagesAllocated|)
                                                                    100.0))
                        (SETQ |PercentAllocated| (TIMES (FQUOTIENT |PagesAllocated| 
                                                               |NSDiskSizeInPages|)
                                                        100.0))
                        (SETQ |TotalPercentUsed| (TIMES (FQUOTIENT (PLUS |PagesUnrestricted| 
                                                                         |PagesRestricted|)
                                                               |NSDiskSizeInPages|)
                                                        100.0))
                        (|printout| |ReportFileStream| |Server| .TAB 20 |.I12| |PagesUnrestricted| 
                               .TAB 35 |.F7.1| |PercentUnrestricted| .TAB 45 |.I12| |PagesRestricted| 
                               .TAB 60 |.F8.2| |PercentRestrictedofAllocated| .TAB 70 |.I7| 
                               |PagesAllocated| .TAB 80 |.F7.1| |PercentAllocated| .TAB 90 |.F12.1| 
                               |TotalPercentUsed| T))))))

(NSALLOCATION.STATS
  (LAMBDA (|FileServiceName| |Filter|)                       (* \; "Edited 19-Feb-88 19:20 by bbb")
          
          (* |;;| 
          "Given a file service name the following three pieces of data are returned in a list: ")
          
          (* |;;| " 1) number of pages in use of unrestricted file drawers")
          
          (* |;;| " 2) number of pages in use in restricted file drawers")
          
          (* |;;| " 3) number of pages allocated to file drawers")
          
          (* |;;| "")
          
          (* |;;| " If Filter is NON-NIL then it is used as a file pattern for selecting directories")

    (LET* ((|FileServiceDirectories| (DIRECTORY (CONCAT "{" |FileServiceName| "}")
                                            'COLLECT))
           (|FileServiceDevice| (\\GETDEVICEFROMNAME |FileServiceName|))
           (|NumBytesUnrestricted| 0)
           (|NumBytesRestricted| 0)
           (|NumBytesAllocated| 0)
           (|BytesPerPage| 512)
           (|Filter| (|if| |Filter|
                         |then| (DIRECTORY.MATCH.SETUP |Filter|))))
          (|for| |Directory| |in| |FileServiceDirectories| |bind| |DirectoryAllocation| 
                                                                 |DirectoryUsed|
             |when| (OR (NULL |Filter|)
                        (DIRECTORY.MATCH |Filter| |Directory|))
             |do| (SETQ |DirectoryAllocation| (\\NSFILING.GETFILEINFO |Directory| 'SUBTREE.SIZE.LIMIT 
                                                     |FileServiceDevice|))
                  (SETQ |DirectoryUsed| (\\NSFILING.GETFILEINFO |Directory| 'SUBTREE.SIZE 
                                               |FileServiceDevice|))
                  (|if| (IGEQ |DirectoryAllocation| 0)
                      |then| (|add| |NumBytesAllocated| |DirectoryAllocation|)
                            (|add| |NumBytesRestricted| |DirectoryUsed|)
                    |else| (|add| |NumBytesUnrestricted| |DirectoryUsed|)))
          (LIST (FQUOTIENT |NumBytesUnrestricted| |BytesPerPage|)
                (FQUOTIENT |NumBytesRestricted| |BytesPerPage|)
                (FQUOTIENT |NumBytesAllocated| |BytesPerPage|)))))
)
(PUTPROPS NSALLOCATION COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE\: DONTCOPY
  (FILEMAP (NIL (457 6277 (NSALLOCATION 467 . 3985) (NSALLOCATION.STATS 3987 . 6275)))))
STOP