How to fetch the SEGMENT_REPO_SIZE from JMX console through programmatically.
(JMX console link: http://localhost:4502/system/console/jmx/org.apache.jackrabbit.oak%3Aname%3DSEGMENT_REPO_SIZE%2Ctype...)
That's not really specific to AEM, but standard Java code.
MBeanServer mbs = java.lang.management.ManagementFactory.getPlatformMBeanServer;
ObjectName name = new ObjectName("org.apache.jackrabbit.oak:Metrics");
Object value = mbs.getAttribute(name,"Count");
System.out.println("Count = " + value.toString());
(please don't try to access this value via HTTP ... that's a guarantee to break.)
You can try to use AEM System Overview Dashboard and parse JSON output for a "Repository Size":
I believe you can just trigger a CURL command, similar to below:
curl -u admin:admin http://<host>:<port>/system/console/jmx/org.apache.jackrabbit.oak%3Aname%3DSEGMENT_REPO_SIZE%2Ctype%3DMetrics | grep "Attribute exposed for management" | cut -c 81-90