Arrow left Go to previous page / next page of Tier3 site log MOVED TO...

19. 12. 2012 Largest directories via Chimera

Based on Fabio's monitoring function the following function & query can be used to extract the largest folders in a given PNFS directory similar to the previous space usage reporting.

CREATE OR REPLACE FUNCTION pnfs_subdirs_du_r(VARCHAR,VARCHAR,INTEGER) RETURNS SETOF v_pnfs AS $$
DECLARE
    fileordir1   v_pnfs%rowtype;
    fileordir2   v_pnfs%rowtype;
    RESULT       BIGINT;
BEGIN
     
    FOR fileordir1 IN ( SELECT * FROM pnfs_dir($1) WHERE path LIKE '/'||$1||'/%' AND depth < $3 ) loop
     
       fileordir2 = fileordir1;
       SELECT INTO RESULT * FROM pnfs_dir_du( SUBSTRING ( fileordir1.path , 2 , LENGTH(fileordir1.path)) , $2) ;
       fileordir2.isize = RESULT;
       fileordir2.depth = fileordir2.depth + 1;
       RETURN NEXT fileordir2;
     
    END loop;
END;
$$ LANGUAGE plpgsql STABLE;

Then use the following query to get all folders below a given folder (up to depth D) ordered in decreasing order by size: Don't use that query on very large folders with many subfolders!

SELECT * FROM pnfs_subdirs_du_r('pnfs/psi.ch/cms/trivcat/store/user/dmeister','MB') ORDER BY isize DESC;

-- DanielMeister - 2012-12-19


Arrow left Go to previous page / next page of Tier3 site log MOVED TO...

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2012-12-19 - DanielMeister
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback