Get size of specific repository in Nexus 3

怎甘沉沦 提交于 2019-12-03 11:23:57

问题


How can I get a size of specific repository in Nexus 3?

For example, Artifactory shows the repository "size on disk" via UI.

Does Nexus have something similar? If not - how can I get this information by script?


回答1:


You can use admin task with groovy script nx-blob-repo-space-report.groovy from https://issues.sonatype.org/browse/NEXUS-14837 - for me turned out too slow

Or you can get it from database:

  1. login with user-owner nexus installation on nexus server (e.g. nexus)

  2. go to application directory (e.g. /opt/nexus):

    $ cd /opt/nexus

  3. run java orient console:

    $ java -jar ./lib/support/nexus-orient-console.jar

  4. connect to local database (e.g. /opt/sonatype-work/nexus3/db/component):

    > CONNECT PLOCAL:/opt/sonatype-work/nexus3/db/component admin admin

  5. find out repository row id in @RID column by repository_name value:

    > select * from bucket limit 50;

  6. get sum for all assets with repo row id found in the previous step:

    > select sum(size) from asset where bucket = #15:9;

result should be like (apparently in bytes):
+----+------------+ |# |sum | +----+------------+ |0 |224981921470| +----+------------+

nexus database connection steps took from https://support.sonatype.com/hc/en-us/articles/115002930827-Accessing-the-OrientDB-Console

another useful queries

summary size by repository name (instead 5 and 6 steps):

> select sum(size) from asset where bucket.repository_name = 'releases';

top 10 repositories by size:

> select bucket.repository_name as repository,sum(size) as bytes from asset group by bucket.repository_name order by bytes desc limit 10;



回答2:


Assign each repository to its own Blob Store.




回答3:


There seems to be no such feature in the Nexus UI. To get the disk usage you can login to the Nexus server and go to the storage directory. There you will find all repositories as separate directories.

/opt/nexus/sonatype-work/nexus/storage# du -hs releases/
129G    releases/


来源:https://stackoverflow.com/questions/44816723/get-size-of-specific-repository-in-nexus-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!